Class: Libhoney::MockTransmissionClient
- Inherits:
-
Object
- Object
- Libhoney::MockTransmissionClient
- Defined in:
- lib/libhoney/mock_transmission.rb
Overview
Note:
This class is intended for use in tests, for example if you want to verify what events your instrumented code is sending. Use in production is not recommended.
For testing use: a mock version of TransmissionClient that retains all events in an in-memory queue for inspection (and does not send them to Honeycomb, or perform any network activity).
Instance Attribute Summary collapse
-
#events ⇒ Array<Event>
readonly
The recorded events.
Instance Method Summary collapse
-
#add(event) ⇒ Object
Records an event.
-
#close(drain) ⇒ Object
Does nothing.
-
#initialize(**_) ⇒ MockTransmissionClient
constructor
A new instance of MockTransmissionClient.
-
#reset ⇒ Object
Discards the recorded events.
Constructor Details
#initialize(**_) ⇒ MockTransmissionClient
Returns a new instance of MockTransmissionClient.
10 11 12 |
# File 'lib/libhoney/mock_transmission.rb', line 10 def initialize(**_) reset end |
Instance Attribute Details
#events ⇒ Array<Event> (readonly)
Returns the recorded events.
15 16 17 |
# File 'lib/libhoney/mock_transmission.rb', line 15 def events @events end |
Instance Method Details
#add(event) ⇒ Object
Records an event
18 19 20 21 22 23 |
# File 'lib/libhoney/mock_transmission.rb', line 18 def add(event) Thread.current[:libhoney_transmitting] = true @events.push(event) ensure Thread.current[:libhoney_transmitting] = false end |
#close(drain) ⇒ Object
Does nothing.
26 |
# File 'lib/libhoney/mock_transmission.rb', line 26 def close(drain); end |
#reset ⇒ Object
Discards the recorded events
29 30 31 |
# File 'lib/libhoney/mock_transmission.rb', line 29 def reset @events = [] end |