Class: OpenTelemetry::Instrumentation::Rage::Handlers::Events
- Inherits:
-
Rage::Telemetry::Handler
- Object
- Rage::Telemetry::Handler
- OpenTelemetry::Instrumentation::Rage::Handlers::Events
- Defined in:
- lib/opentelemetry/instrumentation/rage/handlers/events.rb
Overview
The class records the publishing of Rage events and wraps event subscribers in spans.
Class Method Summary collapse
Class Method Details
.create_publisher_span(event:) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/opentelemetry/instrumentation/rage/handlers/events.rb', line 20 def self.create_publisher_span(event:, &) current_span = OpenTelemetry::Trace.current_span return yield unless current_span.recording? kind = :producer attributes = { SemConv::Incubating::MESSAGING::MESSAGING_SYSTEM => "rage.events", SemConv::Incubating::MESSAGING::MESSAGING_OPERATION_TYPE => "send", SemConv::Incubating::MESSAGING::MESSAGING_DESTINATION_NAME => event.class.name } Rage::Instrumentation.instance.tracer.in_span("#{event.class} publish", kind:, attributes:, &) end |
.create_subscriber_span(event:, subscriber:) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/opentelemetry/instrumentation/rage/handlers/events.rb', line 36 def self.create_subscriber_span(event:, subscriber:) # deferred subscribers will be wrapped into spans by the `Handlers::Deferred` handler return yield if subscriber.class.deferred? kind = :consumer attributes = { SemConv::Incubating::MESSAGING::MESSAGING_SYSTEM => "rage.events", SemConv::Incubating::MESSAGING::MESSAGING_OPERATION_TYPE => "process", SemConv::Incubating::MESSAGING::MESSAGING_DESTINATION_NAME => event.class.name } Rage::Instrumentation.instance.tracer.in_span("#{subscriber.class} process", kind:, attributes:) do |span| result = yield if result.error? span.record_exception(result.exception) span.status = OpenTelemetry::Trace::Status.error end end end |