Class: Datadog::Tracing::Contrib::Shoryuken::Tracer
- Inherits:
-
Object
- Object
- Datadog::Tracing::Contrib::Shoryuken::Tracer
- Defined in:
- lib/datadog/tracing/contrib/shoryuken/tracer.rb
Overview
Tracer is a Shoryuken server-side middleware which traces executed jobs
Instance Method Summary collapse
- #call(worker_instance, queue, sqs_msg, body) ⇒ Object
-
#initialize(options = {}) ⇒ Tracer
constructor
A new instance of Tracer.
Constructor Details
#initialize(options = {}) ⇒ Tracer
Returns a new instance of Tracer.
11 12 13 14 |
# File 'lib/datadog/tracing/contrib/shoryuken/tracer.rb', line 11 def initialize( = {}) @shoryuken_service = [:service_name] || configuration[:service_name] @on_error = [:on_error] || configuration[:on_error] end |
Instance Method Details
#call(worker_instance, queue, sqs_msg, body) ⇒ Object
16 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 |
# File 'lib/datadog/tracing/contrib/shoryuken/tracer.rb', line 16 def call(worker_instance, queue, sqs_msg, body) Tracing.trace( Ext::SPAN_JOB, service: @shoryuken_service, type: Tracing::Metadata::Ext::AppTypes::TYPE_WORKER, on_error: @on_error ) do |span| span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_MESSAGING_SYSTEM) span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT) 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(span, configuration[:analytics_sample_rate]) end # Measure service stats Contrib::Analytics.set_measured(span) span.resource = resource(worker_instance, body) span.set_tag(Ext::TAG_JOB_ID, sqs_msg.) span.set_tag(Ext::TAG_JOB_QUEUE, queue) span.set_tag(Ext::TAG_JOB_ATTRIBUTES, sqs_msg.attributes) if sqs_msg.respond_to?(:attributes) span.set_tag(Ext::TAG_JOB_BODY, body) if configuration[:tag_body] span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CONSUMER) yield end end |