diff --git a/sentry/api/sentry.api b/sentry/api/sentry.api index bcfc1c9194..52eb5df888 100644 --- a/sentry/api/sentry.api +++ b/sentry/api/sentry.api @@ -293,7 +293,7 @@ public final class io/sentry/EnvelopeReader : io/sentry/IEnvelopeReader { } public final class io/sentry/EnvelopeSender : io/sentry/IEnvelopeSender { - public fun (Lio/sentry/IHub;Lio/sentry/ISerializer;Lio/sentry/ILogger;JI)V + public fun (Lio/sentry/IScopes;Lio/sentry/ISerializer;Lio/sentry/ILogger;JI)V public synthetic fun processDirectory (Ljava/io/File;)V public fun processEnvelopeFile (Ljava/lang/String;Lio/sentry/Hint;)V } @@ -520,6 +520,59 @@ public final class io/sentry/HubAdapter : io/sentry/IHub { public fun withScope (Lio/sentry/ScopeCallback;)V } +public final class io/sentry/HubScopesWrapper : io/sentry/IHub { + public fun (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; @@ -548,71 +601,7 @@ public abstract interface class io/sentry/IEnvelopeSender { public abstract fun processEnvelopeFile (Ljava/lang/String;Lio/sentry/Hint;)V } -public abstract interface class io/sentry/IHub { - public abstract fun addBreadcrumb (Lio/sentry/Breadcrumb;)V - public abstract fun addBreadcrumb (Lio/sentry/Breadcrumb;Lio/sentry/Hint;)V - public fun addBreadcrumb (Ljava/lang/String;)V - public fun addBreadcrumb (Ljava/lang/String;Ljava/lang/String;)V - public abstract fun bindClient (Lio/sentry/ISentryClient;)V - public abstract fun captureCheckIn (Lio/sentry/CheckIn;)Lio/sentry/protocol/SentryId; - public fun captureEnvelope (Lio/sentry/SentryEnvelope;)Lio/sentry/protocol/SentryId; - public abstract fun captureEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId; - public fun captureEvent (Lio/sentry/SentryEvent;)Lio/sentry/protocol/SentryId; - public abstract fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId; - public abstract fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId; - public fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId; - public fun captureException (Ljava/lang/Throwable;)Lio/sentry/protocol/SentryId; - public abstract fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId; - public abstract fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId; - public fun captureException (Ljava/lang/Throwable;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId; - public fun captureMessage (Ljava/lang/String;)Lio/sentry/protocol/SentryId; - public fun captureMessage (Ljava/lang/String;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId; - public abstract fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId; - public abstract fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId; - public fun captureTransaction (Lio/sentry/protocol/SentryTransaction;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId; - public fun captureTransaction (Lio/sentry/protocol/SentryTransaction;Lio/sentry/TraceContext;)Lio/sentry/protocol/SentryId; - public fun captureTransaction (Lio/sentry/protocol/SentryTransaction;Lio/sentry/TraceContext;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId; - public abstract fun captureTransaction (Lio/sentry/protocol/SentryTransaction;Lio/sentry/TraceContext;Lio/sentry/Hint;Lio/sentry/ProfilingTraceData;)Lio/sentry/protocol/SentryId; - public abstract fun captureUserFeedback (Lio/sentry/UserFeedback;)V - public abstract fun clearBreadcrumbs ()V - public abstract fun clone ()Lio/sentry/IHub; - public abstract fun close ()V - public abstract fun close (Z)V - public abstract fun configureScope (Lio/sentry/ScopeCallback;)V - public abstract fun continueTrace (Ljava/lang/String;Ljava/util/List;)Lio/sentry/TransactionContext; - public abstract fun endSession ()V - public abstract fun flush (J)V - public abstract fun getBaggage ()Lio/sentry/BaggageHeader; - public abstract fun getLastEventId ()Lio/sentry/protocol/SentryId; - public abstract fun getOptions ()Lio/sentry/SentryOptions; - public abstract fun getRateLimiter ()Lio/sentry/transport/RateLimiter; - public abstract fun getSpan ()Lio/sentry/ISpan; - public abstract fun getTraceparent ()Lio/sentry/SentryTraceHeader; - public abstract fun getTransaction ()Lio/sentry/ITransaction; - public abstract fun isCrashedLastRun ()Ljava/lang/Boolean; - public abstract fun isEnabled ()Z - public abstract fun isHealthy ()Z - public abstract fun metrics ()Lio/sentry/metrics/MetricsApi; - public abstract fun popScope ()V - public abstract fun pushScope ()V - public abstract fun removeExtra (Ljava/lang/String;)V - public abstract fun removeTag (Ljava/lang/String;)V - public fun reportFullDisplayed ()V - public abstract fun reportFullyDisplayed ()V - public abstract fun setExtra (Ljava/lang/String;Ljava/lang/String;)V - public abstract fun setFingerprint (Ljava/util/List;)V - 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 setTransaction (Ljava/lang/String;)V - public abstract fun setUser (Lio/sentry/protocol/User;)V - public abstract fun startSession ()V - public fun startTransaction (Lio/sentry/TransactionContext;)Lio/sentry/ITransaction; - public abstract fun startTransaction (Lio/sentry/TransactionContext;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction; - public fun startTransaction (Ljava/lang/String;Ljava/lang/String;)Lio/sentry/ITransaction; - public fun startTransaction (Ljava/lang/String;Ljava/lang/String;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction; - public abstract fun traceHeaders ()Lio/sentry/SentryTraceHeader; - public abstract fun withScope (Lio/sentry/ScopeCallback;)V +public abstract interface class io/sentry/IHub : io/sentry/IScopes { } public abstract interface class io/sentry/ILogger { @@ -731,6 +720,74 @@ public abstract interface class io/sentry/IScopeObserver { public abstract fun setUser (Lio/sentry/protocol/User;)V } +public abstract interface class io/sentry/IScopes { + public abstract fun addBreadcrumb (Lio/sentry/Breadcrumb;)V + public abstract fun addBreadcrumb (Lio/sentry/Breadcrumb;Lio/sentry/Hint;)V + public fun addBreadcrumb (Ljava/lang/String;)V + public fun addBreadcrumb (Ljava/lang/String;Ljava/lang/String;)V + public abstract fun bindClient (Lio/sentry/ISentryClient;)V + public abstract fun captureCheckIn (Lio/sentry/CheckIn;)Lio/sentry/protocol/SentryId; + public fun captureEnvelope (Lio/sentry/SentryEnvelope;)Lio/sentry/protocol/SentryId; + public abstract fun captureEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId; + public fun captureEvent (Lio/sentry/SentryEvent;)Lio/sentry/protocol/SentryId; + public abstract fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId; + public abstract fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId; + public fun captureEvent (Lio/sentry/SentryEvent;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId; + public fun captureException (Ljava/lang/Throwable;)Lio/sentry/protocol/SentryId; + public abstract fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId; + public abstract fun captureException (Ljava/lang/Throwable;Lio/sentry/Hint;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId; + public fun captureException (Ljava/lang/Throwable;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId; + public fun captureMessage (Ljava/lang/String;)Lio/sentry/protocol/SentryId; + public fun captureMessage (Ljava/lang/String;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId; + public abstract fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;)Lio/sentry/protocol/SentryId; + public abstract fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId; + public fun captureTransaction (Lio/sentry/protocol/SentryTransaction;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId; + public fun captureTransaction (Lio/sentry/protocol/SentryTransaction;Lio/sentry/TraceContext;)Lio/sentry/protocol/SentryId; + public fun captureTransaction (Lio/sentry/protocol/SentryTransaction;Lio/sentry/TraceContext;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId; + public abstract fun captureTransaction (Lio/sentry/protocol/SentryTransaction;Lio/sentry/TraceContext;Lio/sentry/Hint;Lio/sentry/ProfilingTraceData;)Lio/sentry/protocol/SentryId; + public abstract fun captureUserFeedback (Lio/sentry/UserFeedback;)V + public abstract fun clearBreadcrumbs ()V + public abstract fun clone ()Lio/sentry/IHub; + public abstract fun close ()V + public abstract fun close (Z)V + public abstract fun configureScope (Lio/sentry/ScopeCallback;)V + public abstract fun continueTrace (Ljava/lang/String;Ljava/util/List;)Lio/sentry/TransactionContext; + public abstract fun endSession ()V + public abstract fun flush (J)V + public abstract fun getBaggage ()Lio/sentry/BaggageHeader; + public abstract fun getLastEventId ()Lio/sentry/protocol/SentryId; + public abstract fun getOptions ()Lio/sentry/SentryOptions; + public abstract fun getRateLimiter ()Lio/sentry/transport/RateLimiter; + public abstract fun getSpan ()Lio/sentry/ISpan; + public abstract fun getTraceparent ()Lio/sentry/SentryTraceHeader; + public abstract fun getTransaction ()Lio/sentry/ITransaction; + public abstract fun isCrashedLastRun ()Ljava/lang/Boolean; + public abstract fun isEnabled ()Z + public abstract fun isHealthy ()Z + public fun isNoOp ()Z + public abstract fun metrics ()Lio/sentry/metrics/MetricsApi; + public abstract fun popScope ()V + public abstract fun pushScope ()V + public abstract fun removeExtra (Ljava/lang/String;)V + public abstract fun removeTag (Ljava/lang/String;)V + public fun reportFullDisplayed ()V + public abstract fun reportFullyDisplayed ()V + public abstract fun setExtra (Ljava/lang/String;Ljava/lang/String;)V + public abstract fun setFingerprint (Ljava/util/List;)V + 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 setTransaction (Ljava/lang/String;)V + public abstract fun setUser (Lio/sentry/protocol/User;)V + public abstract fun startSession ()V + public fun startTransaction (Lio/sentry/TransactionContext;)Lio/sentry/ITransaction; + public abstract fun startTransaction (Lio/sentry/TransactionContext;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction; + public fun startTransaction (Ljava/lang/String;Ljava/lang/String;)Lio/sentry/ITransaction; + public fun startTransaction (Ljava/lang/String;Ljava/lang/String;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction; + public abstract fun traceHeaders ()Lio/sentry/SentryTraceHeader; + public abstract fun withScope (Lio/sentry/ScopeCallback;)V +} + public abstract interface class io/sentry/ISentryClient { public abstract fun captureCheckIn (Lio/sentry/CheckIn;Lio/sentry/IScope;Lio/sentry/Hint;)Lio/sentry/protocol/SentryId; public fun captureEnvelope (Lio/sentry/SentryEnvelope;)Lio/sentry/protocol/SentryId; @@ -853,7 +910,7 @@ public final class io/sentry/Instrumenter : java/lang/Enum { } public abstract interface class io/sentry/Integration { - public abstract fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V + public abstract fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V } public final class io/sentry/IpAddressUtils { @@ -1187,6 +1244,7 @@ public final class io/sentry/NoOpHub : io/sentry/IHub { public fun isCrashedLastRun ()Ljava/lang/Boolean; public fun isEnabled ()Z public fun isHealthy ()Z + public fun isNoOp ()Z public fun metrics ()Lio/sentry/metrics/MetricsApi; public fun popScope ()V public fun pushScope ()V @@ -1270,6 +1328,60 @@ public final class io/sentry/NoOpScope : io/sentry/IScope { public fun withTransaction (Lio/sentry/Scope$IWithTransaction;)V } +public final class io/sentry/NoOpScopes : io/sentry/IScopes { + 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 static fun getInstance ()Lio/sentry/NoOpScopes; + 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 isNoOp ()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 final class io/sentry/NoOpSpan : io/sentry/ISpan { public fun finish ()V public fun finish (Lio/sentry/SpanStatus;)V @@ -1403,7 +1515,7 @@ public final class io/sentry/OptionsContainer { } public final class io/sentry/OutboxSender : io/sentry/IEnvelopeSender { - public fun (Lio/sentry/IHub;Lio/sentry/IEnvelopeReader;Lio/sentry/ISerializer;Lio/sentry/ILogger;JI)V + public fun (Lio/sentry/IScopes;Lio/sentry/IEnvelopeReader;Lio/sentry/ISerializer;Lio/sentry/ILogger;JI)V public synthetic fun processDirectory (Ljava/io/File;)V public fun processEnvelopeFile (Ljava/lang/String;Lio/sentry/Hint;)V } @@ -1668,11 +1780,64 @@ public abstract class io/sentry/ScopeObserverAdapter : io/sentry/IScopeObserver public fun setUser (Lio/sentry/protocol/User;)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 + 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 static fun getInstance ()Lio/sentry/ScopesAdapter; + 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 final class io/sentry/SendCachedEnvelopeFireAndForgetIntegration : io/sentry/IConnectionStatusProvider$IConnectionStatusObserver, io/sentry/Integration, java/io/Closeable { public fun (Lio/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForgetFactory;)V public fun close ()V public fun onConnectionStatusChanged (Lio/sentry/IConnectionStatusProvider$ConnectionStatus;)V - public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V + public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V } public abstract interface class io/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForget { @@ -1684,19 +1849,19 @@ public abstract interface class io/sentry/SendCachedEnvelopeFireAndForgetIntegra } public abstract interface class io/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForgetFactory { - public abstract fun create (Lio/sentry/IHub;Lio/sentry/SentryOptions;)Lio/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForget; + public abstract fun create (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)Lio/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForget; public fun hasValidPath (Ljava/lang/String;Lio/sentry/ILogger;)Z public fun processDir (Lio/sentry/DirectoryProcessor;Ljava/lang/String;Lio/sentry/ILogger;)Lio/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForget; } public final class io/sentry/SendFireAndForgetEnvelopeSender : io/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForgetFactory { public fun (Lio/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForgetDirPath;)V - public fun create (Lio/sentry/IHub;Lio/sentry/SentryOptions;)Lio/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForget; + public fun create (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)Lio/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForget; } public final class io/sentry/SendFireAndForgetOutboxSender : io/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForgetFactory { public fun (Lio/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForgetDirPath;)V - public fun create (Lio/sentry/IHub;Lio/sentry/SentryOptions;)Lio/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForget; + public fun create (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)Lio/sentry/SendCachedEnvelopeFireAndForgetIntegration$SendFireAndForget; } public final class io/sentry/Sentry { @@ -1721,7 +1886,7 @@ public final class io/sentry/Sentry { public static fun captureMessage (Ljava/lang/String;Lio/sentry/SentryLevel;Lio/sentry/ScopeCallback;)Lio/sentry/protocol/SentryId; public static fun captureUserFeedback (Lio/sentry/UserFeedback;)V public static fun clearBreadcrumbs ()V - public static fun cloneMainHub ()Lio/sentry/IHub; + public static fun cloneMainHub ()Lio/sentry/IScopes; public static fun close ()V public static fun configureScope (Lio/sentry/ScopeCallback;)V public static fun continueTrace (Ljava/lang/String;Ljava/util/List;)Lio/sentry/TransactionContext; @@ -1729,6 +1894,7 @@ public final class io/sentry/Sentry { public static fun flush (J)V public static fun getBaggage ()Lio/sentry/BaggageHeader; public static fun getCurrentHub ()Lio/sentry/IHub; + public static fun getCurrentScopes ()Lio/sentry/IScopes; public static fun getLastEventId ()Lio/sentry/protocol/SentryId; public static fun getSpan ()Lio/sentry/ISpan; public static fun getTraceparent ()Lio/sentry/SentryTraceHeader; @@ -1750,6 +1916,7 @@ public final class io/sentry/Sentry { public static fun reportFullDisplayed ()V public static fun reportFullyDisplayed ()V public static fun setCurrentHub (Lio/sentry/IHub;)V + public static fun setCurrentScopes (Lio/sentry/IScopes;)V public static fun setExtra (Ljava/lang/String;Ljava/lang/String;)V public static fun setFingerprint (Ljava/util/List;)V public static fun setLevel (Lio/sentry/SentryLevel;)V @@ -2500,8 +2667,8 @@ public final class io/sentry/SentryTraceHeader { } public final class io/sentry/SentryTracer : io/sentry/ITransaction { - public fun (Lio/sentry/TransactionContext;Lio/sentry/IHub;)V - public fun (Lio/sentry/TransactionContext;Lio/sentry/IHub;Lio/sentry/TransactionOptions;)V + public fun (Lio/sentry/TransactionContext;Lio/sentry/IScopes;)V + public fun (Lio/sentry/TransactionContext;Lio/sentry/IScopes;Lio/sentry/TransactionOptions;)V public fun finish ()V public fun finish (Lio/sentry/SpanStatus;)V public fun finish (Lio/sentry/SpanStatus;Lio/sentry/SentryDate;)V @@ -2630,11 +2797,11 @@ public final class io/sentry/ShutdownHookIntegration : io/sentry/Integration, ja public fun ()V public fun (Ljava/lang/Runtime;)V public fun close ()V - public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V + public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V } public final class io/sentry/Span : io/sentry/ISpan { - public fun (Lio/sentry/TransactionContext;Lio/sentry/SentryTracer;Lio/sentry/IHub;Lio/sentry/SentryDate;Lio/sentry/SpanOptions;)V + public fun (Lio/sentry/TransactionContext;Lio/sentry/SentryTracer;Lio/sentry/IScopes;Lio/sentry/SentryDate;Lio/sentry/SpanOptions;)V public fun finish ()V public fun finish (Lio/sentry/SpanStatus;)V public fun finish (Lio/sentry/SpanStatus;Lio/sentry/SentryDate;)V @@ -2815,7 +2982,7 @@ public final class io/sentry/SpotlightIntegration : io/sentry/Integration, io/se public fun close ()V public fun execute (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)V public fun getSpotlightConnectionUrl ()Ljava/lang/String; - public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V + public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V } public final class io/sentry/SystemOutLogger : io/sentry/ILogger { @@ -2975,7 +3142,7 @@ public final class io/sentry/TypeCheckHint { public final class io/sentry/UncaughtExceptionHandlerIntegration : io/sentry/Integration, java/io/Closeable, java/lang/Thread$UncaughtExceptionHandler { public fun ()V public fun close ()V - public final fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V + public final fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V public fun uncaughtException (Ljava/lang/Thread;Ljava/lang/Throwable;)V } @@ -3016,7 +3183,7 @@ public final class io/sentry/UserFeedback$JsonKeys { } public final class io/sentry/backpressure/BackpressureMonitor : io/sentry/backpressure/IBackpressureMonitor, java/lang/Runnable { - public fun (Lio/sentry/SentryOptions;Lio/sentry/IHub;)V + public fun (Lio/sentry/SentryOptions;Lio/sentry/IScopes;)V public fun getDownsampleFactor ()I public fun run ()V public fun start ()V @@ -5102,9 +5269,9 @@ public final class io/sentry/util/StringUtils { public final class io/sentry/util/TracingUtils { public fun ()V public static fun maybeUpdateBaggage (Lio/sentry/IScope;Lio/sentry/SentryOptions;)Lio/sentry/PropagationContext; - public static fun startNewTrace (Lio/sentry/IHub;)V - public static fun trace (Lio/sentry/IHub;Ljava/util/List;Lio/sentry/ISpan;)Lio/sentry/util/TracingUtils$TracingHeaders; - public static fun traceIfAllowed (Lio/sentry/IHub;Ljava/lang/String;Ljava/util/List;Lio/sentry/ISpan;)Lio/sentry/util/TracingUtils$TracingHeaders; + 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; } public final class io/sentry/util/TracingUtils$TracingHeaders { diff --git a/sentry/src/main/java/io/sentry/Hub.java b/sentry/src/main/java/io/sentry/Hub.java index 6b6da88f09..6a98bb2367 100644 --- a/sentry/src/main/java/io/sentry/Hub.java +++ b/sentry/src/main/java/io/sentry/Hub.java @@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +@Deprecated public final class Hub implements IHub, MetricsApi.IMetricsInterface { private volatile @NotNull SentryId lastEventId; diff --git a/sentry/src/main/java/io/sentry/HubAdapter.java b/sentry/src/main/java/io/sentry/HubAdapter.java index b31d853192..746d51f0cc 100644 --- a/sentry/src/main/java/io/sentry/HubAdapter.java +++ b/sentry/src/main/java/io/sentry/HubAdapter.java @@ -10,6 +10,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +/** + * @deprecated use {@link ScopesAdapter} instead + */ +@Deprecated public final class HubAdapter implements IHub { private static final HubAdapter INSTANCE = new HubAdapter(); @@ -50,7 +54,7 @@ public boolean isEnabled() { @ApiStatus.Internal @Override public @NotNull SentryId captureEnvelope(@NotNull SentryEnvelope envelope, @Nullable Hint hint) { - return Sentry.getCurrentHub().captureEnvelope(envelope, hint); + return Sentry.getCurrentScopes().captureEnvelope(envelope, hint); } @Override @@ -186,7 +190,7 @@ public void flush(long timeoutMillis) { @Override public @NotNull IHub clone() { - return Sentry.getCurrentHub().clone(); + return Sentry.getCurrentScopes().clone(); } @Override @@ -195,7 +199,7 @@ public void flush(long timeoutMillis) { @Nullable TraceContext traceContext, @Nullable Hint hint, @Nullable ProfilingTraceData profilingTraceData) { - return Sentry.getCurrentHub() + return Sentry.getCurrentScopes() .captureTransaction(transaction, traceContext, hint, profilingTraceData); } @@ -217,23 +221,23 @@ public void setSpanContext( final @NotNull Throwable throwable, final @NotNull ISpan span, final @NotNull String transactionName) { - Sentry.getCurrentHub().setSpanContext(throwable, span, transactionName); + Sentry.getCurrentScopes().setSpanContext(throwable, span, transactionName); } @Override public @Nullable ISpan getSpan() { - return Sentry.getCurrentHub().getSpan(); + return Sentry.getCurrentScopes().getSpan(); } @Override @ApiStatus.Internal public @Nullable ITransaction getTransaction() { - return Sentry.getCurrentHub().getTransaction(); + return Sentry.getCurrentScopes().getTransaction(); } @Override public @NotNull SentryOptions getOptions() { - return Sentry.getCurrentHub().getOptions(); + return Sentry.getCurrentScopes().getOptions(); } @Override @@ -271,11 +275,11 @@ public void reportFullyDisplayed() { @ApiStatus.Internal @Override public @Nullable RateLimiter getRateLimiter() { - return Sentry.getCurrentHub().getRateLimiter(); + return Sentry.getCurrentScopes().getRateLimiter(); } @Override public @NotNull MetricsApi metrics() { - return Sentry.getCurrentHub().metrics(); + return Sentry.getCurrentScopes().metrics(); } } diff --git a/sentry/src/main/java/io/sentry/HubScopesWrapper.java b/sentry/src/main/java/io/sentry/HubScopesWrapper.java new file mode 100644 index 0000000000..9b294d05b7 --- /dev/null +++ b/sentry/src/main/java/io/sentry/HubScopesWrapper.java @@ -0,0 +1,279 @@ +package io.sentry; + +import io.sentry.metrics.MetricsApi; +import io.sentry.protocol.SentryId; +import io.sentry.protocol.SentryTransaction; +import io.sentry.protocol.User; +import io.sentry.transport.RateLimiter; +import java.util.List; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +@SuppressWarnings("deprecation") +@Deprecated +public final class HubScopesWrapper implements IHub { + + private final IScopes scopes; + + public HubScopesWrapper(final @NotNull IScopes scopes) { + this.scopes = scopes; + } + + @Override + public boolean isEnabled() { + return scopes.isEnabled(); + } + + @Override + public @NotNull SentryId captureEvent(@NotNull SentryEvent event, @Nullable Hint hint) { + return scopes.captureEvent(event, hint); + } + + @Override + public @NotNull SentryId captureEvent( + @NotNull SentryEvent event, @Nullable Hint hint, @NotNull ScopeCallback callback) { + return scopes.captureEvent(event, hint, callback); + } + + @Override + public @NotNull SentryId captureMessage(@NotNull String message, @NotNull SentryLevel level) { + return scopes.captureMessage(message, level); + } + + @Override + public @NotNull SentryId captureMessage( + @NotNull String message, @NotNull SentryLevel level, @NotNull ScopeCallback callback) { + return scopes.captureMessage(message, level, callback); + } + + @Override + public @NotNull SentryId captureEnvelope(@NotNull SentryEnvelope envelope, @Nullable Hint hint) { + return scopes.captureEnvelope(envelope, hint); + } + + @Override + public @NotNull SentryId captureException(@NotNull Throwable throwable, @Nullable Hint hint) { + return scopes.captureException(throwable, hint); + } + + @Override + public @NotNull SentryId captureException( + @NotNull Throwable throwable, @Nullable Hint hint, @NotNull ScopeCallback callback) { + return scopes.captureException(throwable, hint, callback); + } + + @Override + public void captureUserFeedback(@NotNull UserFeedback userFeedback) { + scopes.captureUserFeedback(userFeedback); + } + + @Override + public void startSession() { + scopes.startSession(); + } + + @Override + public void endSession() { + scopes.endSession(); + } + + @Override + public void close() { + scopes.close(); + } + + @Override + public void close(boolean isRestarting) { + scopes.close(isRestarting); + } + + @Override + public void addBreadcrumb(@NotNull Breadcrumb breadcrumb, @Nullable Hint hint) { + scopes.addBreadcrumb(breadcrumb, hint); + } + + @Override + public void addBreadcrumb(@NotNull Breadcrumb breadcrumb) { + scopes.addBreadcrumb(breadcrumb); + } + + @Override + public void setLevel(@Nullable SentryLevel level) { + scopes.setLevel(level); + } + + @Override + public void setTransaction(@Nullable String transaction) { + scopes.setTransaction(transaction); + } + + @Override + public void setUser(@Nullable User user) { + scopes.setUser(user); + } + + @Override + public void setFingerprint(@NotNull List fingerprint) { + scopes.setFingerprint(fingerprint); + } + + @Override + public void clearBreadcrumbs() { + scopes.clearBreadcrumbs(); + } + + @Override + public void setTag(@NotNull String key, @NotNull String value) { + scopes.setTag(key, value); + } + + @Override + public void removeTag(@NotNull String key) { + scopes.removeTag(key); + } + + @Override + public void setExtra(@NotNull String key, @NotNull String value) { + scopes.setExtra(key, value); + } + + @Override + public void removeExtra(@NotNull String key) { + scopes.removeExtra(key); + } + + @Override + public @NotNull SentryId getLastEventId() { + return scopes.getLastEventId(); + } + + @Override + public void pushScope() { + scopes.pushScope(); + } + + @Override + public void popScope() { + scopes.popScope(); + } + + @Override + public void withScope(@NotNull ScopeCallback callback) { + scopes.withScope(callback); + } + + @Override + public void configureScope(@NotNull ScopeCallback callback) { + scopes.configureScope(callback); + } + + @Override + public void bindClient(@NotNull ISentryClient client) { + scopes.bindClient(client); + } + + @Override + public boolean isHealthy() { + return scopes.isHealthy(); + } + + @Override + public void flush(long timeoutMillis) { + scopes.flush(timeoutMillis); + } + + @Override + public @NotNull IHub clone() { + return scopes.clone(); + } + + @ApiStatus.Internal + @Override + public @NotNull SentryId captureTransaction( + @NotNull SentryTransaction transaction, + @Nullable TraceContext traceContext, + @Nullable Hint hint, + @Nullable ProfilingTraceData profilingTraceData) { + return scopes.captureTransaction(transaction, traceContext, hint, profilingTraceData); + } + + @Override + public @NotNull ITransaction startTransaction( + @NotNull TransactionContext transactionContext, + @NotNull TransactionOptions transactionOptions) { + return scopes.startTransaction(transactionContext, transactionOptions); + } + + @Override + public @Nullable SentryTraceHeader traceHeaders() { + return scopes.traceHeaders(); + } + + @ApiStatus.Internal + @Override + public void setSpanContext( + @NotNull Throwable throwable, @NotNull ISpan span, @NotNull String transactionName) { + scopes.setSpanContext(throwable, span, transactionName); + } + + @Override + public @Nullable ISpan getSpan() { + return scopes.getSpan(); + } + + @ApiStatus.Internal + @Override + public @Nullable ITransaction getTransaction() { + return scopes.getTransaction(); + } + + @Override + public @NotNull SentryOptions getOptions() { + return scopes.getOptions(); + } + + @Override + public @Nullable Boolean isCrashedLastRun() { + return scopes.isCrashedLastRun(); + } + + @Override + public void reportFullyDisplayed() { + scopes.reportFullyDisplayed(); + } + + @Override + public @Nullable TransactionContext continueTrace( + @Nullable String sentryTrace, @Nullable List baggageHeaders) { + return scopes.continueTrace(sentryTrace, baggageHeaders); + } + + @Override + public @Nullable SentryTraceHeader getTraceparent() { + return scopes.getTraceparent(); + } + + @Override + public @Nullable BaggageHeader getBaggage() { + return scopes.getBaggage(); + } + + @ApiStatus.Experimental + @Override + public @NotNull SentryId captureCheckIn(@NotNull CheckIn checkIn) { + return scopes.captureCheckIn(checkIn); + } + + @ApiStatus.Internal + @Override + public @Nullable RateLimiter getRateLimiter() { + return scopes.getRateLimiter(); + } + + @ApiStatus.Experimental + @Override + public @NotNull MetricsApi metrics() { + return scopes.metrics(); + } +} diff --git a/sentry/src/main/java/io/sentry/IHub.java b/sentry/src/main/java/io/sentry/IHub.java index 684d8ec528..23a7bed7de 100644 --- a/sentry/src/main/java/io/sentry/IHub.java +++ b/sentry/src/main/java/io/sentry/IHub.java @@ -1,590 +1,9 @@ package io.sentry; -import io.sentry.metrics.MetricsApi; -import io.sentry.protocol.SentryId; -import io.sentry.protocol.SentryTransaction; -import io.sentry.protocol.User; -import io.sentry.transport.RateLimiter; -import java.util.List; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** SDK API contract which combines a client and scope management */ -public interface IHub { - - /** - * Check if the Hub is enabled/active. - * - * @return true if its enabled or false otherwise. - */ - boolean isEnabled(); - - /** - * Captures the event. - * - * @param event the event - * @param hint SDK specific but provides high level information about the origin of the event - * @return The Id (SentryId object) of the event - */ - @NotNull - SentryId captureEvent(@NotNull SentryEvent event, @Nullable Hint hint); - - /** - * Captures the event. - * - * @param event the event - * @return The Id (SentryId object) of the event - */ - default @NotNull SentryId captureEvent(@NotNull SentryEvent event) { - return captureEvent(event, new Hint()); - } - - /** - * Captures the event. - * - * @param event the event - * @param callback The callback to configure the scope for a single invocation. - * @return The Id (SentryId object) of the event - */ - default @NotNull SentryId captureEvent( - @NotNull SentryEvent event, final @NotNull ScopeCallback callback) { - return captureEvent(event, new Hint(), callback); - } - - /** - * Captures the event. - * - * @param event the event - * @param hint SDK specific but provides high level information about the origin of the event - * @param callback The callback to configure the scope for a single invocation. - * @return The Id (SentryId object) of the event - */ - @NotNull - SentryId captureEvent( - final @NotNull SentryEvent event, - final @Nullable Hint hint, - final @NotNull ScopeCallback callback); - - /** - * Captures the message. - * - * @param message The message to send. - * @return The Id (SentryId object) of the event - */ - default @NotNull SentryId captureMessage(@NotNull String message) { - return captureMessage(message, SentryLevel.INFO); - } - - /** - * Captures the message. - * - * @param message The message to send. - * @param level The message level. - * @return The Id (SentryId object) of the event - */ - @NotNull - SentryId captureMessage(@NotNull String message, @NotNull SentryLevel level); - - /** - * Captures the message. - * - * @param message The message to send. - * @param level The message level. - * @param callback The callback to configure the scope for a single invocation. - * @return The Id (SentryId object) of the event - */ - @NotNull - SentryId captureMessage( - @NotNull String message, @NotNull SentryLevel level, @NotNull ScopeCallback callback); - - /** - * Captures the message. - * - * @param message The message to send. - * @param callback The callback to configure the scope for a single invocation. - * @return The Id (SentryId object) of the event - */ - default @NotNull SentryId captureMessage( - @NotNull String message, @NotNull ScopeCallback callback) { - return captureMessage(message, SentryLevel.INFO, callback); - } - - /** - * Captures an envelope. - * - * @param envelope the SentryEnvelope to send. - * @param hint SDK specific but provides high level information about the origin of the event - * @return The Id (SentryId object) of the event - */ - @NotNull - SentryId captureEnvelope(@NotNull SentryEnvelope envelope, @Nullable Hint hint); - - /** - * Captures an envelope. - * - * @param envelope the SentryEnvelope to send. - * @return The Id (SentryId object) of the event - */ - default @NotNull SentryId captureEnvelope(@NotNull SentryEnvelope envelope) { - return captureEnvelope(envelope, new Hint()); - } - - /** - * Captures the exception. - * - * @param throwable The exception. - * @param hint SDK specific but provides high level information about the origin of the event - * @return The Id (SentryId object) of the event - */ - @NotNull - SentryId captureException(@NotNull Throwable throwable, @Nullable Hint hint); - - /** - * Captures the exception. - * - * @param throwable The exception. - * @return The Id (SentryId object) of the event - */ - default @NotNull SentryId captureException(@NotNull Throwable throwable) { - return captureException(throwable, new Hint()); - } - - /** - * Captures the exception. - * - * @param throwable The exception. - * @param callback The callback to configure the scope for a single invocation. - * @return The Id (SentryId object) of the event - */ - default @NotNull SentryId captureException( - @NotNull Throwable throwable, final @NotNull ScopeCallback callback) { - return captureException(throwable, new Hint(), callback); - } - - /** - * Captures the exception. - * - * @param throwable The exception. - * @param hint SDK specific but provides high level information about the origin of the event - * @param callback The callback to configure the scope for a single invocation. - * @return The Id (SentryId object) of the event - */ - @NotNull - SentryId captureException( - final @NotNull Throwable throwable, - final @Nullable Hint hint, - final @NotNull ScopeCallback callback); - - /** - * Captures a manually created user feedback and sends it to Sentry. - * - * @param userFeedback The user feedback to send to Sentry. - */ - void captureUserFeedback(@NotNull UserFeedback userFeedback); - - /** Starts a new session. If there's a running session, it ends it before starting the new one. */ - void startSession(); - - /** Ends the current session */ - void endSession(); - - /** Flushes out the queue for up to timeout seconds and disable the Hub. */ - void close(); - - /** - * Flushes out the queue for up to timeout seconds and disable the Hub. - * - * @param isRestarting if true, avoids locking the main thread when finishing the queue. - */ - void close(boolean isRestarting); - - /** - * Adds a breadcrumb to the current Scope - * - * @param breadcrumb the breadcrumb - * @param hint SDK specific but provides high level information about the origin of the event - */ - void addBreadcrumb(@NotNull Breadcrumb breadcrumb, @Nullable Hint hint); - - /** - * Adds a breadcrumb to the current Scope - * - * @param breadcrumb the breadcrumb - */ - void addBreadcrumb(@NotNull Breadcrumb breadcrumb); - - /** - * Adds a breadcrumb to the current Scope - * - * @param message rendered as text and the whitespace is preserved. - */ - default void addBreadcrumb(@NotNull String message) { - addBreadcrumb(new Breadcrumb(message)); - } - - /** - * Adds a breadcrumb to the current Scope - * - * @param message rendered as text and the whitespace is preserved. - * @param category Categories are dotted strings that indicate what the crumb is or where it comes - * from. - */ - default void addBreadcrumb(@NotNull String message, @NotNull String category) { - Breadcrumb breadcrumb = new Breadcrumb(message); - breadcrumb.setCategory(category); - addBreadcrumb(breadcrumb); - } - - /** - * Sets the level of all events sent within current Scope - * - * @param level the Sentry level - */ - void setLevel(@Nullable SentryLevel level); - - /** - * Sets the name of the current transaction to the current Scope. - * - * @param transaction the transaction - */ - void setTransaction(@Nullable String transaction); - - /** - * Shallow merges user configuration (email, username, etc) to the current Scope. - * - * @param user the user - */ - void setUser(@Nullable User user); - - /** - * Sets the fingerprint to group specific events together to the current Scope. - * - * @param fingerprint the fingerprints - */ - void setFingerprint(@NotNull List fingerprint); - - /** Deletes current breadcrumbs from the current scope. */ - void clearBreadcrumbs(); - - /** - * Sets the tag to a string value to the current Scope, overwriting a potential previous value - * - * @param key the key - * @param value the value - */ - void setTag(@NotNull String key, @NotNull String value); - - /** - * Removes the tag to a string value to the current Scope - * - * @param key the key - */ - void removeTag(@NotNull String key); - - /** - * Sets the extra key to an arbitrary value to the current Scope, overwriting a potential previous - * value - * - * @param key the key - * @param value the value - */ - void setExtra(@NotNull String key, @NotNull String value); - - /** - * Removes the extra key to an arbitrary value to the current Scope - * - * @param key the key - */ - void removeExtra(@NotNull String key); - - /** - * Last event id recorded in the current scope - * - * @return last SentryId - */ - @NotNull - SentryId getLastEventId(); - - /** Pushes a new scope while inheriting the current scope's data. */ - void pushScope(); - - /** Removes the first scope */ - void popScope(); - - /** - * Runs the callback with a new scope which gets dropped at the end. If you're using the Sentry - * SDK in globalHubMode (defaults to true on Android) {@link - * Sentry#init(Sentry.OptionsConfiguration, boolean)} calling withScope is discouraged, as scope - * changes may be dropped when executed in parallel. Use {@link - * IHub#configureScope(ScopeCallback)} instead. - * - * @param callback the callback - */ - void withScope(@NotNull ScopeCallback callback); - - /** - * Configures the scope through the callback. - * - * @param callback The configure scope callback. - */ - void configureScope(@NotNull ScopeCallback callback); - - /** - * Binds a different client to the hub - * - * @param client the client. - */ - void bindClient(@NotNull ISentryClient client); - - /** - * Whether the transport is healthy. - * - * @return true if the transport is healthy - */ - boolean isHealthy(); - - /** - * Flushes events queued up, but keeps the Hub enabled. Not implemented yet. - * - * @param timeoutMillis time in milliseconds - */ - void flush(long timeoutMillis); - - /** - * Clones the Hub - * - * @return the cloned Hub - */ - @NotNull - IHub clone(); - - /** - * Captures the transaction and enqueues it for sending to Sentry server. - * - * @param transaction the transaction - * @param traceContext the trace context - * @param hint the hints - * @param profilingTraceData the profiling trace data - * @return transaction's id - */ - @ApiStatus.Internal - @NotNull - SentryId captureTransaction( - @NotNull SentryTransaction transaction, - @Nullable TraceContext traceContext, - @Nullable Hint hint, - @Nullable ProfilingTraceData profilingTraceData); - - /** - * Captures the transaction and enqueues it for sending to Sentry server. - * - * @param transaction the transaction - * @param traceContext the trace context - * @param hint the hints - * @return transaction's id - */ - @ApiStatus.Internal - @NotNull - default SentryId captureTransaction( - @NotNull SentryTransaction transaction, - @Nullable TraceContext traceContext, - @Nullable Hint hint) { - return captureTransaction(transaction, traceContext, hint, null); - } - - @ApiStatus.Internal - @NotNull - default SentryId captureTransaction(@NotNull SentryTransaction transaction, @Nullable Hint hint) { - return captureTransaction(transaction, null, hint); - } - - /** - * Captures the transaction and enqueues it for sending to Sentry server. - * - * @param transaction the transaction - * @param traceContext the trace context - * @return transaction's id - */ - @ApiStatus.Internal - default @NotNull SentryId captureTransaction( - @NotNull SentryTransaction transaction, @Nullable TraceContext traceContext) { - return captureTransaction(transaction, traceContext, null); - } - - /** - * Creates a Transaction and returns the instance. - * - * @param transactionContexts the transaction contexts - * @return created transaction - */ - default @NotNull ITransaction startTransaction(@NotNull TransactionContext transactionContexts) { - return startTransaction(transactionContexts, new TransactionOptions()); - } - - /** - * Creates a Transaction and returns the instance. Based on the {@link - * SentryOptions#getTracesSampleRate()} the decision if transaction is sampled will be taken by - * {@link TracesSampler}. - * - * @param name the transaction name - * @param operation the operation - * @return created transaction - */ - default @NotNull ITransaction startTransaction( - final @NotNull String name, final @NotNull String operation) { - return startTransaction(name, operation, new TransactionOptions()); - } - - /** - * Creates a Transaction and returns the instance. Based on the {@link - * SentryOptions#getTracesSampleRate()} the decision if transaction is sampled will be taken by - * {@link TracesSampler}. - * - * @param name the transaction name - * @param operation the operation - * @param transactionOptions the transaction options - * @return created transaction - */ - default @NotNull ITransaction startTransaction( - final @NotNull String name, - final @NotNull String operation, - final @NotNull TransactionOptions transactionOptions) { - return startTransaction(new TransactionContext(name, operation), transactionOptions); - } - - /** - * Creates a Transaction and returns the instance. Based on the passed transaction context and - * transaction options the decision if transaction is sampled will be taken by {@link - * TracesSampler}. - * - * @param transactionContext the transaction context - * @param transactionOptions the transaction options - * @return created transaction. - */ - @NotNull - ITransaction startTransaction( - final @NotNull TransactionContext transactionContext, - final @NotNull TransactionOptions transactionOptions); - - /** - * Returns the "sentry-trace" header that allows tracing across services. Can also be used in - * <meta> HTML tags. Also see {@link IHub#getBaggage()}. - * - * @deprecated please use {@link IHub#getTraceparent()} instead. - * @return sentry trace header or null - */ - @Deprecated - @Nullable - SentryTraceHeader traceHeaders(); - - /** - * Associates {@link ISpan} and the transaction name with the {@link Throwable}. Used to determine - * in which trace the exception has been thrown in framework integrations. - * - * @param throwable the throwable - * @param span the span context - * @param transactionName the transaction name - */ - @ApiStatus.Internal - void setSpanContext( - @NotNull Throwable throwable, @NotNull ISpan span, @NotNull String transactionName); - - /** - * Gets the current active transaction or span. - * - * @return the active span or null when no active transaction is running - */ - @Nullable - ISpan getSpan(); - - /** - * Returns the transaction. - * - * @return the transaction or null when no active transaction is running. - */ - @ApiStatus.Internal - @Nullable - ITransaction getTransaction(); - - /** - * Gets the {@link SentryOptions} attached to current scope. - * - * @return the options attached to current scope. - */ - @NotNull - SentryOptions getOptions(); - - /** - * Returns if the App has crashed (Process has terminated) during the last run. It only returns - * true or false if offline caching {{@link SentryOptions#getCacheDirPath()} } is set with a valid - * dir. - * - *

If the call to this method is early in the App lifecycle and the SDK could not check if the - * App has crashed in the background, the check is gonna do IO in the calling thread. - * - * @return true if App has crashed, false otherwise, and null if not evaluated yet - */ - @Nullable - Boolean isCrashedLastRun(); - - /** - * Report a screen has been fully loaded. That means all data needed by the UI was loaded. If - * time-to-full-display tracing {{@link SentryOptions#isEnableTimeToFullDisplayTracing()} } is - * disabled this call is ignored. - * - *

This method is safe to be called multiple times. If the time-to-full-display span is already - * finished, this call will be ignored. - */ - void reportFullyDisplayed(); - - /** - * @deprecated See {@link IHub#reportFullyDisplayed()}. - */ - @Deprecated - default void reportFullDisplayed() { - reportFullyDisplayed(); - } - - /** - * Continue a trace based on HTTP header values. If no "sentry-trace" header is provided a random - * trace ID and span ID is created. - * - * @param sentryTrace "sentry-trace" header - * @param baggageHeaders "baggage" headers - * @return a transaction context for starting a transaction or null if performance is disabled - */ - @Nullable - TransactionContext continueTrace( - final @Nullable String sentryTrace, final @Nullable List baggageHeaders); - - /** - * Returns the "sentry-trace" header that allows tracing across services. Can also be used in - * <meta> HTML tags. Also see {@link IHub#getBaggage()}. - * - * @return sentry trace header or null - */ - @Nullable - SentryTraceHeader getTraceparent(); - - /** - * Returns the "baggage" header that allows tracing across services. Can also be used in - * <meta> HTML tags. Also see {@link IHub#getTraceparent()}. - * - * @return baggage header or null - */ - @Nullable - BaggageHeader getBaggage(); - - @ApiStatus.Experimental - @NotNull - SentryId captureCheckIn(final @NotNull CheckIn checkIn); - - @ApiStatus.Internal - @Nullable - RateLimiter getRateLimiter(); - - @ApiStatus.Experimental - @NotNull - MetricsApi metrics(); -} +/** + * SDK API contract which combines a client and scope management + * + * @deprecated please use {@link IScopes} instead + */ +@Deprecated +public interface IHub extends IScopes {} diff --git a/sentry/src/main/java/io/sentry/IScopes.java b/sentry/src/main/java/io/sentry/IScopes.java new file mode 100644 index 0000000000..03662457e4 --- /dev/null +++ b/sentry/src/main/java/io/sentry/IScopes.java @@ -0,0 +1,594 @@ +package io.sentry; + +import io.sentry.metrics.MetricsApi; +import io.sentry.protocol.SentryId; +import io.sentry.protocol.SentryTransaction; +import io.sentry.protocol.User; +import io.sentry.transport.RateLimiter; +import java.util.List; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public interface IScopes { + + /** + * Check if the Hub is enabled/active. + * + * @return true if its enabled or false otherwise. + */ + boolean isEnabled(); + + /** + * Captures the event. + * + * @param event the event + * @param hint SDK specific but provides high level information about the origin of the event + * @return The Id (SentryId object) of the event + */ + @NotNull + SentryId captureEvent(@NotNull SentryEvent event, @Nullable Hint hint); + + /** + * Captures the event. + * + * @param event the event + * @return The Id (SentryId object) of the event + */ + default @NotNull SentryId captureEvent(@NotNull SentryEvent event) { + return captureEvent(event, new Hint()); + } + + /** + * Captures the event. + * + * @param event the event + * @param callback The callback to configure the scope for a single invocation. + * @return The Id (SentryId object) of the event + */ + default @NotNull SentryId captureEvent( + @NotNull SentryEvent event, final @NotNull ScopeCallback callback) { + return captureEvent(event, new Hint(), callback); + } + + /** + * Captures the event. + * + * @param event the event + * @param hint SDK specific but provides high level information about the origin of the event + * @param callback The callback to configure the scope for a single invocation. + * @return The Id (SentryId object) of the event + */ + @NotNull + SentryId captureEvent( + final @NotNull SentryEvent event, + final @Nullable Hint hint, + final @NotNull ScopeCallback callback); + + /** + * Captures the message. + * + * @param message The message to send. + * @return The Id (SentryId object) of the event + */ + default @NotNull SentryId captureMessage(@NotNull String message) { + return captureMessage(message, SentryLevel.INFO); + } + + /** + * Captures the message. + * + * @param message The message to send. + * @param level The message level. + * @return The Id (SentryId object) of the event + */ + @NotNull + SentryId captureMessage(@NotNull String message, @NotNull SentryLevel level); + + /** + * Captures the message. + * + * @param message The message to send. + * @param level The message level. + * @param callback The callback to configure the scope for a single invocation. + * @return The Id (SentryId object) of the event + */ + @NotNull + SentryId captureMessage( + @NotNull String message, @NotNull SentryLevel level, @NotNull ScopeCallback callback); + + /** + * Captures the message. + * + * @param message The message to send. + * @param callback The callback to configure the scope for a single invocation. + * @return The Id (SentryId object) of the event + */ + default @NotNull SentryId captureMessage( + @NotNull String message, @NotNull ScopeCallback callback) { + return captureMessage(message, SentryLevel.INFO, callback); + } + + /** + * Captures an envelope. + * + * @param envelope the SentryEnvelope to send. + * @param hint SDK specific but provides high level information about the origin of the event + * @return The Id (SentryId object) of the event + */ + @NotNull + SentryId captureEnvelope(@NotNull SentryEnvelope envelope, @Nullable Hint hint); + + /** + * Captures an envelope. + * + * @param envelope the SentryEnvelope to send. + * @return The Id (SentryId object) of the event + */ + default @NotNull SentryId captureEnvelope(@NotNull SentryEnvelope envelope) { + return captureEnvelope(envelope, new Hint()); + } + + /** + * Captures the exception. + * + * @param throwable The exception. + * @param hint SDK specific but provides high level information about the origin of the event + * @return The Id (SentryId object) of the event + */ + @NotNull + SentryId captureException(@NotNull Throwable throwable, @Nullable Hint hint); + + /** + * Captures the exception. + * + * @param throwable The exception. + * @return The Id (SentryId object) of the event + */ + default @NotNull SentryId captureException(@NotNull Throwable throwable) { + return captureException(throwable, new Hint()); + } + + /** + * Captures the exception. + * + * @param throwable The exception. + * @param callback The callback to configure the scope for a single invocation. + * @return The Id (SentryId object) of the event + */ + default @NotNull SentryId captureException( + @NotNull Throwable throwable, final @NotNull ScopeCallback callback) { + return captureException(throwable, new Hint(), callback); + } + + /** + * Captures the exception. + * + * @param throwable The exception. + * @param hint SDK specific but provides high level information about the origin of the event + * @param callback The callback to configure the scope for a single invocation. + * @return The Id (SentryId object) of the event + */ + @NotNull + SentryId captureException( + final @NotNull Throwable throwable, + final @Nullable Hint hint, + final @NotNull ScopeCallback callback); + + /** + * Captures a manually created user feedback and sends it to Sentry. + * + * @param userFeedback The user feedback to send to Sentry. + */ + void captureUserFeedback(@NotNull UserFeedback userFeedback); + + /** Starts a new session. If there's a running session, it ends it before starting the new one. */ + void startSession(); + + /** Ends the current session */ + void endSession(); + + /** Flushes out the queue for up to timeout seconds and disable the Hub. */ + void close(); + + /** + * Flushes out the queue for up to timeout seconds and disable the Hub. + * + * @param isRestarting if true, avoids locking the main thread when finishing the queue. + */ + void close(boolean isRestarting); + + /** + * Adds a breadcrumb to the current Scope + * + * @param breadcrumb the breadcrumb + * @param hint SDK specific but provides high level information about the origin of the event + */ + void addBreadcrumb(@NotNull Breadcrumb breadcrumb, @Nullable Hint hint); + + /** + * Adds a breadcrumb to the current Scope + * + * @param breadcrumb the breadcrumb + */ + void addBreadcrumb(@NotNull Breadcrumb breadcrumb); + + /** + * Adds a breadcrumb to the current Scope + * + * @param message rendered as text and the whitespace is preserved. + */ + default void addBreadcrumb(@NotNull String message) { + addBreadcrumb(new Breadcrumb(message)); + } + + /** + * Adds a breadcrumb to the current Scope + * + * @param message rendered as text and the whitespace is preserved. + * @param category Categories are dotted strings that indicate what the crumb is or where it comes + * from. + */ + default void addBreadcrumb(@NotNull String message, @NotNull String category) { + Breadcrumb breadcrumb = new Breadcrumb(message); + breadcrumb.setCategory(category); + addBreadcrumb(breadcrumb); + } + + /** + * Sets the level of all events sent within current Scope + * + * @param level the Sentry level + */ + void setLevel(@Nullable SentryLevel level); + + /** + * Sets the name of the current transaction to the current Scope. + * + * @param transaction the transaction + */ + void setTransaction(@Nullable String transaction); + + /** + * Shallow merges user configuration (email, username, etc) to the current Scope. + * + * @param user the user + */ + void setUser(@Nullable User user); + + /** + * Sets the fingerprint to group specific events together to the current Scope. + * + * @param fingerprint the fingerprints + */ + void setFingerprint(@NotNull List fingerprint); + + /** Deletes current breadcrumbs from the current scope. */ + void clearBreadcrumbs(); + + /** + * Sets the tag to a string value to the current Scope, overwriting a potential previous value + * + * @param key the key + * @param value the value + */ + void setTag(@NotNull String key, @NotNull String value); + + /** + * Removes the tag to a string value to the current Scope + * + * @param key the key + */ + void removeTag(@NotNull String key); + + /** + * Sets the extra key to an arbitrary value to the current Scope, overwriting a potential previous + * value + * + * @param key the key + * @param value the value + */ + void setExtra(@NotNull String key, @NotNull String value); + + /** + * Removes the extra key to an arbitrary value to the current Scope + * + * @param key the key + */ + void removeExtra(@NotNull String key); + + /** + * Last event id recorded in the current scope + * + * @return last SentryId + */ + @NotNull + SentryId getLastEventId(); + + /** Pushes a new scope while inheriting the current scope's data. */ + void pushScope(); + + /** Removes the first scope */ + void popScope(); + + /** + * Runs the callback with a new scope which gets dropped at the end. If you're using the Sentry + * SDK in globalHubMode (defaults to true on Android) {@link + * Sentry#init(Sentry.OptionsConfiguration, boolean)} calling withScope is discouraged, as scope + * changes may be dropped when executed in parallel. Use {@link + * IHub#configureScope(ScopeCallback)} instead. + * + * @param callback the callback + */ + void withScope(@NotNull ScopeCallback callback); + + /** + * Configures the scope through the callback. + * + * @param callback The configure scope callback. + */ + void configureScope(@NotNull ScopeCallback callback); + + /** + * Binds a different client to the hub + * + * @param client the client. + */ + void bindClient(@NotNull ISentryClient client); + + /** + * Whether the transport is healthy. + * + * @return true if the transport is healthy + */ + boolean isHealthy(); + + /** + * Flushes events queued up, but keeps the Hub enabled. Not implemented yet. + * + * @param timeoutMillis time in milliseconds + */ + void flush(long timeoutMillis); + + /** + * Clones the Hub + * + * @return the cloned Hub + */ + @NotNull + @Deprecated + IHub clone(); + + /** + * Captures the transaction and enqueues it for sending to Sentry server. + * + * @param transaction the transaction + * @param traceContext the trace context + * @param hint the hints + * @param profilingTraceData the profiling trace data + * @return transaction's id + */ + @ApiStatus.Internal + @NotNull + SentryId captureTransaction( + @NotNull SentryTransaction transaction, + @Nullable TraceContext traceContext, + @Nullable Hint hint, + @Nullable ProfilingTraceData profilingTraceData); + + /** + * Captures the transaction and enqueues it for sending to Sentry server. + * + * @param transaction the transaction + * @param traceContext the trace context + * @param hint the hints + * @return transaction's id + */ + @ApiStatus.Internal + @NotNull + default SentryId captureTransaction( + @NotNull SentryTransaction transaction, + @Nullable TraceContext traceContext, + @Nullable Hint hint) { + return captureTransaction(transaction, traceContext, hint, null); + } + + @ApiStatus.Internal + @NotNull + default SentryId captureTransaction(@NotNull SentryTransaction transaction, @Nullable Hint hint) { + return captureTransaction(transaction, null, hint); + } + + /** + * Captures the transaction and enqueues it for sending to Sentry server. + * + * @param transaction the transaction + * @param traceContext the trace context + * @return transaction's id + */ + @ApiStatus.Internal + default @NotNull SentryId captureTransaction( + @NotNull SentryTransaction transaction, @Nullable TraceContext traceContext) { + return captureTransaction(transaction, traceContext, null); + } + + /** + * Creates a Transaction and returns the instance. + * + * @param transactionContexts the transaction contexts + * @return created transaction + */ + default @NotNull ITransaction startTransaction(@NotNull TransactionContext transactionContexts) { + return startTransaction(transactionContexts, new TransactionOptions()); + } + + /** + * Creates a Transaction and returns the instance. Based on the {@link + * SentryOptions#getTracesSampleRate()} the decision if transaction is sampled will be taken by + * {@link TracesSampler}. + * + * @param name the transaction name + * @param operation the operation + * @return created transaction + */ + default @NotNull ITransaction startTransaction( + final @NotNull String name, final @NotNull String operation) { + return startTransaction(name, operation, new TransactionOptions()); + } + + /** + * Creates a Transaction and returns the instance. Based on the {@link + * SentryOptions#getTracesSampleRate()} the decision if transaction is sampled will be taken by + * {@link TracesSampler}. + * + * @param name the transaction name + * @param operation the operation + * @param transactionOptions the transaction options + * @return created transaction + */ + default @NotNull ITransaction startTransaction( + final @NotNull String name, + final @NotNull String operation, + final @NotNull TransactionOptions transactionOptions) { + return startTransaction(new TransactionContext(name, operation), transactionOptions); + } + + /** + * Creates a Transaction and returns the instance. Based on the passed transaction context and + * transaction options the decision if transaction is sampled will be taken by {@link + * TracesSampler}. + * + * @param transactionContext the transaction context + * @param transactionOptions the transaction options + * @return created transaction. + */ + @NotNull + ITransaction startTransaction( + final @NotNull TransactionContext transactionContext, + final @NotNull TransactionOptions transactionOptions); + + /** + * Returns the "sentry-trace" header that allows tracing across services. Can also be used in + * <meta> HTML tags. Also see {@link IHub#getBaggage()}. + * + * @deprecated please use {@link IHub#getTraceparent()} instead. + * @return sentry trace header or null + */ + @Deprecated + @Nullable + SentryTraceHeader traceHeaders(); + + /** + * Associates {@link ISpan} and the transaction name with the {@link Throwable}. Used to determine + * in which trace the exception has been thrown in framework integrations. + * + * @param throwable the throwable + * @param span the span context + * @param transactionName the transaction name + */ + @ApiStatus.Internal + void setSpanContext( + @NotNull Throwable throwable, @NotNull ISpan span, @NotNull String transactionName); + + /** + * Gets the current active transaction or span. + * + * @return the active span or null when no active transaction is running + */ + @Nullable + ISpan getSpan(); + + /** + * Returns the transaction. + * + * @return the transaction or null when no active transaction is running. + */ + @ApiStatus.Internal + @Nullable + ITransaction getTransaction(); + + /** + * Gets the {@link SentryOptions} attached to current scope. + * + * @return the options attached to current scope. + */ + @NotNull + SentryOptions getOptions(); + + /** + * Returns if the App has crashed (Process has terminated) during the last run. It only returns + * true or false if offline caching {{@link SentryOptions#getCacheDirPath()} } is set with a valid + * dir. + * + *

If the call to this method is early in the App lifecycle and the SDK could not check if the + * App has crashed in the background, the check is gonna do IO in the calling thread. + * + * @return true if App has crashed, false otherwise, and null if not evaluated yet + */ + @Nullable + Boolean isCrashedLastRun(); + + /** + * Report a screen has been fully loaded. That means all data needed by the UI was loaded. If + * time-to-full-display tracing {{@link SentryOptions#isEnableTimeToFullDisplayTracing()} } is + * disabled this call is ignored. + * + *

This method is safe to be called multiple times. If the time-to-full-display span is already + * finished, this call will be ignored. + */ + void reportFullyDisplayed(); + + /** + * @deprecated See {@link IHub#reportFullyDisplayed()}. + */ + @Deprecated + default void reportFullDisplayed() { + reportFullyDisplayed(); + } + + /** + * Continue a trace based on HTTP header values. If no "sentry-trace" header is provided a random + * trace ID and span ID is created. + * + * @param sentryTrace "sentry-trace" header + * @param baggageHeaders "baggage" headers + * @return a transaction context for starting a transaction or null if performance is disabled + */ + @Nullable + TransactionContext continueTrace( + final @Nullable String sentryTrace, final @Nullable List baggageHeaders); + + /** + * Returns the "sentry-trace" header that allows tracing across services. Can also be used in + * <meta> HTML tags. Also see {@link IHub#getBaggage()}. + * + * @return sentry trace header or null + */ + @Nullable + SentryTraceHeader getTraceparent(); + + /** + * Returns the "baggage" header that allows tracing across services. Can also be used in + * <meta> HTML tags. Also see {@link IHub#getTraceparent()}. + * + * @return baggage header or null + */ + @Nullable + BaggageHeader getBaggage(); + + @ApiStatus.Experimental + @NotNull + SentryId captureCheckIn(final @NotNull CheckIn checkIn); + + @ApiStatus.Internal + @Nullable + RateLimiter getRateLimiter(); + + @ApiStatus.Experimental + @NotNull + MetricsApi metrics(); + + default boolean isNoOp() { + return false; + } +} diff --git a/sentry/src/main/java/io/sentry/NoOpHub.java b/sentry/src/main/java/io/sentry/NoOpHub.java index e51cea8d2d..704bd2b44a 100644 --- a/sentry/src/main/java/io/sentry/NoOpHub.java +++ b/sentry/src/main/java/io/sentry/NoOpHub.java @@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +@Deprecated public final class NoOpHub implements IHub { private static final NoOpHub instance = new NoOpHub(); @@ -21,6 +22,7 @@ public final class NoOpHub implements IHub { private NoOpHub() {} + @Deprecated public static NoOpHub getInstance() { return instance; } @@ -234,4 +236,9 @@ public void reportFullyDisplayed() {} public @NotNull MetricsApi metrics() { return metricsApi; } + + @Override + public boolean isNoOp() { + return true; + } } diff --git a/sentry/src/main/java/io/sentry/NoOpScopes.java b/sentry/src/main/java/io/sentry/NoOpScopes.java new file mode 100644 index 0000000000..6fef262944 --- /dev/null +++ b/sentry/src/main/java/io/sentry/NoOpScopes.java @@ -0,0 +1,243 @@ +package io.sentry; + +import io.sentry.metrics.MetricsApi; +import io.sentry.metrics.NoopMetricsAggregator; +import io.sentry.protocol.SentryId; +import io.sentry.protocol.SentryTransaction; +import io.sentry.protocol.User; +import io.sentry.transport.RateLimiter; +import java.util.List; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public final class NoOpScopes implements IScopes { + + private static final NoOpScopes instance = new NoOpScopes(); + + private final @NotNull SentryOptions emptyOptions = SentryOptions.empty(); + private final @NotNull MetricsApi metricsApi = + new MetricsApi(NoopMetricsAggregator.getInstance()); + + private NoOpScopes() {} + + public static NoOpScopes getInstance() { + return instance; + } + + @Override + public boolean isEnabled() { + return false; + } + + @Override + public @NotNull SentryId captureEvent(@NotNull SentryEvent event, @Nullable Hint hint) { + return SentryId.EMPTY_ID; + } + + @Override + public @NotNull SentryId captureEvent( + @NotNull SentryEvent event, @Nullable Hint hint, @NotNull ScopeCallback callback) { + return SentryId.EMPTY_ID; + } + + @Override + public @NotNull SentryId captureMessage(@NotNull String message, @NotNull SentryLevel level) { + return SentryId.EMPTY_ID; + } + + @Override + public @NotNull SentryId captureMessage( + @NotNull String message, @NotNull SentryLevel level, @NotNull ScopeCallback callback) { + return SentryId.EMPTY_ID; + } + + @Override + public @NotNull SentryId captureEnvelope(@NotNull SentryEnvelope envelope, @Nullable Hint hint) { + return SentryId.EMPTY_ID; + } + + @Override + public @NotNull SentryId captureException(@NotNull Throwable throwable, @Nullable Hint hint) { + return SentryId.EMPTY_ID; + } + + @Override + public @NotNull SentryId captureException( + @NotNull Throwable throwable, @Nullable Hint hint, @NotNull ScopeCallback callback) { + return SentryId.EMPTY_ID; + } + + @Override + public void captureUserFeedback(@NotNull UserFeedback userFeedback) {} + + @Override + public void startSession() {} + + @Override + public void endSession() {} + + @Override + public void close() {} + + @Override + public void close(final boolean isRestarting) {} + + @Override + public void addBreadcrumb(@NotNull Breadcrumb breadcrumb, @Nullable Hint hint) {} + + @Override + public void addBreadcrumb(final @NotNull Breadcrumb breadcrumb) {} + + @Override + public void setLevel(@Nullable SentryLevel level) {} + + @Override + public void setTransaction(@Nullable String transaction) {} + + @Override + public void setUser(@Nullable User user) {} + + @Override + public void setFingerprint(@NotNull List fingerprint) {} + + @Override + public void clearBreadcrumbs() {} + + @Override + public void setTag(@NotNull String key, @NotNull String value) {} + + @Override + public void removeTag(@NotNull String key) {} + + @Override + public void setExtra(@NotNull String key, @NotNull String value) {} + + @Override + public void removeExtra(@NotNull String key) {} + + @Override + public @NotNull SentryId getLastEventId() { + return SentryId.EMPTY_ID; + } + + @Override + public void pushScope() {} + + @Override + public void popScope() {} + + @Override + public void withScope(@NotNull ScopeCallback callback) { + callback.run(NoOpScope.getInstance()); + } + + @Override + public void configureScope(@NotNull ScopeCallback callback) {} + + @Override + public void bindClient(@NotNull ISentryClient client) {} + + @Override + public boolean isHealthy() { + return true; + } + + @Override + public void flush(long timeoutMillis) {} + + @Deprecated + @Override + public @NotNull IHub clone() { + return NoOpHub.getInstance(); + } + + @Override + public @NotNull SentryId captureTransaction( + final @NotNull SentryTransaction transaction, + final @Nullable TraceContext traceContext, + final @Nullable Hint hint, + final @Nullable ProfilingTraceData profilingTraceData) { + return SentryId.EMPTY_ID; + } + + @Override + public @NotNull ITransaction startTransaction( + @NotNull TransactionContext transactionContext, + @NotNull TransactionOptions transactionOptions) { + return NoOpTransaction.getInstance(); + } + + @Override + @Deprecated + @SuppressWarnings("InlineMeSuggester") + public @NotNull SentryTraceHeader traceHeaders() { + return new SentryTraceHeader(SentryId.EMPTY_ID, SpanId.EMPTY_ID, true); + } + + @Override + public void setSpanContext( + final @NotNull Throwable throwable, + final @NotNull ISpan spanContext, + final @NotNull String transactionName) {} + + @Override + public @Nullable ISpan getSpan() { + return null; + } + + @Override + public @Nullable ITransaction getTransaction() { + return null; + } + + @Override + public @NotNull SentryOptions getOptions() { + return emptyOptions; + } + + @Override + public @Nullable Boolean isCrashedLastRun() { + return null; + } + + @Override + public void reportFullyDisplayed() {} + + @Override + public @Nullable TransactionContext continueTrace( + final @Nullable String sentryTrace, final @Nullable List baggageHeaders) { + return null; + } + + @Override + public @Nullable SentryTraceHeader getTraceparent() { + return null; + } + + @Override + public @Nullable BaggageHeader getBaggage() { + return null; + } + + @Override + @ApiStatus.Experimental + public @NotNull SentryId captureCheckIn(final @NotNull CheckIn checkIn) { + return SentryId.EMPTY_ID; + } + + @Override + public @Nullable RateLimiter getRateLimiter() { + return null; + } + + @Override + public @NotNull MetricsApi metrics() { + return metricsApi; + } + + @Override + public boolean isNoOp() { + return true; + } +} diff --git a/sentry/src/main/java/io/sentry/ScopesAdapter.java b/sentry/src/main/java/io/sentry/ScopesAdapter.java new file mode 100644 index 0000000000..1ecd31e248 --- /dev/null +++ b/sentry/src/main/java/io/sentry/ScopesAdapter.java @@ -0,0 +1,286 @@ +package io.sentry; + +import io.sentry.metrics.MetricsApi; +import io.sentry.protocol.SentryId; +import io.sentry.protocol.SentryTransaction; +import io.sentry.protocol.User; +import io.sentry.transport.RateLimiter; +import java.util.List; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public final class ScopesAdapter implements IScopes { + + private static final ScopesAdapter INSTANCE = new ScopesAdapter(); + + private ScopesAdapter() {} + + public static ScopesAdapter getInstance() { + return INSTANCE; + } + + @Override + public boolean isEnabled() { + return Sentry.isEnabled(); + } + + @Override + public @NotNull SentryId captureEvent(@NotNull SentryEvent event, @Nullable Hint hint) { + return Sentry.captureEvent(event, hint); + } + + @Override + public @NotNull SentryId captureEvent( + @NotNull SentryEvent event, @Nullable Hint hint, @NotNull ScopeCallback callback) { + return Sentry.captureEvent(event, hint, callback); + } + + @Override + public @NotNull SentryId captureMessage(@NotNull String message, @NotNull SentryLevel level) { + return Sentry.captureMessage(message, level); + } + + @Override + public @NotNull SentryId captureMessage( + @NotNull String message, @NotNull SentryLevel level, @NotNull ScopeCallback callback) { + return Sentry.captureMessage(message, level, callback); + } + + @ApiStatus.Internal + @Override + public @NotNull SentryId captureEnvelope(@NotNull SentryEnvelope envelope, @Nullable Hint hint) { + return Sentry.getCurrentScopes().captureEnvelope(envelope, hint); + } + + @Override + public @NotNull SentryId captureException(@NotNull Throwable throwable, @Nullable Hint hint) { + return Sentry.captureException(throwable, hint); + } + + @Override + public @NotNull SentryId captureException( + @NotNull Throwable throwable, @Nullable Hint hint, @NotNull ScopeCallback callback) { + return Sentry.captureException(throwable, hint, callback); + } + + @Override + public void captureUserFeedback(@NotNull UserFeedback userFeedback) { + Sentry.captureUserFeedback(userFeedback); + } + + @Override + public void startSession() { + Sentry.startSession(); + } + + @Override + public void endSession() { + Sentry.endSession(); + } + + @Override + public void close(final boolean isRestarting) { + Sentry.close(); + } + + @Override + public void close() { + Sentry.close(); + } + + @Override + public void addBreadcrumb(@NotNull Breadcrumb breadcrumb, @Nullable Hint hint) { + Sentry.addBreadcrumb(breadcrumb, hint); + } + + @Override + public void addBreadcrumb(final @NotNull Breadcrumb breadcrumb) { + addBreadcrumb(breadcrumb, new Hint()); + } + + @Override + public void setLevel(@Nullable SentryLevel level) { + Sentry.setLevel(level); + } + + @Override + public void setTransaction(@Nullable String transaction) { + Sentry.setTransaction(transaction); + } + + @Override + public void setUser(@Nullable User user) { + Sentry.setUser(user); + } + + @Override + public void setFingerprint(@NotNull List fingerprint) { + Sentry.setFingerprint(fingerprint); + } + + @Override + public void clearBreadcrumbs() { + Sentry.clearBreadcrumbs(); + } + + @Override + public void setTag(@NotNull String key, @NotNull String value) { + Sentry.setTag(key, value); + } + + @Override + public void removeTag(@NotNull String key) { + Sentry.removeTag(key); + } + + @Override + public void setExtra(@NotNull String key, @NotNull String value) { + Sentry.setExtra(key, value); + } + + @Override + public void removeExtra(@NotNull String key) { + Sentry.removeExtra(key); + } + + @Override + public @NotNull SentryId getLastEventId() { + return Sentry.getLastEventId(); + } + + @Override + public void pushScope() { + Sentry.pushScope(); + } + + @Override + public void popScope() { + Sentry.popScope(); + } + + @Override + public void withScope(@NotNull ScopeCallback callback) { + Sentry.withScope(callback); + } + + @Override + public void configureScope(@NotNull ScopeCallback callback) { + Sentry.configureScope(callback); + } + + @Override + public void bindClient(@NotNull ISentryClient client) { + Sentry.bindClient(client); + } + + @Override + public boolean isHealthy() { + return Sentry.isHealthy(); + } + + @Override + public void flush(long timeoutMillis) { + Sentry.flush(timeoutMillis); + } + + @Override + @SuppressWarnings("deprecation") + public @NotNull IHub clone() { + return Sentry.getCurrentScopes().clone(); + } + + @ApiStatus.Internal + @Override + public @NotNull SentryId captureTransaction( + @NotNull SentryTransaction transaction, + @Nullable TraceContext traceContext, + @Nullable Hint hint, + @Nullable ProfilingTraceData profilingTraceData) { + return Sentry.getCurrentScopes() + .captureTransaction(transaction, traceContext, hint, profilingTraceData); + } + + @Override + public @NotNull ITransaction startTransaction( + @NotNull TransactionContext transactionContext, + @NotNull TransactionOptions transactionOptions) { + return Sentry.startTransaction(transactionContext, transactionOptions); + } + + @Deprecated + @Override + @SuppressWarnings("deprecation") + public @Nullable SentryTraceHeader traceHeaders() { + return Sentry.traceHeaders(); + } + + @ApiStatus.Internal + @Override + public void setSpanContext( + final @NotNull Throwable throwable, + final @NotNull ISpan span, + final @NotNull String transactionName) { + Sentry.getCurrentScopes().setSpanContext(throwable, span, transactionName); + } + + @Override + public @Nullable ISpan getSpan() { + return Sentry.getCurrentScopes().getSpan(); + } + + @Override + @ApiStatus.Internal + public @Nullable ITransaction getTransaction() { + return Sentry.getCurrentScopes().getTransaction(); + } + + @Override + public @NotNull SentryOptions getOptions() { + return Sentry.getCurrentScopes().getOptions(); + } + + @Override + public @Nullable Boolean isCrashedLastRun() { + return Sentry.isCrashedLastRun(); + } + + @Override + public void reportFullyDisplayed() { + Sentry.reportFullyDisplayed(); + } + + @Override + public @Nullable TransactionContext continueTrace( + final @Nullable String sentryTrace, final @Nullable List baggageHeaders) { + return Sentry.continueTrace(sentryTrace, baggageHeaders); + } + + @Override + public @Nullable SentryTraceHeader getTraceparent() { + return Sentry.getTraceparent(); + } + + @Override + public @Nullable BaggageHeader getBaggage() { + return Sentry.getBaggage(); + } + + @Override + @ApiStatus.Experimental + public @NotNull SentryId captureCheckIn(final @NotNull CheckIn checkIn) { + return Sentry.captureCheckIn(checkIn); + } + + @ApiStatus.Internal + @Override + public @Nullable RateLimiter getRateLimiter() { + return Sentry.getCurrentScopes().getRateLimiter(); + } + + @ApiStatus.Experimental + @Override + public @NotNull MetricsApi metrics() { + return Sentry.getCurrentScopes().metrics(); + } +} diff --git a/sentry/src/main/java/io/sentry/Sentry.java b/sentry/src/main/java/io/sentry/Sentry.java index 5196d0f31a..206ffd8d20 100644 --- a/sentry/src/main/java/io/sentry/Sentry.java +++ b/sentry/src/main/java/io/sentry/Sentry.java @@ -43,11 +43,11 @@ public final class Sentry { private Sentry() {} - /** Holds Hubs per thread or only mainHub if globalHubMode is enabled. */ - private static final @NotNull ThreadLocal currentHub = new ThreadLocal<>(); + /** Holds Hubs per thread or only mainScopes if globalHubMode is enabled. */ + private static final @NotNull ThreadLocal currentScopes = new ThreadLocal<>(); /** The Main Hub or NoOp if Sentry is disabled. */ - private static volatile @NotNull IHub mainHub = NoOpHub.getInstance(); + private static volatile @NotNull IScopes mainScopes = NoOpScopes.getInstance(); /** Default value for globalHubMode is false */ private static final boolean GLOBAL_HUB_DEFAULT_MODE = false; @@ -66,40 +66,58 @@ private Sentry() {} private static final long classCreationTimestamp = System.currentTimeMillis(); /** - * Returns the current (threads) hub, if none, clones the mainHub and returns it. + * Returns the current (threads) hub, if none, clones the mainScopes and returns it. * * @return the hub */ @ApiStatus.Internal // exposed for the coroutines integration in SentryContext + @SuppressWarnings("deprecation") + @Deprecated public static @NotNull IHub getCurrentHub() { + return new HubScopesWrapper(getCurrentScopes()); + } + + @ApiStatus.Internal // exposed for the coroutines integration in SentryContext + @SuppressWarnings("deprecation") + public static @NotNull IScopes getCurrentScopes() { if (globalHubMode) { - return mainHub; + return mainScopes; } - IHub hub = currentHub.get(); - if (hub == null || hub instanceof NoOpHub) { - hub = mainHub.clone(); - currentHub.set(hub); + IScopes hub = currentScopes.get(); + if (hub == null || hub.isNoOp()) { + // TODO fork instead + hub = mainScopes.clone(); + currentScopes.set(hub); } return hub; } /** - * Returns a new hub which is cloned from the mainHub. + * Returns a new hub which is cloned from the mainScopes. * * @return the hub */ @ApiStatus.Internal @ApiStatus.Experimental - public static @NotNull IHub cloneMainHub() { + @SuppressWarnings("deprecation") + public static @NotNull IScopes cloneMainHub() { if (globalHubMode) { - return mainHub; + return mainScopes; } - return mainHub.clone(); + // TODO fork instead + return mainScopes.clone(); } @ApiStatus.Internal // exposed for the coroutines integration in SentryContext + @Deprecated + @SuppressWarnings("deprecation") public static void setCurrentHub(final @NotNull IHub hub) { - currentHub.set(hub); + currentScopes.set(hub); + } + + @ApiStatus.Internal // exposed for the coroutines integration in SentryContext + public static void setCurrentScopes(final @NotNull IScopes scopes) { + currentScopes.set(scopes); } /** @@ -108,7 +126,7 @@ public static void setCurrentHub(final @NotNull IHub hub) { * @return true if its enabled or false otherwise. */ public static boolean isEnabled() { - return getCurrentHub().isEnabled(); + return getCurrentScopes().isEnabled(); } /** Initializes the SDK */ @@ -217,6 +235,7 @@ public static void init(final @NotNull SentryOptions options) { * @param options options the SentryOptions * @param globalHubMode the globalHubMode */ + @SuppressWarnings("deprecation") private static synchronized void init( final @NotNull SentryOptions options, final boolean globalHubMode) { if (isEnabled()) { @@ -234,10 +253,11 @@ private static synchronized void init( options.getLogger().log(SentryLevel.INFO, "GlobalHubMode: '%s'", String.valueOf(globalHubMode)); Sentry.globalHubMode = globalHubMode; - final IHub hub = getCurrentHub(); - mainHub = new Hub(options); + final IScopes hub = getCurrentScopes(); + // TODO new Scopes() + mainScopes = new Hub(options); - currentHub.set(mainHub); + currentScopes.set(mainScopes); hub.close(true); @@ -252,12 +272,12 @@ private static synchronized void init( // and hub was still NoOp. // Registering integrations here make sure that Hub is already created. for (final Integration integration : options.getIntegrations()) { - integration.register(HubAdapter.getInstance(), options); + integration.register(ScopesAdapter.getInstance(), options); } notifyOptionsObservers(options); - finalizePreviousSession(options, HubAdapter.getInstance()); + finalizePreviousSession(options, ScopesAdapter.getInstance()); handleAppStartProfilingConfig(options, options.getExecutorService()); } @@ -327,12 +347,12 @@ private static void handleAppStartProfilingConfig( @SuppressWarnings("FutureReturnValueIgnored") private static void finalizePreviousSession( - final @NotNull SentryOptions options, final @NotNull IHub hub) { + final @NotNull SentryOptions options, final @NotNull IScopes scopes) { // enqueue a task to finalize previous session. Since the executor // is single-threaded, this task will be enqueued sequentially after all integrations that have // to modify the previous session have done their work, even if they do that async. try { - options.getExecutorService().submit(new PreviousSessionFinalizer(options, hub)); + options.getExecutorService().submit(new PreviousSessionFinalizer(options, scopes)); } catch (Throwable e) { options.getLogger().log(SentryLevel.DEBUG, "Failed to finalize previous session.", e); } @@ -475,7 +495,7 @@ private static boolean initConfigurations(final @NotNull SentryOptions options) } if (options.isEnableBackpressureHandling()) { - options.setBackpressureMonitor(new BackpressureMonitor(options, HubAdapter.getInstance())); + options.setBackpressureMonitor(new BackpressureMonitor(options, ScopesAdapter.getInstance())); options.getBackpressureMonitor().start(); } @@ -484,11 +504,11 @@ private static boolean initConfigurations(final @NotNull SentryOptions options) /** Close the SDK */ public static synchronized void close() { - final IHub hub = getCurrentHub(); - mainHub = NoOpHub.getInstance(); + final IScopes scopes = getCurrentScopes(); + mainScopes = NoOpScopes.getInstance(); // remove thread local to avoid memory leak - currentHub.remove(); - hub.close(false); + currentScopes.remove(); + scopes.close(false); } /** @@ -498,7 +518,7 @@ public static synchronized void close() { * @return The Id (SentryId object) of the event */ public static @NotNull SentryId captureEvent(final @NotNull SentryEvent event) { - return getCurrentHub().captureEvent(event); + return getCurrentScopes().captureEvent(event); } /** @@ -510,7 +530,7 @@ public static synchronized void close() { */ public static @NotNull SentryId captureEvent( final @NotNull SentryEvent event, final @NotNull ScopeCallback callback) { - return getCurrentHub().captureEvent(event, callback); + return getCurrentScopes().captureEvent(event, callback); } /** @@ -522,7 +542,7 @@ public static synchronized void close() { */ public static @NotNull SentryId captureEvent( final @NotNull SentryEvent event, final @Nullable Hint hint) { - return getCurrentHub().captureEvent(event, hint); + return getCurrentScopes().captureEvent(event, hint); } /** @@ -537,7 +557,7 @@ public static synchronized void close() { final @NotNull SentryEvent event, final @Nullable Hint hint, final @NotNull ScopeCallback callback) { - return getCurrentHub().captureEvent(event, hint, callback); + return getCurrentScopes().captureEvent(event, hint, callback); } /** @@ -547,7 +567,7 @@ public static synchronized void close() { * @return The Id (SentryId object) of the event */ public static @NotNull SentryId captureMessage(final @NotNull String message) { - return getCurrentHub().captureMessage(message); + return getCurrentScopes().captureMessage(message); } /** @@ -559,7 +579,7 @@ public static synchronized void close() { */ public static @NotNull SentryId captureMessage( final @NotNull String message, final @NotNull ScopeCallback callback) { - return getCurrentHub().captureMessage(message, callback); + return getCurrentScopes().captureMessage(message, callback); } /** @@ -571,7 +591,7 @@ public static synchronized void close() { */ public static @NotNull SentryId captureMessage( final @NotNull String message, final @NotNull SentryLevel level) { - return getCurrentHub().captureMessage(message, level); + return getCurrentScopes().captureMessage(message, level); } /** @@ -586,7 +606,7 @@ public static synchronized void close() { final @NotNull String message, final @NotNull SentryLevel level, final @NotNull ScopeCallback callback) { - return getCurrentHub().captureMessage(message, level, callback); + return getCurrentScopes().captureMessage(message, level, callback); } /** @@ -596,7 +616,7 @@ public static synchronized void close() { * @return The Id (SentryId object) of the event */ public static @NotNull SentryId captureException(final @NotNull Throwable throwable) { - return getCurrentHub().captureException(throwable); + return getCurrentScopes().captureException(throwable); } /** @@ -608,7 +628,7 @@ public static synchronized void close() { */ public static @NotNull SentryId captureException( final @NotNull Throwable throwable, final @NotNull ScopeCallback callback) { - return getCurrentHub().captureException(throwable, callback); + return getCurrentScopes().captureException(throwable, callback); } /** @@ -620,7 +640,7 @@ public static synchronized void close() { */ public static @NotNull SentryId captureException( final @NotNull Throwable throwable, final @Nullable Hint hint) { - return getCurrentHub().captureException(throwable, hint); + return getCurrentScopes().captureException(throwable, hint); } /** @@ -635,7 +655,7 @@ public static synchronized void close() { final @NotNull Throwable throwable, final @Nullable Hint hint, final @NotNull ScopeCallback callback) { - return getCurrentHub().captureException(throwable, hint, callback); + return getCurrentScopes().captureException(throwable, hint, callback); } /** @@ -644,7 +664,7 @@ public static synchronized void close() { * @param userFeedback The user feedback to send to Sentry. */ public static void captureUserFeedback(final @NotNull UserFeedback userFeedback) { - getCurrentHub().captureUserFeedback(userFeedback); + getCurrentScopes().captureUserFeedback(userFeedback); } /** @@ -655,7 +675,7 @@ public static void captureUserFeedback(final @NotNull UserFeedback userFeedback) */ public static void addBreadcrumb( final @NotNull Breadcrumb breadcrumb, final @Nullable Hint hint) { - getCurrentHub().addBreadcrumb(breadcrumb, hint); + getCurrentScopes().addBreadcrumb(breadcrumb, hint); } /** @@ -664,7 +684,7 @@ public static void addBreadcrumb( * @param breadcrumb the breadcrumb */ public static void addBreadcrumb(final @NotNull Breadcrumb breadcrumb) { - getCurrentHub().addBreadcrumb(breadcrumb); + getCurrentScopes().addBreadcrumb(breadcrumb); } /** @@ -673,7 +693,7 @@ public static void addBreadcrumb(final @NotNull Breadcrumb breadcrumb) { * @param message rendered as text and the whitespace is preserved. */ public static void addBreadcrumb(final @NotNull String message) { - getCurrentHub().addBreadcrumb(message); + getCurrentScopes().addBreadcrumb(message); } /** @@ -684,7 +704,7 @@ public static void addBreadcrumb(final @NotNull String message) { * from. */ public static void addBreadcrumb(final @NotNull String message, final @NotNull String category) { - getCurrentHub().addBreadcrumb(message, category); + getCurrentScopes().addBreadcrumb(message, category); } /** @@ -693,7 +713,7 @@ public static void addBreadcrumb(final @NotNull String message, final @NotNull S * @param level the Sentry level */ public static void setLevel(final @Nullable SentryLevel level) { - getCurrentHub().setLevel(level); + getCurrentScopes().setLevel(level); } /** @@ -702,7 +722,7 @@ public static void setLevel(final @Nullable SentryLevel level) { * @param transaction the transaction */ public static void setTransaction(final @Nullable String transaction) { - getCurrentHub().setTransaction(transaction); + getCurrentScopes().setTransaction(transaction); } /** @@ -711,7 +731,7 @@ public static void setTransaction(final @Nullable String transaction) { * @param user the user */ public static void setUser(final @Nullable User user) { - getCurrentHub().setUser(user); + getCurrentScopes().setUser(user); } /** @@ -720,12 +740,12 @@ public static void setUser(final @Nullable User user) { * @param fingerprint the fingerprints */ public static void setFingerprint(final @NotNull List fingerprint) { - getCurrentHub().setFingerprint(fingerprint); + getCurrentScopes().setFingerprint(fingerprint); } /** Deletes current breadcrumbs from the current scope. */ public static void clearBreadcrumbs() { - getCurrentHub().clearBreadcrumbs(); + getCurrentScopes().clearBreadcrumbs(); } /** @@ -735,7 +755,7 @@ public static void clearBreadcrumbs() { * @param value the value */ public static void setTag(final @NotNull String key, final @NotNull String value) { - getCurrentHub().setTag(key, value); + getCurrentScopes().setTag(key, value); } /** @@ -744,7 +764,7 @@ public static void setTag(final @NotNull String key, final @NotNull String value * @param key the key */ public static void removeTag(final @NotNull String key) { - getCurrentHub().removeTag(key); + getCurrentScopes().removeTag(key); } /** @@ -755,7 +775,7 @@ public static void removeTag(final @NotNull String key) { * @param value the value */ public static void setExtra(final @NotNull String key, final @NotNull String value) { - getCurrentHub().setExtra(key, value); + getCurrentScopes().setExtra(key, value); } /** @@ -764,7 +784,7 @@ public static void setExtra(final @NotNull String key, final @NotNull String val * @param key the key */ public static void removeExtra(final @NotNull String key) { - getCurrentHub().removeExtra(key); + getCurrentScopes().removeExtra(key); } /** @@ -773,14 +793,14 @@ public static void removeExtra(final @NotNull String key) { * @return last SentryId */ public static @NotNull SentryId getLastEventId() { - return getCurrentHub().getLastEventId(); + return getCurrentScopes().getLastEventId(); } /** Pushes a new scope while inheriting the current scope's data. */ public static void pushScope() { // pushScope is no-op in global hub mode if (!globalHubMode) { - getCurrentHub().pushScope(); + getCurrentScopes().pushScope(); } } @@ -788,7 +808,7 @@ public static void pushScope() { public static void popScope() { // popScope is no-op in global hub mode if (!globalHubMode) { - getCurrentHub().popScope(); + getCurrentScopes().popScope(); } } @@ -798,7 +818,7 @@ public static void popScope() { * @param callback the callback */ public static void withScope(final @NotNull ScopeCallback callback) { - getCurrentHub().withScope(callback); + getCurrentScopes().withScope(callback); } /** @@ -807,7 +827,7 @@ public static void withScope(final @NotNull ScopeCallback callback) { * @param callback The configure scope callback. */ public static void configureScope(final @NotNull ScopeCallback callback) { - getCurrentHub().configureScope(callback); + getCurrentScopes().configureScope(callback); } /** @@ -816,11 +836,11 @@ public static void configureScope(final @NotNull ScopeCallback callback) { * @param client the client. */ public static void bindClient(final @NotNull ISentryClient client) { - getCurrentHub().bindClient(client); + getCurrentScopes().bindClient(client); } public static boolean isHealthy() { - return getCurrentHub().isHealthy(); + return getCurrentScopes().isHealthy(); } /** @@ -829,17 +849,17 @@ public static boolean isHealthy() { * @param timeoutMillis time in milliseconds */ public static void flush(final long timeoutMillis) { - getCurrentHub().flush(timeoutMillis); + getCurrentScopes().flush(timeoutMillis); } /** Starts a new session. If there's a running session, it ends it before starting the new one. */ public static void startSession() { - getCurrentHub().startSession(); + getCurrentScopes().startSession(); } /** Ends the current session */ public static void endSession() { - getCurrentHub().endSession(); + getCurrentScopes().endSession(); } /** @@ -851,7 +871,7 @@ public static void endSession() { */ public static @NotNull ITransaction startTransaction( final @NotNull String name, final @NotNull String operation) { - return getCurrentHub().startTransaction(name, operation); + return getCurrentScopes().startTransaction(name, operation); } /** @@ -866,7 +886,7 @@ public static void endSession() { final @NotNull String name, final @NotNull String operation, final @NotNull TransactionOptions transactionOptions) { - return getCurrentHub().startTransaction(name, operation, transactionOptions); + return getCurrentScopes().startTransaction(name, operation, transactionOptions); } /** @@ -884,7 +904,7 @@ public static void endSession() { final @Nullable String description, final @NotNull TransactionOptions transactionOptions) { final ITransaction transaction = - getCurrentHub().startTransaction(name, operation, transactionOptions); + getCurrentScopes().startTransaction(name, operation, transactionOptions); transaction.setDescription(description); return transaction; } @@ -897,7 +917,7 @@ public static void endSession() { */ public static @NotNull ITransaction startTransaction( final @NotNull TransactionContext transactionContexts) { - return getCurrentHub().startTransaction(transactionContexts); + return getCurrentScopes().startTransaction(transactionContexts); } /** @@ -910,7 +930,7 @@ public static void endSession() { public static @NotNull ITransaction startTransaction( final @NotNull TransactionContext transactionContext, final @NotNull TransactionOptions transactionOptions) { - return getCurrentHub().startTransaction(transactionContext, transactionOptions); + return getCurrentScopes().startTransaction(transactionContext, transactionOptions); } /** @@ -923,7 +943,7 @@ public static void endSession() { @Deprecated @SuppressWarnings("InlineMeSuggester") public static @Nullable SentryTraceHeader traceHeaders() { - return getCurrentHub().traceHeaders(); + return getCurrentScopes().traceHeaders(); } /** @@ -935,9 +955,9 @@ public static void endSession() { */ public static @Nullable ISpan getSpan() { if (globalHubMode && Platform.isAndroid()) { - return getCurrentHub().getTransaction(); + return getCurrentScopes().getTransaction(); } else { - return getCurrentHub().getSpan(); + return getCurrentScopes().getSpan(); } } @@ -952,7 +972,7 @@ public static void endSession() { * @return true if App has crashed, false otherwise, and null if not evaluated yet */ public static @Nullable Boolean isCrashedLastRun() { - return getCurrentHub().isCrashedLastRun(); + return getCurrentScopes().isCrashedLastRun(); } /** @@ -964,7 +984,7 @@ public static void endSession() { * finished, this call will be ignored. */ public static void reportFullyDisplayed() { - getCurrentHub().reportFullyDisplayed(); + getCurrentScopes().reportFullyDisplayed(); } /** @@ -980,7 +1000,7 @@ public static void reportFullDisplayed() { @NotNull @ApiStatus.Experimental public static MetricsApi metrics() { - return getCurrentHub().metrics(); + return getCurrentScopes().metrics(); } /** @@ -1009,7 +1029,7 @@ public interface OptionsConfiguration { // return TransactionContext (if performance enabled) or null (if performance disabled) public static @Nullable TransactionContext continueTrace( final @Nullable String sentryTrace, final @Nullable List baggageHeaders) { - return getCurrentHub().continueTrace(sentryTrace, baggageHeaders); + return getCurrentScopes().continueTrace(sentryTrace, baggageHeaders); } /** @@ -1019,7 +1039,7 @@ public interface OptionsConfiguration { * @return sentry trace header or null */ public static @Nullable SentryTraceHeader getTraceparent() { - return getCurrentHub().getTraceparent(); + return getCurrentScopes().getTraceparent(); } /** @@ -1029,11 +1049,11 @@ public interface OptionsConfiguration { * @return baggage header or null */ public static @Nullable BaggageHeader getBaggage() { - return getCurrentHub().getBaggage(); + return getCurrentScopes().getBaggage(); } @ApiStatus.Experimental public static @NotNull SentryId captureCheckIn(final @NotNull CheckIn checkIn) { - return getCurrentHub().captureCheckIn(checkIn); + return getCurrentScopes().captureCheckIn(checkIn); } }