Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(node): Pass inferred name & attributes to tracesSampler #12945

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented Jul 17, 2024

Previously, we passed the span name directly to the tracesSampler as-is. However, this is not ideal because this does not match the name we actually send to sentry later, making this confusing. The reason is that we infer the name from the attributes for some types of spans, but we do that at export-time.

This PR adjust this so that we send the inferred name & attributes to the tracesSampler. This works reasonably enough. However, there is a big caveat: This still only has access to the initial attributes that a span has at creation time. This means that we'll never have e.g. the http.route correctly there, because all http.server spans originate from the http instrumentation where they do not have a route yet, and then more specific instrumentation (e.g. express or fastify) add the http.route to that span later. So the name will never be parametrized, for example, for http.server spans, which is not ideal (as it will still not match the final span exactly) but should still be better than what we had so far (where the name would always just be e.g. GET).

Fixes #12944

Copy link
Contributor

github-actions bot commented Jul 17, 2024

size-limit report 📦

Path Size
@sentry/browser 22.3 KB (0%)
@sentry/browser (incl. Tracing) 33.69 KB (0%)
@sentry/browser (incl. Tracing, Replay) 69.77 KB (0%)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 63.08 KB (0%)
@sentry/browser (incl. Tracing, Replay with Canvas) 74.17 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) 86.49 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 88.36 KB (0%)
@sentry/browser (incl. metrics) 26.59 KB (0%)
@sentry/browser (incl. Feedback) 38.98 KB (0%)
@sentry/browser (incl. sendFeedback) 26.93 KB (0%)
@sentry/browser (incl. FeedbackAsync) 31.54 KB (0%)
@sentry/react 25.06 KB (0%)
@sentry/react (incl. Tracing) 36.75 KB (0%)
@sentry/vue 26.41 KB (0%)
@sentry/vue (incl. Tracing) 35.57 KB (0%)
@sentry/svelte 22.44 KB (0%)
CDN Bundle 23.52 KB (0%)
CDN Bundle (incl. Tracing) 35.47 KB (0%)
CDN Bundle (incl. Tracing, Replay) 69.87 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) 75.14 KB (0%)
CDN Bundle - uncompressed 69 KB (0%)
CDN Bundle (incl. Tracing) - uncompressed 104.93 KB (0%)
CDN Bundle (incl. Tracing, Replay) - uncompressed 216.71 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 229.43 KB (0%)
@sentry/nextjs (client) 36.61 KB (0%)
@sentry/sveltekit (client) 34.34 KB (0%)
@sentry/node 111.29 KB (+0.01% 🔺)
@sentry/node - without tracing 88.71 KB (-0.03% 🔽)
@sentry/aws-serverless 97.88 KB (+0.02% 🔺)

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Even if we can't get the final parameterized name in time, I think this is an improvement to what we had before so 👍

@@ -45,8 +45,6 @@ export function startSpan<T>(options: OpenTelemetrySpanContext, callback: (span:
const spanOptions = getSpanOptions(options);

return tracer.startActiveSpan(name, spanOptions, ctx, span => {
_applySentryAttributesToSpan(span, options);
Copy link
Member Author

Choose a reason for hiding this comment

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

I noticed that this was actually also not ideal, we just added the op attribute after the span was started, which means this was not sent to the sampler. Also, this is overall unnecessary, we can just add the attribute right away!

@mydea mydea merged commit ac6e2f1 into develop Jul 18, 2024
105 checks passed
@mydea mydea deleted the fn/sampler-name branch July 18, 2024 13:42
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.

tracesSampler "name" property missing route name with Fastify integration
2 participants