libhoney 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbbdf54cf6c6f49316a2599197b3418c20a65d171c49c7bb2e3be25fc98fb7e7
4
- data.tar.gz: 765269d8c9a3d028469ae41904934f879f72a33ebe137f65f61448979a149dac
3
+ metadata.gz: ab4842399534d125e9b6a5efeacca99e6a6a49f07caef2c71e0ac70430e13830
4
+ data.tar.gz: e497f15c36c2856e8c26bd7ac3ea814e1262d1d42e96ceb462fed7d6a5f143cd
5
5
  SHA512:
6
- metadata.gz: c9a32d01167fa4e618c75c563ea225ba33df1a70bb0bc26a86f3bdf41f874ffa6335e1686875bc887408e13c4742bd2b0a67e1f24d53730e89756d29620060d1
7
- data.tar.gz: f110fe871e6fb626590d57fde6b138b03d0236c8ef828bf2b9991220d92d58f2b67c0f4de1a452d8944ecbf3f6917892ecd1425a0377dc367d488cc75c62d996
6
+ metadata.gz: 99449aa5c26539244ec71bc27e5fca1de59119171d3ac0f06d35bcaf5c8207fe82ffde7c6e0bd9bfa7bad7bb1539098669b3da09a6b61fffc9cafb1ed6de977d
7
+ data.tar.gz: 504dc7078f44dc2065ff2f020547aca89c58d0c3c1d3d6c4ed9d9aeb3a6dbd336c94442b54f487d336eded810485f5231a97351ac82ae200bb64b5cd6a8682bf
data/README.md CHANGED
@@ -61,6 +61,27 @@ Check out the documentation for [`Libhoney::Client`](http://www.rubydoc.info/gem
61
61
 
62
62
  You can find a more complete example demonstrating usage in [`example/fact.rb`](example/fact.rb)
63
63
 
64
+ ## Debugging instrumentation
65
+
66
+ If you've instrumented your code to send events to Honeycomb, you may want to
67
+ verify that you're sending the events you expected at the right time with the
68
+ desired fields. To support this use case, libhoney provides a
69
+ [`LogClient`](http://www.rubydoc.info/gems/libhoney/Libhoney/LogClient) that
70
+ outputs events to standard error, which you can swap in for the usual `Client`.
71
+ Example usage:
72
+
73
+ ```ruby
74
+ honeycomb = Libhoney::LogClient.new
75
+
76
+ my_app = MyApp.new(..., honeycomb, ...)
77
+ my_app.do_stuff
78
+ # should output events to standard error
79
+ ```
80
+
81
+ Note that this will disable sending events to Honeycomb, so you'll want to
82
+ revert this change once you've verified that the events are coming through
83
+ appropriately.
84
+
64
85
  ## Testing instrumented code
65
86
 
66
87
  Once you've instrumented your code to send events to Honeycomb, you may want to
@@ -210,27 +210,4 @@ module Libhoney
210
210
  rand(1..sample_rate) != 1
211
211
  end
212
212
  end
213
-
214
- # A client with the network stubbed out for testing purposes. Does not
215
- # actually send any events to Honeycomb; instead, records events for later
216
- # inspection.
217
- #
218
- # @note This class is intended for use in tests, for example if you want to
219
- # verify what events your instrumented code is sending. Use in
220
- # production is not recommended.
221
- class TestClient < Client
222
- def initialize(*args, **kwargs)
223
- super(*args, transmission: MockTransmissionClient.new, **kwargs)
224
- end
225
-
226
- # @return [Array<Event>] the recorded events
227
- def events
228
- @tx.events
229
- end
230
-
231
- # Discards the recorded events
232
- def reset
233
- @tx.reset
234
- end
235
- end
236
213
  end
@@ -0,0 +1,20 @@
1
+ require 'libhoney/client'
2
+
3
+ module Libhoney
4
+
5
+ # A client that prints events to stderr or a file for inspection. Does not
6
+ # actually send any events to Honeycomb; instead, records events for later
7
+ # inspection.
8
+ #
9
+ # @note This class is intended for use in development, for example if you want
10
+ # to verify what events your instrumented code is sending. Use in
11
+ # production is not recommended.
12
+ class LogClient < Client
13
+ def initialize(*args, output: ::STDERR, verbose: false, **kwargs)
14
+ super(*args,
15
+ transmission: LogTransmissionClient.new(output: output, verbose: verbose),
16
+ **kwargs)
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,34 @@
1
+ require 'json'
2
+
3
+ module Libhoney
4
+ # For debugging use: a mock version of TransmissionClient that simply prints
5
+ # events to stderr or a file for inspection (and does not send them to
6
+ # Honeycomb, or perform any network activity).
7
+ #
8
+ # @note This class is intended for use in development, for example if you want
9
+ # to verify what events your instrumented code is sending. Use in
10
+ # production is not recommended.
11
+ class LogTransmissionClient
12
+ def initialize(output:, verbose: false)
13
+ @output = output
14
+ @verbose = verbose
15
+ end
16
+
17
+ # Prints an event
18
+ def add(event)
19
+ if @verbose
20
+ metadata = "Honeycomb dataset '#{event.dataset}' | #{event.timestamp.iso8601}"
21
+ if event.sample_rate != 1
22
+ metadata << " (sample rate: #{event.sample_rate})"
23
+ end
24
+ @output.print("#{metadata} | ")
25
+ end
26
+ @output.puts(event.data.to_json)
27
+ end
28
+
29
+ # Flushes the output (but does not close it)
30
+ def close(drain)
31
+ @output.flush
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ require 'libhoney/client'
2
+
3
+ module Libhoney
4
+
5
+ # A client with the network stubbed out for testing purposes. Does not
6
+ # actually send any events to Honeycomb; instead, records events for later
7
+ # inspection.
8
+ #
9
+ # @note This class is intended for use in tests, for example if you want to
10
+ # verify what events your instrumented code is sending. Use in
11
+ # production is not recommended.
12
+ class TestClient < Client
13
+ def initialize(*args, **kwargs)
14
+ super(*args, transmission: MockTransmissionClient.new, **kwargs)
15
+ end
16
+
17
+ # @return [Array<Event>] the recorded events
18
+ def events
19
+ @tx.events
20
+ end
21
+
22
+ # Discards the recorded events
23
+ def reset
24
+ @tx.reset
25
+ end
26
+ end
27
+
28
+ end
@@ -1,3 +1,3 @@
1
1
  module Libhoney
2
- VERSION = "1.6.0"
2
+ VERSION = "1.7.0"
3
3
  end
data/lib/libhoney.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'libhoney/client'
2
+ require 'libhoney/log_client'
3
+ require 'libhoney/test_client'
2
4
  require 'libhoney/version'
3
5
  require 'libhoney/builder'
4
6
  require 'libhoney/response'
5
7
  require 'libhoney/transmission'
8
+ require 'libhoney/log_transmission'
6
9
  require 'libhoney/mock_transmission'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libhoney
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Honeycomb.io Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-19 00:00:00.000000000 Z
11
+ date: 2018-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -141,8 +141,11 @@ files:
141
141
  - lib/libhoney/builder.rb
142
142
  - lib/libhoney/client.rb
143
143
  - lib/libhoney/event.rb
144
+ - lib/libhoney/log_client.rb
145
+ - lib/libhoney/log_transmission.rb
144
146
  - lib/libhoney/mock_transmission.rb
145
147
  - lib/libhoney/response.rb
148
+ - lib/libhoney/test_client.rb
146
149
  - lib/libhoney/transmission.rb
147
150
  - lib/libhoney/version.rb
148
151
  - libhoney.gemspec