Class: ActiveJob::Temporal::Observability::OpenTelemetry
- Defined in:
- lib/activejob/temporal/observability/opentelemetry.rb
Constant Summary collapse
- SPAN_EVENTS =
%i[enqueue perform retry].freeze
Instance Attribute Summary collapse
-
#propagation ⇒ Object
writeonly
Sets the attribute propagation.
-
#tracer ⇒ Object
writeonly
Sets the attribute tracer.
Attributes inherited from Adapter
Instance Method Summary collapse
-
#initialize(tracer: nil, propagation: nil) ⇒ OpenTelemetry
constructor
A new instance of OpenTelemetry.
- #instrument(event_name, payload, &block) ⇒ Object
- #record(event_name, payload) ⇒ Object
- #trace_context_for_enqueue(_payload) ⇒ Object
- #validate_dependencies! ⇒ Object
Methods inherited from Adapter
#start!, #started?, #stop!, #validate!
Constructor Details
#initialize(tracer: nil, propagation: nil) ⇒ OpenTelemetry
Returns a new instance of OpenTelemetry.
14 15 16 17 18 |
# File 'lib/activejob/temporal/observability/opentelemetry.rb', line 14 def initialize(tracer: nil, propagation: nil) super(:opentelemetry) @tracer = tracer @propagation = propagation end |
Instance Attribute Details
#propagation=(value) ⇒ Object
Sets the attribute propagation
12 13 14 |
# File 'lib/activejob/temporal/observability/opentelemetry.rb', line 12 def propagation=(value) @propagation = value end |
#tracer=(value) ⇒ Object
Sets the attribute tracer
12 13 14 |
# File 'lib/activejob/temporal/observability/opentelemetry.rb', line 12 def tracer=(value) @tracer = value end |
Instance Method Details
#instrument(event_name, payload, &block) ⇒ Object
32 33 34 35 36 |
# File 'lib/activejob/temporal/observability/opentelemetry.rb', line 32 def instrument(event_name, payload, &block) return block.call unless SPAN_EVENTS.include?(event_name) trace(event_name, payload, &block) end |
#record(event_name, payload) ⇒ Object
26 27 28 29 30 |
# File 'lib/activejob/temporal/observability/opentelemetry.rb', line 26 def record(event_name, payload) return unless event_name == :enqueue trace(:enqueue, payload) { nil } end |
#trace_context_for_enqueue(_payload) ⇒ Object
20 21 22 23 24 |
# File 'lib/activejob/temporal/observability/opentelemetry.rb', line 20 def trace_context_for_enqueue(_payload) carrier = {} propagation.inject(carrier) carrier end |
#validate_dependencies! ⇒ Object
38 39 40 41 |
# File 'lib/activejob/temporal/observability/opentelemetry.rb', line 38 def validate_dependencies! require_dependency("opentelemetry-sdk", "opentelemetry/sdk", "OpenTelemetry") self end |