Skip to content

Commit

Permalink
Don't apply Scope's transaction name to the event if it already has one
Browse files Browse the repository at this point in the history
This makes transaction event's transaction being overriden when
`Transaction#finish` is called.

Fixes #1540.
  • Loading branch information
st0012 committed Aug 21, 2021
1 parent af9803a commit a1b823a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sentry-ruby/lib/sentry/scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ def apply_to_event(event, hint = nil)
event.user = user.merge(event.user)
event.extra = extra.merge(event.extra)
event.contexts = contexts.merge(event.contexts)
event.transaction ||= transaction_names.last

if span
event.contexts[:trace] = span.get_trace_context
end

event.fingerprint = fingerprint
event.level = level
event.transaction = transaction_names.last
event.breadcrumbs = breadcrumbs
event.rack_env = rack_env if rack_env

Expand Down
9 changes: 9 additions & 0 deletions sentry-ruby/spec/sentry/transaction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,15 @@
expect(event[:spans]).to be_empty
end

it "doesn't override the event's transaction attribute with the scope's" do
subject.finish

expect(events.count).to eq(1)
event = events.last.to_hash

expect(event[:transaction]).to eq("foo")
end

describe "hub selection" do
it "prioritizes the optional hub argument and uses it to submit the transaction" do
expect(another_hub).to receive(:capture_event)
Expand Down

0 comments on commit a1b823a

Please sign in to comment.