Skip to content

fix(telemetry): include span attributes in breadcrumbs#7421

Merged
thomaseizinger merged 5 commits intomainfrom
chore/telemetry-only-sample-telemetry-spans
Dec 2, 2024
Merged

fix(telemetry): include span attributes in breadcrumbs#7421
thomaseizinger merged 5 commits intomainfrom
chore/telemetry-only-sample-telemetry-spans

Conversation

@thomaseizinger
Copy link
Member

@thomaseizinger thomaseizinger commented Nov 29, 2024

This is another attempt at fixing #7386. Previous PR was #7379. The difference is, this time it works! In the following screenshot, handle_input is a currently active span.

image

I had to make some patches to Sentry, most notably:

The way we configure Sentry is quite tricky:

First and foremost, we need to understand that the tracing adapter for Sentry has a span_filter configuration. When a span gets filtered out there, the rest of sentry-tracing never sees the data in that span. Thus, in order to capture variables from spans, we need to have a fairly generous span filter. In this PR, we change this span filter to include all spans except those on TRACE level.

Secondly, by default, the Sentry SDK doesn't send any spans to the backend, i.e. the sampling rate is 0. Previously, we set the sampling rate to 1.0 because the span_filter was already filtering out all non-telemetry spans. A telemetry span is a concept that we invented. It is a span that gets sampled at creation time with a probability of 1%. This is useful because creating a lot of spans is also expensive, so we don't want to do it e.g. on a per-packet basis. With just these configuration options, we now have a problem: We don't want to submit all spans to Sentry but we need the span_filter to allow all spans otherwise we can't capture the contextual fields from the span in breadcrumbs. Luckily, the Sentry SDK has another configuration option: traces_sampler.

The traces_sampler gets to compute a sampling rate for each individual span. This allows us to discard all spans from being sent to Sentry unless they are telemetry spans.

Resolves: #7386.

@vercel
Copy link

vercel bot commented Nov 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 1, 2024 10:05am

Copy link
Member

@jamilbk jamilbk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thomaseizinger thomaseizinger added this pull request to the merge queue Dec 2, 2024
Merged via the queue into main with commit 8bc1277 Dec 2, 2024
@thomaseizinger thomaseizinger deleted the chore/telemetry-only-sample-telemetry-spans branch December 2, 2024 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Capture span attributes in Sentry breadcrumbs without affecting performance too much

2 participants