Class: Datadog::Tracing::Contrib::Sidekiq::ClientTracer
- Inherits:
-
Object
- Object
- Datadog::Tracing::Contrib::Sidekiq::ClientTracer
- Includes:
- Utils
- Defined in:
- lib/datadog/tracing/contrib/sidekiq/client_tracer.rb
Overview
Tracer is a Sidekiq client-side middleware which traces job enqueues/pushes
Instance Method Summary collapse
-
#call(worker_class, job, queue, redis_pool) ⇒ Object
Client middleware arguments are documented here: github.com/mperham/sidekiq/wiki/Middleware#client-middleware.
-
#initialize(options = {}) ⇒ ClientTracer
constructor
A new instance of ClientTracer.
Constructor Details
#initialize(options = {}) ⇒ ClientTracer
Returns a new instance of ClientTracer.
17 18 19 |
# File 'lib/datadog/tracing/contrib/sidekiq/client_tracer.rb', line 17 def initialize( = {}) @sidekiq_service = [:client_service_name] || configuration[:client_service_name] end |
Instance Method Details
#call(worker_class, job, queue, redis_pool) ⇒ Object
Client middleware arguments are documented here:
https://github.com/mperham/sidekiq/wiki/Middleware#client-middleware
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 50 51 |
# File 'lib/datadog/tracing/contrib/sidekiq/client_tracer.rb', line 23 def call(worker_class, job, queue, redis_pool) resource = job_resource(job) Datadog::Tracing.trace(Ext::SPAN_PUSH, service: @sidekiq_service) do |span, trace_op| propagation.inject!(trace_op, job) if configuration[:distributed_tracing] span.resource = resource span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT) span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT) span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_PUSH) span.set_tag( Datadog::Tracing::Metadata::Ext::TAG_KIND, Datadog::Tracing::Metadata::Ext::SpanKind::TAG_PRODUCER ) # Set analytics sample rate if Contrib::Analytics.enabled?(configuration[:analytics_enabled]) Contrib::Analytics.set_sample_rate(span, configuration[:analytics_sample_rate]) end span.set_tag(Ext::TAG_JOB_ID, job['jid']) span.set_tag(Ext::TAG_JOB_QUEUE, job['queue']) span.set_tag(Ext::TAG_JOB_WRAPPER, job['class']) if job['wrapped'] yield end end |