Class: Chronos::Core::TelemetryEvent
- Inherits:
-
Object
- Object
- Chronos::Core::TelemetryEvent
- Defined in:
- lib/chronos/core/telemetry_event.rb
Overview
Immutable framework telemetry event normalized to the Chronos v1 envelope.
Constant Summary collapse
- TYPES =
%w(request query job cache).freeze
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#event_id ⇒ Object
readonly
Returns the value of attribute event_id.
-
#event_type ⇒ Object
readonly
Returns the value of attribute event_type.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(event_type, payload = {}, context = {}, options = {}) ⇒ TelemetryEvent
constructor
A new instance of TelemetryEvent.
Constructor Details
#initialize(event_type, payload = {}, context = {}, options = {}) ⇒ TelemetryEvent
Returns a new instance of TelemetryEvent.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/chronos/core/telemetry_event.rb', line 23 def initialize(event_type, payload = {}, context = {}, = {}) type = event_type.to_s raise ArgumentError, "unsupported telemetry event type" unless TYPES.include?(type) clock = [:clock] || proc { Time.now } @event_id = ([:event_id] || SecureRandom.uuid).to_s.freeze @event_type = type.freeze @timestamp = clock.call.utc.iso8601(6).freeze @context = deep_freeze(context.is_a?(Hash) ? context : {}) @payload = deep_freeze(payload.is_a?(Hash) ? payload : {}) freeze end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
21 22 23 |
# File 'lib/chronos/core/telemetry_event.rb', line 21 def context @context end |
#event_id ⇒ Object (readonly)
Returns the value of attribute event_id.
21 22 23 |
# File 'lib/chronos/core/telemetry_event.rb', line 21 def event_id @event_id end |
#event_type ⇒ Object (readonly)
Returns the value of attribute event_type.
21 22 23 |
# File 'lib/chronos/core/telemetry_event.rb', line 21 def event_type @event_type end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
21 22 23 |
# File 'lib/chronos/core/telemetry_event.rb', line 21 def payload @payload end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
21 22 23 |
# File 'lib/chronos/core/telemetry_event.rb', line 21 def @timestamp end |