Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hubs/Scopes Merge 30 - Add getGlobalScope and forkedRootScopes to IScopes #3359

Merged
merged 36 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
305baf5
replace hub with scopes
adinauer Mar 27, 2024
95f5e1b
Add Scopes
adinauer Apr 2, 2024
27f2398
Introduce `IScopes` interface.
adinauer Apr 2, 2024
ce3c14f
Replace `IHub` with `IScopes` in core
adinauer Apr 2, 2024
ce615f4
Replace `IHub` with `IScopes` in android core
adinauer Apr 2, 2024
22ddc00
Replace `IHub` with `IScopes` in android integrations
adinauer Apr 2, 2024
305c217
Replace `IHub` with `IScopes` in apollo integrations
adinauer Apr 2, 2024
da927bc
Replace `IHub` with `IScopes` in okhttp integration
adinauer Apr 2, 2024
8279276
Replace `IHub` with `IScopes` in graphql integration
adinauer Apr 2, 2024
9bfc086
Replace `IHub` with `IScopes` in logging integrations
adinauer Apr 2, 2024
b998e50
Replace `IHub` with `IScopes` in more integrations
adinauer Apr 2, 2024
739827a
Replace `IHub` with `IScopes` in OTel integration
adinauer Apr 2, 2024
69f2d63
Replace `IHub` with `IScopes` in Spring 5 / Spring Boot 2 integrations
adinauer Apr 2, 2024
792d482
Replace `IHub` with `IScopes` in Spring 6 / Spring Boot 3 integrations
adinauer Apr 2, 2024
9bcbce6
Replace `IHub` with `IScopes` in samples
adinauer Apr 2, 2024
3f25a4b
Merge branch 'feat/hsm-13-replacements-in-samples' into feat/hubs-sco…
adinauer Apr 2, 2024
d6fb40a
gitscopes -> github
adinauer Apr 2, 2024
7752bcc
Replace ThreadLocal with ScopesStorage
adinauer Apr 4, 2024
1e329c5
Move client and throwable to span map to scope
adinauer Apr 4, 2024
b0d89ae
Add global scope
adinauer Apr 4, 2024
cdd414a
use global scope in Scopes
adinauer Apr 4, 2024
98da9ff
Implement pushScope popScope and withScope for Scopes
adinauer Apr 4, 2024
2d26033
Add pushIsolationScope; add fork methods to ISCope
adinauer Apr 12, 2024
bbb6700
Use separate scopes for current, isolation and global scope; rename m…
adinauer Apr 12, 2024
c714b21
Allow controlling which scope configureScope uses
adinauer Apr 12, 2024
a474402
Combine scopes
adinauer Apr 12, 2024
ae93e33
Use new API for CRONS integrations
adinauer Apr 12, 2024
b01298b
Add lifecycle helper
adinauer Apr 12, 2024
b64e688
Change spring integrations to use new API
adinauer Apr 12, 2024
d06fc50
Use new API in servlet integrations
adinauer Apr 12, 2024
f0af5c3
Use new API for kotlin coroutines and wrapers for Supplier/Callable
adinauer Apr 12, 2024
2f02001
Discussion TODOs
adinauer Apr 12, 2024
bf4a7bf
Fix breadcrumb ordering
adinauer Apr 15, 2024
62cb91a
Mark TODOS with [HSM]
adinauer Apr 15, 2024
b1630ea
Add getGlobalScope and forkedRootScopes to IScopes
adinauer Apr 16, 2024
c3d5466
Merge branch '8.x.x' into feat/hsm-30-get-global-scope-forked-root-sc…
adinauer Apr 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions sentry/src/main/java/io/sentry/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions sentry/src/main/java/io/sentry/HubAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions sentry/src/main/java/io/sentry/HubScopesWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(
Expand Down
18 changes: 17 additions & 1 deletion sentry/src/main/java/io/sentry/IScopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
*
Expand All @@ -414,6 +423,13 @@ default void configureScope(@NotNull ScopeCallback callback) {
*/
public @NotNull IScope getIsolationScope();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not need to be public in interface.
Still in discussion if we actually need it and whether to mark it as @ApiStatus.Internal


/**
* Returns the global scope.
*
* @return global scope
*/
public @NotNull IScope getGlobalScope();

/**
* Captures the transaction and enqueues it for sending to Sentry server.
*
Expand Down
10 changes: 10 additions & 0 deletions sentry/src/main/java/io/sentry/NoOpHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions sentry/src/main/java/io/sentry/NoOpScopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion sentry/src/main/java/io/sentry/Scopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
}
Expand Down
10 changes: 10 additions & 0 deletions sentry/src/main/java/io/sentry/ScopesAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
2 changes: 0 additions & 2 deletions sentry/src/main/java/io/sentry/Sentry.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading