Skip to content

Commit

Permalink
Fix skipping 'connect' spans (#2364)
Browse files Browse the repository at this point in the history
  • Loading branch information
solnic authored Aug 8, 2024
1 parent 47c4458 commit 278316c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
- Transaction data are now included in the context ([#2365](https://github.com/getsentry/sentry-ruby/pull/2365))
- Closes [#2364](https://github.com/getsentry/sentry-ruby/issues/2363)

### Bug Fixes

- Fix skipping `connect` spans in open-telemetry [#2364](https://github.com/getsentry/sentry-ruby/pull/2364)

## 5.18.2

### Bug Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def from_sentry_sdk?(otel_span)
dsn = Sentry.configuration.dsn
return false unless dsn

if otel_span.name.start_with?("HTTP")
if otel_span.name.start_with?("HTTP") || otel_span.name == "connect"
# only check client requests, connects are sometimes internal
return false unless INTERNAL_SPAN_KINDS.include?(otel_span.kind)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@
tracer.start_span('HTTP POST', with_parent: root_parent_context, attributes: attributes, kind: :client)
end

let(:child_internal_span_connect) do
attributes = {
'http.method' => 'POST',
'http.scheme' => 'https',
'http.target' => '/api/5434472/envelope/',
'net.peer.name' => 'sentry.localdomain',
'net.peer.port' => 443
}

tracer.start_span('connect', with_parent: root_parent_context, attributes: attributes, kind: :internal)
end

before do
perform_basic_setup
perform_otel_setup
Expand Down Expand Up @@ -153,6 +165,11 @@
subject.on_start(child_internal_span, root_parent_context)
end

it 'noops on `connect` requests' do
expect(transaction).not_to receive(:start_child)
subject.on_start(child_internal_span_connect, root_parent_context)
end

it 'starts a sentry child span on otel child span' do
expect(transaction).to receive(:start_child).and_call_original
subject.on_start(child_db_span, root_parent_context)
Expand Down

0 comments on commit 278316c

Please sign in to comment.