Skip to content

Commit 5c9fb87

Browse files
authored
POTEL 14 - Keep Sentry span op and OTel span name in sync (#3468)
* 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 * Use transaction name * remove obsolete comment * Keep OTel and Sentry span name/op in sync
1 parent 94ba63c commit 5c9fb87

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

sentry-opentelemetry/sentry-opentelemetry-bootstrap/api/sentry-opentelemetry-bootstrap.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ public final class io/sentry/opentelemetry/OtelContextScopesStorage : io/sentry/
1919

2020
public final class io/sentry/opentelemetry/OtelSpanContext : io/sentry/SpanContext {
2121
public fun <init> (Lio/opentelemetry/sdk/trace/ReadWriteSpan;Lio/sentry/TracesSamplingDecision;Lio/sentry/opentelemetry/OtelSpanWrapper;Lio/sentry/Baggage;)V
22+
public fun getOperation ()Ljava/lang/String;
2223
public fun getStatus ()Lio/sentry/SpanStatus;
24+
public fun setOperation (Ljava/lang/String;)V
2325
public fun setStatus (Lio/sentry/SpanStatus;)V
2426
}
2527

sentry-opentelemetry/sentry-opentelemetry-bootstrap/src/main/java/io/sentry/opentelemetry/OtelSpanContext.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ public void setStatus(@Nullable SpanStatus status) {
7575
}
7676
}
7777

78+
@Override
79+
public @NotNull String getOperation() {
80+
final @Nullable ReadWriteSpan otelSpan = span.get();
81+
if (otelSpan != null) {
82+
return otelSpan.getName();
83+
}
84+
return "<unlabeled span>";
85+
}
86+
87+
@Override
88+
public void setOperation(@NotNull String operation) {
89+
final @Nullable ReadWriteSpan otelSpan = span.get();
90+
if (otelSpan != null) {
91+
otelSpan.updateName(operation);
92+
}
93+
}
94+
7895
private @Nullable SpanStatus otelStatusCodeFallback(final @NotNull StatusData otelStatus) {
7996
if (otelStatus.getStatusCode() == StatusCode.ERROR) {
8097
return SpanStatus.UNKNOWN_ERROR;

0 commit comments

Comments
 (0)