Class: Libhoney::LogTransmissionClient
- Inherits:
-
Object
- Object
- Libhoney::LogTransmissionClient
- Includes:
- Cleaner
- Defined in:
- lib/libhoney/log_transmission.rb
Overview
Note:
This class is intended for use in development, for example if you want to verify what events your instrumented code is sending. Use in production is not recommended.
For debugging use: a mock version of TransmissionClient that simply prints events to stderr or a file for inspection (and does not send them to Honeycomb, or perform any network activity).
Constant Summary
Constants included from Cleaner
Cleaner::ENCODING_OPTIONS, Cleaner::RAISED, Cleaner::RECURSION
Instance Method Summary collapse
-
#add(event) ⇒ Object
Prints an event.
-
#close(_drain) ⇒ Object
Flushes the output (but does not close it).
-
#initialize(output:, verbose: false) ⇒ LogTransmissionClient
constructor
A new instance of LogTransmissionClient.
Methods included from Cleaner
Constructor Details
#initialize(output:, verbose: false) ⇒ LogTransmissionClient
Returns a new instance of LogTransmissionClient.
15 16 17 18 |
# File 'lib/libhoney/log_transmission.rb', line 15 def initialize(output:, verbose: false) @output = output @verbose = verbose end |
Instance Method Details
#add(event) ⇒ Object
Prints an event
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/libhoney/log_transmission.rb', line 21 def add(event) Thread.current[:libhoney_transmitting] = true if @verbose = "Honeycomb dataset '#{event.dataset}' | #{event..iso8601}" << " (sample rate: #{event.sample_rate})" if event.sample_rate != 1 @output.print("#{} | ") end clean_data(event.data).tap do |data| @output.puts(data.to_json) end ensure Thread.current[:libhoney_transmitting] = false end |
#close(_drain) ⇒ Object
Flushes the output (but does not close it)
36 37 38 |
# File 'lib/libhoney/log_transmission.rb', line 36 def close(_drain) @output.flush end |