Class: Datadog::Tracing::Contrib::Sneakers::Tracer
- Inherits:
-
Object
- Object
- Datadog::Tracing::Contrib::Sneakers::Tracer
- Defined in:
- lib/datadog/tracing/contrib/sneakers/tracer.rb
Overview
Tracer is a Sneakers server-side middleware which traces executed jobs
Instance Method Summary collapse
- #call(deserialized_msg, delivery_info, metadata, handler) ⇒ Object
-
#initialize(app, *args) ⇒ Tracer
constructor
A new instance of Tracer.
Constructor Details
#initialize(app, *args) ⇒ Tracer
Returns a new instance of Tracer.
12 13 14 15 |
# File 'lib/datadog/tracing/contrib/sneakers/tracer.rb', line 12 def initialize(app, *args) @app = app @args = args end |
Instance Method Details
#call(deserialized_msg, delivery_info, metadata, handler) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/datadog/tracing/contrib/sneakers/tracer.rb', line 17 def call(deserialized_msg, delivery_info, , handler) = { service: configuration[:service_name], span_type: Tracing::Metadata::Ext::AppTypes::TYPE_WORKER, on_error: configuration[:error_handler] } Tracing.trace(Ext::SPAN_JOB, **) do |request_span| request_span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_MESSAGING_SYSTEM) request_span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT) request_span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_JOB) # Set analytics sample rate if Contrib::Analytics.enabled?(configuration[:analytics_enabled]) Contrib::Analytics.set_sample_rate(request_span, configuration[:analytics_sample_rate]) end # Measure service stats Contrib::Analytics.set_measured(request_span) request_span.resource = @app.to_proc.binding.eval('self.class').to_s request_span.set_tag(Ext::TAG_JOB_ROUTING_KEY, delivery_info.routing_key) request_span.set_tag(Ext::TAG_RABBITMQ_ROUTING_KEY, delivery_info.routing_key) request_span.set_tag(Ext::TAG_JOB_QUEUE, delivery_info.consumer.queue.name) request_span.set_tag(Ext::TAG_JOB_BODY, deserialized_msg) if configuration[:tag_body] request_span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CONSUMER) @app.call(deserialized_msg, delivery_info, , handler) end end |