Skip to content

Commit

Permalink
Add origin to Sidekiq
Browse files Browse the repository at this point in the history
  • Loading branch information
sl0thentr0py committed Jun 6, 2024
1 parent 992418c commit 225b86a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sentry-sidekiq/lib/sentry/sidekiq/sentry_context_middleware.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# frozen_string_literal: true

require 'sentry/sidekiq/context_filter'

module Sentry
module Sidekiq
class SentryContextServerMiddleware
OP_NAME = "queue.sidekiq".freeze
OP_NAME = "queue.sidekiq"
SPAN_ORIGIN = "auto.queue.sidekiq"

def call(_worker, job, queue)
return yield unless Sentry.initialized?
Expand Down Expand Up @@ -40,7 +43,13 @@ def build_tags(tags)
end

def start_transaction(scope, env)
options = { name: scope.transaction_name, source: scope.transaction_source, op: OP_NAME }
options = {
name: scope.transaction_name,
source: scope.transaction_source,
op: OP_NAME,
origin: SPAN_ORIGIN
}

transaction = Sentry.continue_trace(env, **options)
Sentry.start_transaction(transaction: transaction, **options)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
expect(event.tags.keys).to include(:"sidekiq.marvel", :"sidekiq.dc")
end

it "has the correct origin" do
execute_worker(processor, TagsWorker)
transaction = transport.events.last
expect(transaction.contexts.dig(:trace, :origin)).to eq('auto.queue.sidekiq')
end

context "with trace_propagation_headers" do
let(:parent_transaction) { Sentry.start_transaction(op: "sidekiq") }

Expand Down

0 comments on commit 225b86a

Please sign in to comment.