Skip to content

Commit

Permalink
reviewref
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsandfoxes committed Feb 27, 2025
1 parent 2243841 commit d9d43ee
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.sentry.IScopes;
import io.sentry.ISerializer;
import io.sentry.ObjectWriter;
import io.sentry.PropagationContext;
import io.sentry.ScopeType;
import io.sentry.ScopesAdapter;
import io.sentry.SentryEnvelope;
Expand All @@ -31,6 +32,7 @@
import io.sentry.protocol.SentryId;
import io.sentry.protocol.User;
import io.sentry.util.MapObjectWriter;
import io.sentry.util.TracingUtils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
Expand Down Expand Up @@ -344,6 +346,8 @@ public static void setTrace(
final @NotNull String spanId,
final @Nullable Double sampleRate,
final @Nullable Double sampleRand) {
getCurrentScopes().setTrace(traceId, spanId, sampleRate, sampleRand);
TracingUtils.setTrace(
getCurrentScopes(),
PropagationContext.fromExistingTrace(traceId, spanId, sampleRate, sampleRand));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import io.sentry.SentryExceptionFactory
import io.sentry.SentryItemType
import io.sentry.SentryOptions
import io.sentry.Session
import io.sentry.SpanId
import io.sentry.android.core.performance.ActivityLifecycleTimeSpan
import io.sentry.android.core.performance.AppStartMetrics
import io.sentry.exception.ExceptionMechanismException
Expand Down
8 changes: 1 addition & 7 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,6 @@ public final class io/sentry/HubAdapter : io/sentry/IHub {
public fun setLevel (Lio/sentry/SentryLevel;)V
public fun setSpanContext (Ljava/lang/Throwable;Lio/sentry/ISpan;Ljava/lang/String;)V
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setTrace (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Double;Ljava/lang/Double;)V
public fun setTransaction (Ljava/lang/String;)V
public fun setUser (Lio/sentry/protocol/User;)V
public fun startSession ()V
Expand Down Expand Up @@ -690,7 +689,6 @@ public final class io/sentry/HubScopesWrapper : io/sentry/IHub {
public fun setLevel (Lio/sentry/SentryLevel;)V
public fun setSpanContext (Ljava/lang/Throwable;Lio/sentry/ISpan;Ljava/lang/String;)V
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setTrace (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Double;Ljava/lang/Double;)V
public fun setTransaction (Ljava/lang/String;)V
public fun setUser (Lio/sentry/protocol/User;)V
public fun startSession ()V
Expand Down Expand Up @@ -918,7 +916,6 @@ public abstract interface class io/sentry/IScopes {
public abstract fun setLevel (Lio/sentry/SentryLevel;)V
public abstract fun setSpanContext (Ljava/lang/Throwable;Lio/sentry/ISpan;Ljava/lang/String;)V
public abstract fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public abstract fun setTrace (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Double;Ljava/lang/Double;)V
public abstract fun setTransaction (Ljava/lang/String;)V
public abstract fun setUser (Lio/sentry/protocol/User;)V
public abstract fun startSession ()V
Expand Down Expand Up @@ -1441,7 +1438,6 @@ public final class io/sentry/NoOpHub : io/sentry/IHub {
public fun setLevel (Lio/sentry/SentryLevel;)V
public fun setSpanContext (Ljava/lang/Throwable;Lio/sentry/ISpan;Ljava/lang/String;)V
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setTrace (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Double;Ljava/lang/Double;)V
public fun setTransaction (Ljava/lang/String;)V
public fun setUser (Lio/sentry/protocol/User;)V
public fun startSession ()V
Expand Down Expand Up @@ -1601,7 +1597,6 @@ public final class io/sentry/NoOpScopes : io/sentry/IScopes {
public fun setLevel (Lio/sentry/SentryLevel;)V
public fun setSpanContext (Ljava/lang/Throwable;Lio/sentry/ISpan;Ljava/lang/String;)V
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setTrace (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Double;Ljava/lang/Double;)V
public fun setTransaction (Ljava/lang/String;)V
public fun setUser (Lio/sentry/protocol/User;)V
public fun startSession ()V
Expand Down Expand Up @@ -2203,7 +2198,6 @@ public final class io/sentry/Scopes : io/sentry/IScopes {
public fun setLevel (Lio/sentry/SentryLevel;)V
public fun setSpanContext (Ljava/lang/Throwable;Lio/sentry/ISpan;Ljava/lang/String;)V
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setTrace (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Double;Ljava/lang/Double;)V
public fun setTransaction (Ljava/lang/String;)V
public fun setUser (Lio/sentry/protocol/User;)V
public fun startSession ()V
Expand Down Expand Up @@ -2268,7 +2262,6 @@ public final class io/sentry/ScopesAdapter : io/sentry/IScopes {
public fun setLevel (Lio/sentry/SentryLevel;)V
public fun setSpanContext (Ljava/lang/Throwable;Lio/sentry/ISpan;Ljava/lang/String;)V
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setTrace (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Double;Ljava/lang/Double;)V
public fun setTransaction (Ljava/lang/String;)V
public fun setUser (Lio/sentry/protocol/User;)V
public fun startSession ()V
Expand Down Expand Up @@ -6368,6 +6361,7 @@ public final class io/sentry/util/TracingUtils {
public static fun ensureBaggage (Lio/sentry/Baggage;Ljava/lang/Boolean;Ljava/lang/Double;Ljava/lang/Double;)Lio/sentry/Baggage;
public static fun isIgnored (Ljava/util/List;Ljava/lang/String;)Z
public static fun maybeUpdateBaggage (Lio/sentry/IScope;Lio/sentry/SentryOptions;)Lio/sentry/PropagationContext;
public static fun setTrace (Lio/sentry/IScopes;Lio/sentry/PropagationContext;)V
public static fun startNewTrace (Lio/sentry/IScopes;)V
public static fun trace (Lio/sentry/IScopes;Ljava/util/List;Lio/sentry/ISpan;)Lio/sentry/util/TracingUtils$TracingHeaders;
public static fun traceIfAllowed (Lio/sentry/IScopes;Ljava/lang/String;Ljava/util/List;Lio/sentry/ISpan;)Lio/sentry/util/TracingUtils$TracingHeaders;
Expand Down
9 changes: 0 additions & 9 deletions sentry/src/main/java/io/sentry/HubAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,6 @@ public void reportFullyDisplayed() {
return Sentry.continueTrace(sentryTrace, baggageHeaders);
}

@Override
public void setTrace(
final @NotNull String traceId,
final @NotNull String spanId,
final @Nullable Double sampleRate,
final @Nullable Double sampleRand) {
Sentry.getCurrentScopes().setTrace(traceId, spanId, sampleRate, sampleRand);
}

@Override
public @Nullable SentryTraceHeader getTraceparent() {
return Sentry.getTraceparent();
Expand Down
9 changes: 0 additions & 9 deletions sentry/src/main/java/io/sentry/HubScopesWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,6 @@ public void reportFullyDisplayed() {
return scopes.continueTrace(sentryTrace, baggageHeaders);
}

@Override
public void setTrace(
final @NotNull String traceId,
final @NotNull String spanId,
final @Nullable Double sampleRate,
final @Nullable Double sampleRand) {
Sentry.getCurrentScopes().setTrace(traceId, spanId, sampleRate, sampleRand);
}

@Override
public @Nullable SentryTraceHeader getTraceparent() {
return scopes.getTraceparent();
Expand Down
14 changes: 0 additions & 14 deletions sentry/src/main/java/io/sentry/IScopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -657,20 +657,6 @@ void setSpanContext(
TransactionContext continueTrace(
final @Nullable String sentryTrace, final @Nullable List<String> baggageHeaders);

/**
* Set a trace. This is primarily used by other SDKs in a Hybrid SDK context
*
* @param traceId the trace ID
* @param spanId the trace origin's span ID
* @param sampleRate the sample rate used by the origin of the trace
* @param sampleRand the random value used to sample with by the origin of the trace
*/
void setTrace(
final @NotNull String traceId,
final @NotNull String spanId,
final @Nullable Double sampleRate,
final @Nullable Double sampleRand);

/**
* Returns the "sentry-trace" header that allows tracing across services. Can also be used in
* &lt;meta&gt; HTML tags. Also see {@link IScopes#getBaggage()}.
Expand Down
7 changes: 0 additions & 7 deletions sentry/src/main/java/io/sentry/NoOpHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,6 @@ public void reportFullyDisplayed() {}
return null;
}

@Override
public void setTrace(
final @NotNull String traceId,
final @NotNull String spanId,
final @Nullable Double sampleRate,
final @Nullable Double sampleRand) {}

@Override
public @Nullable SentryTraceHeader getTraceparent() {
return null;
Expand Down
7 changes: 0 additions & 7 deletions sentry/src/main/java/io/sentry/NoOpScopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,6 @@ public void reportFullyDisplayed() {}
return null;
}

@Override
public void setTrace(
final @NotNull String traceId,
final @NotNull String spanId,
final @Nullable Double sampleRate,
final @Nullable Double sampleRand) {}

@Override
public @Nullable SentryTraceHeader getTraceparent() {
return null;
Expand Down
15 changes: 0 additions & 15 deletions sentry/src/main/java/io/sentry/Scopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -989,21 +989,6 @@ public void reportFullyDisplayed() {
}
}

@Override
public void setTrace(
final @NotNull String traceId,
final @NotNull String spanId,
final @Nullable Double sampleRate,
final @Nullable Double sampleRand) {
@NotNull
PropagationContext propagationContext =
PropagationContext.fromExistingTrace(traceId, spanId, sampleRate, sampleRand);
configureScope(
(scope) -> {
scope.setPropagationContext(propagationContext);
});
}

@Override
public @Nullable SentryTraceHeader getTraceparent() {
if (!isEnabled()) {
Expand Down
9 changes: 0 additions & 9 deletions sentry/src/main/java/io/sentry/ScopesAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,6 @@ public void reportFullyDisplayed() {
return Sentry.continueTrace(sentryTrace, baggageHeaders);
}

@Override
public void setTrace(
final @NotNull String traceId,
final @NotNull String spanId,
final @Nullable Double sampleRate,
final @Nullable Double sampleRand) {
Sentry.getCurrentScopes().setTrace(traceId, spanId, sampleRate, sampleRand);
}

@Override
public @Nullable SentryTraceHeader getTraceparent() {
return Sentry.getTraceparent();
Expand Down
11 changes: 11 additions & 0 deletions sentry/src/main/java/io/sentry/util/TracingUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ public static void startNewTrace(final @NotNull IScopes scopes) {
});
}

public static void setTrace(
final @NotNull IScopes scopes, final @NotNull PropagationContext propagationContext) {
scopes.configureScope(
scope -> {
scope.withPropagationContext(
oldPropagationContext -> {
scope.setPropagationContext(propagationContext);
});
});
}

public static @Nullable TracingHeaders traceIfAllowed(
final @NotNull IScopes scopes,
final @NotNull String requestUrl,
Expand Down

0 comments on commit d9d43ee

Please sign in to comment.