Skip to content

Commit 789ae1e

Browse files
committed
Remove internal span attributes so they are not sent to Sentry
1 parent a31fc08 commit 789ae1e

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ public final class SentrySpanExporter implements SpanExporter {
5555

5656
private final @NotNull List<SpanKind> spanKindsConsideredForSentryRequests =
5757
Arrays.asList(SpanKind.CLIENT, SpanKind.INTERNAL);
58+
59+
private final @NotNull List<String> attributeKeysToRemove =
60+
Arrays.asList(
61+
InternalSemanticAttributes.IS_REMOTE_PARENT.getKey(),
62+
InternalSemanticAttributes.BAGGAGE.getKey(),
63+
InternalSemanticAttributes.BAGGAGE_MUTABLE.getKey(),
64+
InternalSemanticAttributes.SAMPLED.getKey(),
65+
InternalSemanticAttributes.SAMPLE_RATE.getKey(),
66+
InternalSemanticAttributes.PROFILE_SAMPLED.getKey(),
67+
InternalSemanticAttributes.PROFILE_SAMPLE_RATE.getKey(),
68+
InternalSemanticAttributes.PARENT_SAMPLED.getKey());
5869
private static final @NotNull Long SPAN_TIMEOUT = DateUtils.secondsToNanos(5 * 60);
5970

6071
private static final String TRACE_ORIGN = "auto.potel";
@@ -516,14 +527,21 @@ private SpanStatus mapOtelStatus(
516527
attributes.forEach(
517528
(key, value) -> {
518529
if (key != null) {
519-
mapWithStringKeys.put(key.getKey(), value);
530+
final @NotNull String stringKey = key.getKey();
531+
if (!isSentryInternalKey(stringKey)) {
532+
mapWithStringKeys.put(stringKey, value);
533+
}
520534
}
521535
});
522536
}
523537

524538
return mapWithStringKeys;
525539
}
526540

541+
private boolean isSentryInternalKey(final @NotNull String key) {
542+
return attributeKeysToRemove.contains(key);
543+
}
544+
527545
@Override
528546
public CompletableResultCode flush() {
529547
scopes.flush(10000);

0 commit comments

Comments
 (0)