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

#set_span_data

Instance Method Details

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



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/sentry/sidekiq/sentry_context_middleware.rb', line 93

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?
  job["trace_propagation_headers"] ||= Sentry.get_trace_propagation_headers

  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