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 19 - Add pushIsolationScope and fork methods #3343

Merged
merged 24 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 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
24ab503
Merge branch '8.x.x' into feat/hsm-19-push-isolation-scope-fork
adinauer Apr 19, 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
53 changes: 0 additions & 53 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -580,59 +580,6 @@ public final class io/sentry/HubScopesWrapper : io/sentry/IHub {
public fun withScope (Lio/sentry/ScopeCallback;)V
}

public final class io/sentry/HubScopesWrapper : io/sentry/IHub {
public fun <init> (Lio/sentry/IScopes;)V
public fun addBreadcrumb (Lio/sentry/Breadcrumb;)V
public fun addBreadcrumb (Lio/sentry/Breadcrumb;Lio/sentry/Hint;)V
public fun bindClient (Lio/sentry/ISentryClient;)V
public fun captureCheckIn (Lio/sentry/CheckIn;)Lio/sentry/protocol/SentryId;
public fun captureEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
public fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
public fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId;
public fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId;
public fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId;
public fun captureTransaction (Lio/sentry/protocol/SentryTransaction;Lio/sentry/TraceContext;Lio/sentry/Hint;Lio/sentry/ProfilingTraceData;)Lio/sentry/protocol/SentryId;
public fun captureUserFeedback (Lio/sentry/UserFeedback;)V
public fun clearBreadcrumbs ()V
public fun clone ()Lio/sentry/IHub;
public synthetic fun clone ()Ljava/lang/Object;
public fun close ()V
public fun close (Z)V
public fun configureScope (Lio/sentry/ScopeCallback;)V
public fun continueTrace (Ljava/lang/String;Ljava/util/List;)Lio/sentry/TransactionContext;
public fun endSession ()V
public fun flush (J)V
public fun getBaggage ()Lio/sentry/BaggageHeader;
public fun getLastEventId ()Lio/sentry/protocol/SentryId;
public fun getOptions ()Lio/sentry/SentryOptions;
public fun getRateLimiter ()Lio/sentry/transport/RateLimiter;
public fun getSpan ()Lio/sentry/ISpan;
public fun getTraceparent ()Lio/sentry/SentryTraceHeader;
public fun getTransaction ()Lio/sentry/ITransaction;
public fun isCrashedLastRun ()Ljava/lang/Boolean;
public fun isEnabled ()Z
public fun isHealthy ()Z
public fun metrics ()Lio/sentry/metrics/MetricsApi;
public fun popScope ()V
public fun pushScope ()V
public fun removeExtra (Ljava/lang/String;)V
public fun removeTag (Ljava/lang/String;)V
public fun reportFullyDisplayed ()V
public fun setExtra (Ljava/lang/String;Ljava/lang/String;)V
public fun setFingerprint (Ljava/util/List;)V
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 setTransaction (Ljava/lang/String;)V
public fun setUser (Lio/sentry/protocol/User;)V
public fun startSession ()V
public fun startTransaction (Lio/sentry/TransactionContext;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction;
public fun traceHeaders ()Lio/sentry/SentryTraceHeader;
public fun withScope (Lio/sentry/ScopeCallback;)V
}

public abstract interface class io/sentry/IConnectionStatusProvider {
public abstract fun addConnectionStatusObserver (Lio/sentry/IConnectionStatusProvider$IConnectionStatusObserver;)Z
public abstract fun getConnectionStatus ()Lio/sentry/IConnectionStatusProvider$ConnectionStatus;
Expand Down
30 changes: 30 additions & 0 deletions sentry/src/main/java/io/sentry/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,11 @@ public void removeExtra(final @NotNull String key) {
return NoOpScopesStorage.NoOpScopesLifecycleToken.getInstance();
}

@Override
public @NotNull ISentryLifecycleToken pushIsolationScope() {
return NoOpScopesStorage.NoOpScopesLifecycleToken.getInstance();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this also be Sentry.pushIsolationScope()? Same as in HubAdapter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hub should be removed before releasing the major IMO.

}

@Override
public @NotNull SentryOptions getOptions() {
return this.stack.peek().getOptions();
Expand Down Expand Up @@ -652,6 +657,31 @@ public void flush(long timeoutMillis) {
return new Hub(this.options, new Stack(this.stack));
}

@Override
public @NotNull IScopes forkedScopes(@NotNull String creator) {
return Sentry.forkedScopes(creator);
}

@Override
public @NotNull IScopes forkedCurrentScope(@NotNull String creator) {
return Sentry.forkedCurrentScope(creator);
}

@Override
public @NotNull ISentryLifecycleToken makeCurrent() {
return NoOpScopesStorage.NoOpScopesLifecycleToken.getInstance();
}

@Override
public @NotNull IScope getScope() {
return Sentry.getCurrentScopes().getScope();
}

@Override
public @NotNull IScope getIsolationScope() {
return Sentry.getCurrentScopes().getIsolationScope();
}

@ApiStatus.Internal
@Override
public @NotNull SentryId captureTransaction(
Expand Down
31 changes: 31 additions & 0 deletions sentry/src/main/java/io/sentry/HubAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ public void removeExtra(@NotNull String key) {
return Sentry.pushScope();
}

@Override
public @NotNull ISentryLifecycleToken pushIsolationScope() {
return Sentry.pushIsolationScope();
}

@Override
public void popScope() {
Sentry.popScope();
Expand Down Expand Up @@ -193,6 +198,32 @@ public void flush(long timeoutMillis) {
return Sentry.getCurrentScopes().clone();
}

@Override
public @NotNull IScopes forkedScopes(@NotNull String creator) {
return Sentry.forkedScopes(creator);
}

@Override
public @NotNull IScopes forkedCurrentScope(@NotNull String creator) {
return Sentry.forkedCurrentScope(creator);
}

@Override
public @NotNull ISentryLifecycleToken makeCurrent() {
// TODO this wouldn't do anything since it replaced the current with the same Scopes
return NoOpScopesStorage.NoOpScopesLifecycleToken.getInstance();
}

@Override
public @NotNull IScope getScope() {
return Sentry.getCurrentScopes().getScope();
}

@Override
public @NotNull IScope getIsolationScope() {
return Sentry.getCurrentScopes().getIsolationScope();
}

@Override
public @NotNull SentryId captureTransaction(
@NotNull SentryTransaction transaction,
Expand Down
30 changes: 30 additions & 0 deletions sentry/src/main/java/io/sentry/HubScopesWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ public void removeExtra(@NotNull String key) {
return scopes.pushScope();
}

@Override
public @NotNull ISentryLifecycleToken pushIsolationScope() {
return scopes.pushIsolationScope();
}

@Override
public void popScope() {
scopes.popScope();
Expand Down Expand Up @@ -188,6 +193,31 @@ public void flush(long timeoutMillis) {
return scopes.clone();
}

@Override
public @NotNull IScopes forkedScopes(@NotNull String creator) {
return scopes.forkedScopes(creator);
}

@Override
public @NotNull IScopes forkedCurrentScope(@NotNull String creator) {
return scopes.forkedCurrentScope(creator);
}

@Override
public @NotNull ISentryLifecycleToken makeCurrent() {
return scopes.makeCurrent();
}

@Override
public @NotNull IScope getScope() {
return scopes.getScope();
}

@Override
public @NotNull IScope getIsolationScope() {
return scopes.getIsolationScope();
}

@ApiStatus.Internal
@Override
public @NotNull SentryId captureTransaction(
Expand Down
45 changes: 45 additions & 0 deletions sentry/src/main/java/io/sentry/IScopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ default void addBreadcrumb(@NotNull String message, @NotNull String category) {
@NotNull
ISentryLifecycleToken pushScope();

@NotNull
ISentryLifecycleToken pushIsolationScope();

/** Removes the first scope */
void popScope();

Expand Down Expand Up @@ -354,12 +357,54 @@ default void addBreadcrumb(@NotNull String message, @NotNull String category) {
/**
* Clones the Hub
*
* @deprecated please use {@link IScopes#forkedScopes(String)} or {@link
* IScopes#forkedCurrentScope(String)} instead.
* @return the cloned Hub
*/
@NotNull
@Deprecated
IHub clone();

/**
* Creates a fork of both current and isolation scope.
*
* @param creator debug information to see why scopes where forked
* @return forked Scopes
*/
@NotNull
IScopes forkedScopes(final @NotNull String creator);

/**
* Creates a fork of current scope without forking isolation scope.
*
* @param creator debug information to see why scopes where forked
* @return forked Scopes
*/
@NotNull
IScopes forkedCurrentScope(final @NotNull String creator);

/**
* Stores this Scopes in store, making it the current one that is used by static API.
*
* @return a token you should call .close() on when you're done.
*/
@NotNull
ISentryLifecycleToken makeCurrent();

/**
* Returns the current scope of this Scopes.
*
* @return scope
*/
public @NotNull IScope getScope();
Copy link
Collaborator

Choose a reason for hiding this comment

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

public keyword can be removed


/**
* Returns the isolation scope of this Scopes.
*
* @return isolation scope
*/
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.

public keyword can be removed


/**
* Captures the transaction and enqueues it for sending to Sentry server.
*
Expand Down
30 changes: 30 additions & 0 deletions sentry/src/main/java/io/sentry/NoOpHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ public void removeExtra(@NotNull String key) {}
return NoOpScopesStorage.NoOpScopesLifecycleToken.getInstance();
}

@Override
public @NotNull ISentryLifecycleToken pushIsolationScope() {
return NoOpScopesStorage.NoOpScopesLifecycleToken.getInstance();
}

@Override
public void popScope() {}

Expand Down Expand Up @@ -155,6 +160,31 @@ public void flush(long timeoutMillis) {}
return instance;
}

@Override
public @NotNull IScopes forkedScopes(@NotNull String creator) {
return NoOpScopes.getInstance();
}

@Override
public @NotNull IScopes forkedCurrentScope(@NotNull String creator) {
return NoOpScopes.getInstance();
}

@Override
public @NotNull ISentryLifecycleToken makeCurrent() {
return NoOpScopesStorage.NoOpScopesLifecycleToken.getInstance();
}

@Override
public @NotNull IScope getScope() {
return NoOpScope.getInstance();
}

@Override
public @NotNull IScope getIsolationScope() {
return NoOpScope.getInstance();
}

@Override
public @NotNull SentryId captureTransaction(
final @NotNull SentryTransaction transaction,
Expand Down
30 changes: 30 additions & 0 deletions sentry/src/main/java/io/sentry/NoOpScopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ public void removeExtra(@NotNull String key) {}
return NoOpScopesStorage.NoOpScopesLifecycleToken.getInstance();
}

@Override
public @NotNull ISentryLifecycleToken pushIsolationScope() {
return NoOpScopesStorage.NoOpScopesLifecycleToken.getInstance();
}

@Override
public void popScope() {}

Expand Down Expand Up @@ -154,6 +159,31 @@ public void flush(long timeoutMillis) {}
return NoOpHub.getInstance();
}

@Override
public @NotNull IScopes forkedScopes(@NotNull String creator) {
return NoOpScopes.getInstance();
}

@Override
public @NotNull IScopes forkedCurrentScope(@NotNull String creator) {
return NoOpScopes.getInstance();
}

@Override
public @NotNull ISentryLifecycleToken makeCurrent() {
return NoOpScopesStorage.NoOpScopesLifecycleToken.getInstance();
}

@Override
public @NotNull IScope getScope() {
return NoOpScope.getInstance();
}

@Override
public @NotNull IScope getIsolationScope() {
return NoOpScope.getInstance();
}

@Override
public @NotNull SentryId captureTransaction(
final @NotNull SentryTransaction transaction,
Expand Down
Loading
Loading