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

Why baggage header override parent sampling decision #2308

Closed
DanielLiu1123 opened this issue Oct 18, 2022 · 1 comment · Fixed by #2311
Closed

Why baggage header override parent sampling decision #2308

DanielLiu1123 opened this issue Oct 18, 2022 · 1 comment · Fixed by #2311
Labels
Platform: Java Type: Bug Something isn't working

Comments

@DanielLiu1123
Copy link

Description

From io.sentry.TransactionContext#fromSentryTrace()

  public static @NotNull TransactionContext fromSentryTrace(
      final @NotNull String name,
      final @NotNull TransactionNameSource transactionNameSource,
      final @NotNull String operation,
      final @NotNull SentryTraceHeader sentryTrace,
      final @Nullable Baggage baggage) {
    @Nullable Boolean parentSampled = sentryTrace.isSampled();
    TracesSamplingDecision samplingDecision =
        parentSampled == null ? null : new TracesSamplingDecision(parentSampled);

    if (baggage != null) {
      baggage.freeze();

      Double sampleRate = baggage.getSampleRateDouble();
      // Override the parent sampling decision, makes me confused.
      // So no matter what parent sampling decision is, it becomes true.
      if (sampleRate != null) {
        samplingDecision = new TracesSamplingDecision(true, sampleRate);
      } else {
        samplingDecision = new TracesSamplingDecision(true);
      }
    }

    // ...
  }
@adinauer
Copy link
Member

@DanielLiu1123 thanks for raising this. This is a bug. We'll change it so it respects an incoming sampling decision of false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Java Type: Bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants