diff --git a/sentry/api/sentry.api b/sentry/api/sentry.api index e6525cee31c..09d83295ce9 100644 --- a/sentry/api/sentry.api +++ b/sentry/api/sentry.api @@ -528,9 +528,11 @@ public final class io/sentry/Hub : io/sentry/IHub, io/sentry/metrics/MetricsApi$ public fun endSession ()V public fun flush (J)V public fun forkedCurrentScope (Ljava/lang/String;)Lio/sentry/IScopes; + public fun forkedRootScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun forkedScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun getBaggage ()Lio/sentry/BaggageHeader; public fun getDefaultTagsForMetrics ()Ljava/util/Map; + public fun getGlobalScope ()Lio/sentry/IScope; public fun getIsolationScope ()Lio/sentry/IScope; public fun getLastEventId ()Lio/sentry/protocol/SentryId; public fun getLocalMetricsAggregator ()Lio/sentry/metrics/LocalMetricsAggregator; @@ -590,8 +592,10 @@ public final class io/sentry/HubAdapter : io/sentry/IHub { public fun endSession ()V public fun flush (J)V public fun forkedCurrentScope (Ljava/lang/String;)Lio/sentry/IScopes; + public fun forkedRootScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun forkedScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun getBaggage ()Lio/sentry/BaggageHeader; + public fun getGlobalScope ()Lio/sentry/IScope; public static fun getInstance ()Lio/sentry/HubAdapter; public fun getIsolationScope ()Lio/sentry/IScope; public fun getLastEventId ()Lio/sentry/protocol/SentryId; @@ -650,8 +654,10 @@ public final class io/sentry/HubScopesWrapper : io/sentry/IHub { public fun endSession ()V public fun flush (J)V public fun forkedCurrentScope (Ljava/lang/String;)Lio/sentry/IScopes; + public fun forkedRootScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun forkedScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun getBaggage ()Lio/sentry/BaggageHeader; + public fun getGlobalScope ()Lio/sentry/IScope; public fun getIsolationScope ()Lio/sentry/IScope; public fun getLastEventId ()Lio/sentry/protocol/SentryId; public fun getOptions ()Lio/sentry/SentryOptions; @@ -874,8 +880,10 @@ public abstract interface class io/sentry/IScopes { public abstract fun endSession ()V public abstract fun flush (J)V public abstract fun forkedCurrentScope (Ljava/lang/String;)Lio/sentry/IScopes; + public abstract fun forkedRootScopes (Ljava/lang/String;)Lio/sentry/IScopes; public abstract fun forkedScopes (Ljava/lang/String;)Lio/sentry/IScopes; public abstract fun getBaggage ()Lio/sentry/BaggageHeader; + public abstract fun getGlobalScope ()Lio/sentry/IScope; public abstract fun getIsolationScope ()Lio/sentry/IScope; public abstract fun getLastEventId ()Lio/sentry/protocol/SentryId; public abstract fun getOptions ()Lio/sentry/SentryOptions; @@ -1369,8 +1377,10 @@ public final class io/sentry/NoOpHub : io/sentry/IHub { public fun endSession ()V public fun flush (J)V public fun forkedCurrentScope (Ljava/lang/String;)Lio/sentry/IScopes; + public fun forkedRootScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun forkedScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun getBaggage ()Lio/sentry/BaggageHeader; + public fun getGlobalScope ()Lio/sentry/IScope; public static fun getInstance ()Lio/sentry/NoOpHub; public fun getIsolationScope ()Lio/sentry/IScope; public fun getLastEventId ()Lio/sentry/protocol/SentryId; @@ -1500,8 +1510,10 @@ public final class io/sentry/NoOpScopes : io/sentry/IScopes { public fun endSession ()V public fun flush (J)V public fun forkedCurrentScope (Ljava/lang/String;)Lio/sentry/IScopes; + public fun forkedRootScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun forkedScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun getBaggage ()Lio/sentry/BaggageHeader; + public fun getGlobalScope ()Lio/sentry/IScope; public static fun getInstance ()Lio/sentry/NoOpScopes; public fun getIsolationScope ()Lio/sentry/IScope; public fun getLastEventId ()Lio/sentry/protocol/SentryId; @@ -1980,6 +1992,7 @@ public final class io/sentry/Scopes : io/sentry/IScopes, io/sentry/metrics/Metri public fun endSession ()V public fun flush (J)V public fun forkedCurrentScope (Ljava/lang/String;)Lio/sentry/IScopes; + public fun forkedRootScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun forkedScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun getBaggage ()Lio/sentry/BaggageHeader; public fun getCreator ()Ljava/lang/String; @@ -2046,8 +2059,10 @@ public final class io/sentry/ScopesAdapter : io/sentry/IScopes { public fun endSession ()V public fun flush (J)V public fun forkedCurrentScope (Ljava/lang/String;)Lio/sentry/IScopes; + public fun forkedRootScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun forkedScopes (Ljava/lang/String;)Lio/sentry/IScopes; public fun getBaggage ()Lio/sentry/BaggageHeader; + public fun getGlobalScope ()Lio/sentry/IScope; public static fun getInstance ()Lio/sentry/ScopesAdapter; public fun getIsolationScope ()Lio/sentry/IScope; public fun getLastEventId ()Lio/sentry/protocol/SentryId; diff --git a/sentry/src/main/java/io/sentry/Hub.java b/sentry/src/main/java/io/sentry/Hub.java index 35740f4c3e1..bcb93c75587 100644 --- a/sentry/src/main/java/io/sentry/Hub.java +++ b/sentry/src/main/java/io/sentry/Hub.java @@ -668,6 +668,11 @@ public void flush(long timeoutMillis) { return Sentry.forkedCurrentScope(creator); } + @Override + public @NotNull IScopes forkedRootScopes(final @NotNull String creator) { + return Sentry.forkedRootScopes(creator); + } + @Override public @NotNull ISentryLifecycleToken makeCurrent() { return NoOpScopesStorage.NoOpScopesLifecycleToken.getInstance(); @@ -683,6 +688,11 @@ public void flush(long timeoutMillis) { return Sentry.getCurrentScopes().getIsolationScope(); } + @Override + public @NotNull IScope getGlobalScope() { + return Sentry.getGlobalScope(); + } + @ApiStatus.Internal @Override public @NotNull SentryId captureTransaction( diff --git a/sentry/src/main/java/io/sentry/HubAdapter.java b/sentry/src/main/java/io/sentry/HubAdapter.java index 8e6966aac5a..df1a7aa6611 100644 --- a/sentry/src/main/java/io/sentry/HubAdapter.java +++ b/sentry/src/main/java/io/sentry/HubAdapter.java @@ -208,6 +208,11 @@ public void flush(long timeoutMillis) { return Sentry.forkedCurrentScope(creator); } + @Override + public @NotNull IScopes forkedRootScopes(final @NotNull String creator) { + return Sentry.forkedRootScopes(creator); + } + @Override public @NotNull ISentryLifecycleToken makeCurrent() { // TODO [HSM] this wouldn't do anything since it replaced the current with the same Scopes @@ -224,6 +229,11 @@ public void flush(long timeoutMillis) { return Sentry.getCurrentScopes().getIsolationScope(); } + @Override + public @NotNull IScope getGlobalScope() { + return Sentry.getGlobalScope(); + } + @Override public @NotNull SentryId captureTransaction( @NotNull SentryTransaction transaction, diff --git a/sentry/src/main/java/io/sentry/HubScopesWrapper.java b/sentry/src/main/java/io/sentry/HubScopesWrapper.java index 3309e596716..2a50d8ca48d 100644 --- a/sentry/src/main/java/io/sentry/HubScopesWrapper.java +++ b/sentry/src/main/java/io/sentry/HubScopesWrapper.java @@ -203,6 +203,11 @@ public void flush(long timeoutMillis) { return scopes.forkedCurrentScope(creator); } + @Override + public @NotNull IScopes forkedRootScopes(final @NotNull String creator) { + return Sentry.forkedRootScopes(creator); + } + @Override public @NotNull ISentryLifecycleToken makeCurrent() { return scopes.makeCurrent(); @@ -218,6 +223,11 @@ public void flush(long timeoutMillis) { return scopes.getIsolationScope(); } + @Override + public @NotNull IScope getGlobalScope() { + return Sentry.getGlobalScope(); + } + @ApiStatus.Internal @Override public @NotNull SentryId captureTransaction( diff --git a/sentry/src/main/java/io/sentry/IScopes.java b/sentry/src/main/java/io/sentry/IScopes.java index af6f41ae13c..6eb82cca328 100644 --- a/sentry/src/main/java/io/sentry/IScopes.java +++ b/sentry/src/main/java/io/sentry/IScopes.java @@ -375,7 +375,7 @@ default void configureScope(@NotNull ScopeCallback callback) { IHub clone(); /** - * Creates a fork of both current and isolation scope. + * Creates a fork of both current and isolation scope from current scopes. * * @param creator debug information to see why scopes where forked * @return forked Scopes @@ -392,6 +392,15 @@ default void configureScope(@NotNull ScopeCallback callback) { @NotNull IScopes forkedCurrentScope(final @NotNull String creator); + /** + * Creates a fork of both current and isolation scope from root scopes. + * + * @param creator debug information to see why scopes where forked + * @return forked Scopes + */ + @NotNull + IScopes forkedRootScopes(final @NotNull String creator); + /** * Stores this Scopes in store, making it the current one that is used by static API. * @@ -414,6 +423,13 @@ default void configureScope(@NotNull ScopeCallback callback) { */ public @NotNull IScope getIsolationScope(); + /** + * Returns the global scope. + * + * @return global scope + */ + public @NotNull IScope getGlobalScope(); + /** * Captures the transaction and enqueues it for sending to Sentry server. * diff --git a/sentry/src/main/java/io/sentry/NoOpHub.java b/sentry/src/main/java/io/sentry/NoOpHub.java index ac1c542a940..06969518b7e 100644 --- a/sentry/src/main/java/io/sentry/NoOpHub.java +++ b/sentry/src/main/java/io/sentry/NoOpHub.java @@ -185,6 +185,16 @@ public void flush(long timeoutMillis) {} return NoOpScope.getInstance(); } + @Override + public @NotNull IScope getGlobalScope() { + return NoOpScope.getInstance(); + } + + @Override + public @NotNull IScopes forkedRootScopes(final @NotNull String creator) { + return NoOpScopes.getInstance(); + } + @Override public @NotNull SentryId captureTransaction( final @NotNull SentryTransaction transaction, diff --git a/sentry/src/main/java/io/sentry/NoOpScopes.java b/sentry/src/main/java/io/sentry/NoOpScopes.java index de75ff8178d..74f965f6518 100644 --- a/sentry/src/main/java/io/sentry/NoOpScopes.java +++ b/sentry/src/main/java/io/sentry/NoOpScopes.java @@ -169,6 +169,11 @@ public void flush(long timeoutMillis) {} return NoOpScopes.getInstance(); } + @Override + public @NotNull IScopes forkedRootScopes(final @NotNull String creator) { + return NoOpScopes.getInstance(); + } + @Override public @NotNull ISentryLifecycleToken makeCurrent() { return NoOpScopesStorage.NoOpScopesLifecycleToken.getInstance(); @@ -184,6 +189,11 @@ public void flush(long timeoutMillis) {} return NoOpScope.getInstance(); } + @Override + public @NotNull IScope getGlobalScope() { + return NoOpScope.getInstance(); + } + @Override public @NotNull SentryId captureTransaction( final @NotNull SentryTransaction transaction, diff --git a/sentry/src/main/java/io/sentry/Scopes.java b/sentry/src/main/java/io/sentry/Scopes.java index d30a9b6074e..bb83e5060c6 100644 --- a/sentry/src/main/java/io/sentry/Scopes.java +++ b/sentry/src/main/java/io/sentry/Scopes.java @@ -115,6 +115,11 @@ public boolean isAncestorOf(final @Nullable Scopes otherScopes) { return new Scopes(scope.clone(), isolationScope, this, options, creator); } + @Override + public @NotNull IScopes forkedRootScopes(final @NotNull String creator) { + return Sentry.forkedRootScopes(creator); + } + // TODO [HSM] always read from root scope? @Override public boolean isEnabled() { @@ -582,7 +587,7 @@ private void updateLastEventId(final @NotNull SentryId lastEventId) { getCombinedScopeView().setLastEventId(lastEventId); } - // TODO [HSM] add to IScopes interface + @Override public @NotNull IScope getGlobalScope() { return Sentry.getGlobalScope(); } diff --git a/sentry/src/main/java/io/sentry/ScopesAdapter.java b/sentry/src/main/java/io/sentry/ScopesAdapter.java index 684ab121137..c7f11612e93 100644 --- a/sentry/src/main/java/io/sentry/ScopesAdapter.java +++ b/sentry/src/main/java/io/sentry/ScopesAdapter.java @@ -205,6 +205,11 @@ public void flush(long timeoutMillis) { return Sentry.forkedCurrentScope(creator); } + @Override + public @NotNull IScopes forkedRootScopes(final @NotNull String creator) { + return Sentry.forkedRootScopes(creator); + } + @Override public @NotNull ISentryLifecycleToken makeCurrent() { // TODO [HSM] this wouldn't do anything since it replaced the current with the same Scopes @@ -221,6 +226,11 @@ public void flush(long timeoutMillis) { return Sentry.getCurrentScopes().getIsolationScope(); } + @Override + public @NotNull IScope getGlobalScope() { + return Sentry.getGlobalScope(); + } + @ApiStatus.Internal @Override public @NotNull SentryId captureTransaction( diff --git a/sentry/src/main/java/io/sentry/Sentry.java b/sentry/src/main/java/io/sentry/Sentry.java index bd1fcee04bc..fe5c8b41129 100644 --- a/sentry/src/main/java/io/sentry/Sentry.java +++ b/sentry/src/main/java/io/sentry/Sentry.java @@ -102,8 +102,6 @@ private Sentry() {} * @return the hub */ @ApiStatus.Internal - @ApiStatus.Experimental - @SuppressWarnings("deprecation") public static @NotNull IScopes forkedRootScopes(final @NotNull String creator) { if (globalHubMode) { return rootScopes;