-
-
Notifications
You must be signed in to change notification settings - Fork 445
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 14 - Add Scopes
to replace Hub
#3311
Changes from all commits
305baf5
95f5e1b
27f2398
ce3c14f
ce615f4
22ddc00
305c217
da927bc
8279276
9bfc086
b998e50
739827a
69f2d63
792d482
9bcbce6
3f25a4b
d6fb40a
d260706
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -661,10 +661,12 @@ public abstract interface class io/sentry/IScope { | |
public abstract fun endSession ()Lio/sentry/Session; | ||
public abstract fun getAttachments ()Ljava/util/List; | ||
public abstract fun getBreadcrumbs ()Ljava/util/Queue; | ||
public abstract fun getClient ()Lio/sentry/ISentryClient; | ||
public abstract fun getContexts ()Lio/sentry/protocol/Contexts; | ||
public abstract fun getEventProcessors ()Ljava/util/List; | ||
public abstract fun getExtras ()Ljava/util/Map; | ||
public abstract fun getFingerprint ()Ljava/util/List; | ||
public abstract fun getLastEventId ()Lio/sentry/protocol/SentryId; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking that we could track last event ID per scope. By default it should probably just return the value from global scope in the future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed in #3346 |
||
public abstract fun getLevel ()Lio/sentry/SentryLevel; | ||
public abstract fun getOptions ()Lio/sentry/SentryOptions; | ||
public abstract fun getPropagationContext ()Lio/sentry/PropagationContext; | ||
|
@@ -679,6 +681,7 @@ public abstract interface class io/sentry/IScope { | |
public abstract fun removeContexts (Ljava/lang/String;)V | ||
public abstract fun removeExtra (Ljava/lang/String;)V | ||
public abstract fun removeTag (Ljava/lang/String;)V | ||
public abstract fun setClient (Lio/sentry/ISentryClient;)V | ||
public abstract fun setContexts (Ljava/lang/String;Ljava/lang/Boolean;)V | ||
public abstract fun setContexts (Ljava/lang/String;Ljava/lang/Character;)V | ||
public abstract fun setContexts (Ljava/lang/String;Ljava/lang/Number;)V | ||
|
@@ -688,6 +691,7 @@ public abstract interface class io/sentry/IScope { | |
public abstract fun setContexts (Ljava/lang/String;[Ljava/lang/Object;)V | ||
public abstract fun setExtra (Ljava/lang/String;Ljava/lang/String;)V | ||
public abstract fun setFingerprint (Ljava/util/List;)V | ||
public abstract fun setLastEventId (Lio/sentry/protocol/SentryId;)V | ||
public abstract fun setLevel (Lio/sentry/SentryLevel;)V | ||
public abstract fun setPropagationContext (Lio/sentry/PropagationContext;)V | ||
public abstract fun setRequest (Lio/sentry/protocol/Request;)V | ||
|
@@ -1286,11 +1290,13 @@ public final class io/sentry/NoOpScope : io/sentry/IScope { | |
public fun endSession ()Lio/sentry/Session; | ||
public fun getAttachments ()Ljava/util/List; | ||
public fun getBreadcrumbs ()Ljava/util/Queue; | ||
public fun getClient ()Lio/sentry/ISentryClient; | ||
public fun getContexts ()Lio/sentry/protocol/Contexts; | ||
public fun getEventProcessors ()Ljava/util/List; | ||
public fun getExtras ()Ljava/util/Map; | ||
public fun getFingerprint ()Ljava/util/List; | ||
public static fun getInstance ()Lio/sentry/NoOpScope; | ||
public fun getLastEventId ()Lio/sentry/protocol/SentryId; | ||
public fun getLevel ()Lio/sentry/SentryLevel; | ||
public fun getOptions ()Lio/sentry/SentryOptions; | ||
public fun getPropagationContext ()Lio/sentry/PropagationContext; | ||
|
@@ -1305,6 +1311,7 @@ public final class io/sentry/NoOpScope : io/sentry/IScope { | |
public fun removeContexts (Ljava/lang/String;)V | ||
public fun removeExtra (Ljava/lang/String;)V | ||
public fun removeTag (Ljava/lang/String;)V | ||
public fun setClient (Lio/sentry/ISentryClient;)V | ||
public fun setContexts (Ljava/lang/String;Ljava/lang/Boolean;)V | ||
public fun setContexts (Ljava/lang/String;Ljava/lang/Character;)V | ||
public fun setContexts (Ljava/lang/String;Ljava/lang/Number;)V | ||
|
@@ -1314,6 +1321,7 @@ public final class io/sentry/NoOpScope : io/sentry/IScope { | |
public fun setContexts (Ljava/lang/String;[Ljava/lang/Object;)V | ||
public fun setExtra (Ljava/lang/String;Ljava/lang/String;)V | ||
public fun setFingerprint (Ljava/util/List;)V | ||
public fun setLastEventId (Lio/sentry/protocol/SentryId;)V | ||
public fun setLevel (Lio/sentry/SentryLevel;)V | ||
public fun setPropagationContext (Lio/sentry/PropagationContext;)V | ||
public fun setRequest (Lio/sentry/protocol/Request;)V | ||
|
@@ -1708,10 +1716,12 @@ public final class io/sentry/Scope : io/sentry/IScope { | |
public fun endSession ()Lio/sentry/Session; | ||
public fun getAttachments ()Ljava/util/List; | ||
public fun getBreadcrumbs ()Ljava/util/Queue; | ||
public fun getClient ()Lio/sentry/ISentryClient; | ||
public fun getContexts ()Lio/sentry/protocol/Contexts; | ||
public fun getEventProcessors ()Ljava/util/List; | ||
public fun getExtras ()Ljava/util/Map; | ||
public fun getFingerprint ()Ljava/util/List; | ||
public fun getLastEventId ()Lio/sentry/protocol/SentryId; | ||
public fun getLevel ()Lio/sentry/SentryLevel; | ||
public fun getOptions ()Lio/sentry/SentryOptions; | ||
public fun getPropagationContext ()Lio/sentry/PropagationContext; | ||
|
@@ -1726,6 +1736,7 @@ public final class io/sentry/Scope : io/sentry/IScope { | |
public fun removeContexts (Ljava/lang/String;)V | ||
public fun removeExtra (Ljava/lang/String;)V | ||
public fun removeTag (Ljava/lang/String;)V | ||
public fun setClient (Lio/sentry/ISentryClient;)V | ||
public fun setContexts (Ljava/lang/String;Ljava/lang/Boolean;)V | ||
public fun setContexts (Ljava/lang/String;Ljava/lang/Character;)V | ||
public fun setContexts (Ljava/lang/String;Ljava/lang/Number;)V | ||
|
@@ -1735,6 +1746,7 @@ public final class io/sentry/Scope : io/sentry/IScope { | |
public fun setContexts (Ljava/lang/String;[Ljava/lang/Object;)V | ||
public fun setExtra (Ljava/lang/String;Ljava/lang/String;)V | ||
public fun setFingerprint (Ljava/util/List;)V | ||
public fun setLastEventId (Lio/sentry/protocol/SentryId;)V | ||
public fun setLevel (Lio/sentry/SentryLevel;)V | ||
public fun setPropagationContext (Lio/sentry/PropagationContext;)V | ||
public fun setRequest (Lio/sentry/protocol/Request;)V | ||
|
@@ -1780,6 +1792,70 @@ public abstract class io/sentry/ScopeObserverAdapter : io/sentry/IScopeObserver | |
public fun setUser (Lio/sentry/protocol/User;)V | ||
} | ||
|
||
public final class io/sentry/Scopes : io/sentry/IScopes, io/sentry/metrics/MetricsApi$IMetricsInterface { | ||
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 forkedCurrentScope (Ljava/lang/String;)Lio/sentry/Scopes; | ||
public fun forkedScopes (Ljava/lang/String;)Lio/sentry/Scopes; | ||
public fun getBaggage ()Lio/sentry/BaggageHeader; | ||
public fun getCreator ()Ljava/lang/String; | ||
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; | ||
public fun getMetricsAggregator ()Lio/sentry/IMetricsAggregator; | ||
public fun getOptions ()Lio/sentry/SentryOptions; | ||
public fun getParent ()Lio/sentry/Scopes; | ||
public fun getRateLimiter ()Lio/sentry/transport/RateLimiter; | ||
public fun getScope ()Lio/sentry/IScope; | ||
public fun getSpan ()Lio/sentry/ISpan; | ||
public fun getTraceparent ()Lio/sentry/SentryTraceHeader; | ||
public fun getTransaction ()Lio/sentry/ITransaction; | ||
public fun isAncestorOf (Lio/sentry/Scopes;)Z | ||
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 startSpanForMetric (Ljava/lang/String;Ljava/lang/String;)Lio/sentry/ISpan; | ||
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 final class io/sentry/ScopesAdapter : io/sentry/IScopes { | ||
public fun addBreadcrumb (Lio/sentry/Breadcrumb;)V | ||
public fun addBreadcrumb (Lio/sentry/Breadcrumb;Lio/sentry/Hint;)V | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will address in a follow up PR. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import io.sentry.protocol.App; | ||
import io.sentry.protocol.Contexts; | ||
import io.sentry.protocol.Request; | ||
import io.sentry.protocol.SentryId; | ||
import io.sentry.protocol.TransactionNameSource; | ||
import io.sentry.protocol.User; | ||
import io.sentry.util.CollectionUtils; | ||
|
@@ -22,6 +23,8 @@ | |
/** Scope data to be sent with the event */ | ||
public final class Scope implements IScope { | ||
|
||
private volatile @NotNull SentryId lastEventId; | ||
|
||
/** Scope's SentryLevel */ | ||
private @Nullable SentryLevel level; | ||
|
||
|
@@ -80,6 +83,8 @@ public final class Scope implements IScope { | |
|
||
private @NotNull PropagationContext propagationContext; | ||
|
||
private @NotNull ISentryClient client = NoOpSentryClient.getInstance(); | ||
|
||
/** | ||
* Scope's ctor | ||
* | ||
|
@@ -89,6 +94,7 @@ public Scope(final @NotNull SentryOptions options) { | |
this.options = Objects.requireNonNull(options, "SentryOptions is required."); | ||
this.breadcrumbs = createBreadcrumbsList(this.options.getMaxBreadcrumbs()); | ||
this.propagationContext = new PropagationContext(); | ||
this.lastEventId = SentryId.EMPTY_ID; | ||
} | ||
|
||
private Scope(final @NotNull Scope scope) { | ||
|
@@ -97,6 +103,8 @@ private Scope(final @NotNull Scope scope) { | |
this.session = scope.session; | ||
this.options = scope.options; | ||
this.level = scope.level; | ||
// TODO should we do this? didn't do it for Hub | ||
this.lastEventId = scope.getLastEventId(); | ||
|
||
final User userRef = scope.user; | ||
this.user = userRef != null ? new User(userRef) : null; | ||
|
@@ -945,6 +953,26 @@ public void setPropagationContext(final @NotNull PropagationContext propagationC | |
return new Scope(this); | ||
} | ||
|
||
@Override | ||
public void setLastEventId(@NotNull SentryId lastEventId) { | ||
this.lastEventId = lastEventId; | ||
} | ||
|
||
@Override | ||
public @NotNull SentryId getLastEventId() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit weird but JS removed this feature altogether:
But to be honest I still think we need it though 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we intend to remove it, we should deprecate it for a while and only remove this in a later major, not in |
||
return lastEventId; | ||
} | ||
|
||
@Override | ||
public void setClient(@NotNull ISentryClient client) { | ||
this.client = client; | ||
} | ||
|
||
@Override | ||
public @NotNull ISentryClient getClient() { | ||
return client; | ||
} | ||
|
||
/** The IWithTransaction callback */ | ||
@ApiStatus.Internal | ||
public interface IWithTransaction { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Client now lives on
IScope
and we'll set the default one on global scope in the future (follow up PR).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Client is now bound to global scope, as of #3344 but the code region is changed in later PRs a couple times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! For metrics it would be important to have only one shared
SentryClient
instance by default, as metrics aggregation/sending is bound to that right now. If that's not the case anymore just let me know, I can take a look.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should still be true. The
SentryClient
is set on global scope onSentry.init
. Before that there's aNoOpSentryClient
on global scope. By default there should also only ever beNoOpSentryClient
on isolation and current scope. A user can however bind any client on any of the scopes.