Skip to content

Commit d8ef786

Browse files
authored
Merge 48fc6f8 into 8cf3731
2 parents 8cf3731 + 48fc6f8 commit d8ef786

File tree

1 file changed

+14
-1
lines changed
  • sentry-opentelemetry/sentry-opentelemetry-core/src/main/java/io/sentry/opentelemetry

1 file changed

+14
-1
lines changed

sentry-opentelemetry/sentry-opentelemetry-core/src/main/java/io/sentry/opentelemetry/SentrySampler.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io.opentelemetry.sdk.trace.samplers.SamplingDecision;
1212
import io.opentelemetry.sdk.trace.samplers.SamplingResult;
1313
import io.sentry.Baggage;
14+
import io.sentry.DataCategory;
1415
import io.sentry.IScopes;
1516
import io.sentry.PropagationContext;
1617
import io.sentry.SamplingContext;
@@ -19,6 +20,7 @@
1920
import io.sentry.SpanId;
2021
import io.sentry.TracesSamplingDecision;
2122
import io.sentry.TransactionContext;
23+
import io.sentry.clientreport.DiscardReason;
2224
import io.sentry.protocol.SentryId;
2325
import java.util.List;
2426
import org.jetbrains.annotations.NotNull;
@@ -94,7 +96,18 @@ public SamplingResult shouldSample(
9496
.getOptions()
9597
.getInternalTracesSampler()
9698
.sample(new SamplingContext(transactionContext, null));
97-
// TODO [POTEL] if sampling decision = false, we should record it in client report
99+
100+
if (!sentryDecision.getSampled()) {
101+
scopes
102+
.getOptions()
103+
.getClientReportRecorder()
104+
.recordLostEvent(DiscardReason.SAMPLE_RATE, DataCategory.Transaction);
105+
scopes
106+
.getOptions()
107+
.getClientReportRecorder()
108+
.recordLostEvent(DiscardReason.SAMPLE_RATE, DataCategory.Span);
109+
}
110+
98111
return new SentrySamplingResult(sentryDecision);
99112
}
100113

0 commit comments

Comments
 (0)