Class: Datadog::Contrib::Sidekiq::ServerTracer
- Inherits:
-
Object
- Object
- Datadog::Contrib::Sidekiq::ServerTracer
- Includes:
- Tracing
- Defined in:
- lib/ddtrace/contrib/sidekiq/server_tracer.rb
Overview
Tracer is a Sidekiq server-side middleware which traces executed jobs
Instance Method Summary collapse
- #call(worker, job, queue) ⇒ Object
-
#initialize(options = {}) ⇒ ServerTracer
constructor
A new instance of ServerTracer.
Constructor Details
#initialize(options = {}) ⇒ ServerTracer
Returns a new instance of ServerTracer.
11 12 13 14 |
# File 'lib/ddtrace/contrib/sidekiq/server_tracer.rb', line 11 def initialize( = {}) super @sidekiq_service = [:service_name] || configuration[:service_name] end |
Instance Method Details
#call(worker, job, queue) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ddtrace/contrib/sidekiq/server_tracer.rb', line 16 def call(worker, job, queue) resource = job_resource(job) service = service_from_worker_config(resource) || @sidekiq_service @tracer.trace(Ext::SPAN_JOB, service: service, span_type: Datadog::Ext::AppTypes::WORKER) do |span| span.resource = resource # 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_RETRY, job['retry']) span.set_tag(Ext::TAG_JOB_QUEUE, job['queue']) span.set_tag(Ext::TAG_JOB_WRAPPER, job['class']) if job['wrapped'] span.set_tag(Ext::TAG_JOB_DELAY, 1000.0 * (Time.now.utc.to_f - job['enqueued_at'].to_f)) yield end end |