From e666be18e2720b5500c01048d5929b8cac05e3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Wolf?= Date: Mon, 9 Feb 2026 17:13:54 +0100 Subject: [PATCH 1/2] fix(telemetry): Remove DSN object from envelope header The DSN object was incorrectly included in the envelope headers for telemetry events (logs, metrics), causing serialization failures when the envelope was converted to JSON. The error occurred because JSON.generate() couldn't serialize the DSN object (a complex Ruby object) directly. The server rejected these envelopes with: invalid event envelope invalid type: map, expected a string at line 1 column 360 This fix removes the dsn parameter from the Envelope initialization in TelemetryEventBuffer#send_items, aligning it with how other envelope types (events, sessions) are created in the codebase, which don't include the DSN in their headers. The DSN is not needed in the envelope header as the transport layer already has access to it for routing the request to the correct Sentry endpoint. Fixes log ingestion when config.enable_logs is enabled. --- sentry-ruby/lib/sentry/telemetry_event_buffer.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/sentry-ruby/lib/sentry/telemetry_event_buffer.rb b/sentry-ruby/lib/sentry/telemetry_event_buffer.rb index 8c5ce0781..b256a6e84 100644 --- a/sentry-ruby/lib/sentry/telemetry_event_buffer.rb +++ b/sentry-ruby/lib/sentry/telemetry_event_buffer.rb @@ -84,7 +84,6 @@ def send_items envelope = Envelope.new( event_id: Sentry::Utils.uuid, sent_at: Sentry.utc_now.iso8601, - dsn: @dsn, sdk: Sentry.sdk_meta ) From c808fc5d99422a4c1f0b14b5a609f18de37504fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Wolf?= Date: Mon, 9 Feb 2026 19:28:13 +0100 Subject: [PATCH 2/2] fix(telemetry): Convert DSN to string in envelope header The previous fix incorrectly removed the DSN from the envelope header entirely. However, the DSN should be included but must be converted to a string using .to_s before being added to the header. This aligns with the existing implementation in Transport#envelope_from_event (transport.rb:122) which uses `dsn: @dsn.to_s`. Changes: - Add dsn back to envelope header in TelemetryEventBuffer#send_items, converting it to string with .to_s - Fix test in metrics_spec.rb to expect string DSN instead of DSN object This ensures telemetry envelopes can be properly serialized to JSON while maintaining consistency with how other envelope types handle DSN. --- sentry-ruby/lib/sentry/telemetry_event_buffer.rb | 1 + sentry-ruby/spec/sentry/metrics_spec.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sentry-ruby/lib/sentry/telemetry_event_buffer.rb b/sentry-ruby/lib/sentry/telemetry_event_buffer.rb index b256a6e84..5122a4af9 100644 --- a/sentry-ruby/lib/sentry/telemetry_event_buffer.rb +++ b/sentry-ruby/lib/sentry/telemetry_event_buffer.rb @@ -84,6 +84,7 @@ def send_items envelope = Envelope.new( event_id: Sentry::Utils.uuid, sent_at: Sentry.utc_now.iso8601, + dsn: @dsn.to_s, sdk: Sentry.sdk_meta ) diff --git a/sentry-ruby/spec/sentry/metrics_spec.rb b/sentry-ruby/spec/sentry/metrics_spec.rb index 874c1e8d0..78284e489 100644 --- a/sentry-ruby/spec/sentry/metrics_spec.rb +++ b/sentry-ruby/spec/sentry/metrics_spec.rb @@ -248,7 +248,7 @@ expect(headers[:event_id]).to match(/\A[0-9a-f]{32}\z/) # UUID format expect(headers[:sent_at]).to match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/) # ISO8601 timestamp - expect(headers[:dsn]).to eq(Sentry.configuration.dsn) + expect(headers[:dsn]).to eq(Sentry.configuration.dsn.to_s) expect(headers[:sdk]).to eq(Sentry.sdk_meta) end