diff --git a/CHANGELOG.md b/CHANGELOG.md index cdb83c687..087f72996 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/sentry-opentelemetry/lib/sentry/opentelemetry/span_processor.rb b/sentry-opentelemetry/lib/sentry/opentelemetry/span_processor.rb index db6d500f0..71152ad29 100644 --- a/sentry-opentelemetry/lib/sentry/opentelemetry/span_processor.rb +++ b/sentry-opentelemetry/lib/sentry/opentelemetry/span_processor.rb @@ -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) diff --git a/sentry-opentelemetry/spec/sentry/opentelemetry/span_processor_spec.rb b/sentry-opentelemetry/spec/sentry/opentelemetry/span_processor_spec.rb index 48d27596e..0d5626730 100644 --- a/sentry-opentelemetry/spec/sentry/opentelemetry/span_processor_spec.rb +++ b/sentry-opentelemetry/spec/sentry/opentelemetry/span_processor_spec.rb @@ -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 @@ -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)