Skip to content

fix(nextjs): Do not sample next spans if they have remote parent #11680

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

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/opentelemetry/src/sampler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export class SentrySampler implements Sampler {
// If we encounter a span emitted by Next.js, we do not want to sample it
// The reason for this is that the data quality of the spans varies, it is different per version of Next,
// and we need to keep our manual instrumentation around for the edge runtime anyhow.
// BUT we only do this if we don't have a parent span with a sampling decision yet
if (spanAttributes['next.span_type'] && typeof parentSampled !== 'boolean') {
// BUT we only do this if we don't have a parent span with a sampling decision yet (or if the parent is remote)
if (spanAttributes['next.span_type'] && (typeof parentSampled !== 'boolean' || parentContext?.isRemote)) {
return { decision: SamplingDecision.NOT_RECORD, traceState: traceState };
}

Expand Down
Loading