Class: Sentry::Sidekiq::SentryContextClientMiddleware

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/sentry/sidekiq/sentry_context_middleware.rb

Instance Method Summary collapse

Methods included from Helpers

#calculate_latency, #now_in_ms, #set_span_data

Instance Method Details

#call(worker_class, job, queue, _redis_pool) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/sentry/sidekiq/sentry_context_middleware.rb', line 108

def call(worker_class, job, queue, _redis_pool)
  return yield unless Sentry.initialized?

  user = Sentry.get_current_scope.user
  job["sentry_user"] = user unless user.empty?

  if Sentry.configuration.sidekiq.propagate_traces
    job["trace_propagation_headers"] ||= Sentry.get_trace_propagation_headers
  end

  Sentry.with_child_span(op: "queue.publish", description: worker_class.to_s) do |span|
    set_span_data(span, id: job["jid"], queue: queue)

    yield
  end
end