Skip to content

Commit dd6307a

Browse files
authored
POTEL 12 - Remove internal span attributes so they are not sent to Sentry (#3463)
* replace hub with scopes * Add Scopes * Introduce `IScopes` interface. * Replace `IHub` with `IScopes` in core * Replace `IHub` with `IScopes` in android core * Replace `IHub` with `IScopes` in android integrations * Replace `IHub` with `IScopes` in apollo integrations * Replace `IHub` with `IScopes` in okhttp integration * Replace `IHub` with `IScopes` in graphql integration * Replace `IHub` with `IScopes` in logging integrations * Replace `IHub` with `IScopes` in more integrations * Replace `IHub` with `IScopes` in OTel integration * Replace `IHub` with `IScopes` in Spring 5 / Spring Boot 2 integrations * Replace `IHub` with `IScopes` in Spring 6 / Spring Boot 3 integrations * Replace `IHub` with `IScopes` in samples * gitscopes -> github * Replace ThreadLocal with ScopesStorage * Move client and throwable to span map to scope * Add global scope * use global scope in Scopes * Implement pushScope popScope and withScope for Scopes * Add pushIsolationScope; add fork methods to ISCope * Use separate scopes for current, isolation and global scope; rename mainScopes to rootScopes * Allow controlling which scope configureScope uses * Combine scopes * Use new API for CRONS integrations * Add lifecycle helper * Change spring integrations to use new API * Use new API in servlet integrations * Use new API for kotlin coroutines and wrapers for Supplier/Callable * Discussion TODOs * Fix breadcrumb ordering * Mark TODOS with [HSM] * Add getGlobalScope and forkedRootScopes to IScopes * Fix EventProcessor ordering on scopes * Reuse code in Scopes * No longer replace global scope * Replace hub occurrences in comments, var names etc. * Implement ScopesTest * Implement CombinedScopeViewTest * Fix combined contexts * Use combined scopes for cross platform * Changes according to reviews of previous PRs * more * even more * isEnabled checks client instead of having a property on Scopes * Use SentryOptions.empty * Remove Hub * Use OpenTelemetry for Performance and Scopes propagation * Promote certain span attributes * Use OTel in Sentry API * Deduplicate SpanInfo extraction * Forward Sentry API to Sentry through OTel * Use OTel status for Sentry span API * POTel Tracing * fix root span detection (remote flag), and scope closing * Inherit OTel span IDs when sending to sentry * Fix tracing; parse incoming baggage; add baggage to outgoing * Cleanup * Move sampling logic to OTel Sampler * Remove internal span attributes so they are not sent to Sentry
1 parent e50d955 commit dd6307a

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)