Class Scopes
- All Implemented Interfaces:
IScopes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBreadcrumb(@NotNull Breadcrumb breadcrumb) Adds a breadcrumb to the current ScopevoidaddBreadcrumb(@NotNull Breadcrumb breadcrumb, @Nullable Hint hint) Adds a breadcrumb to the current ScopevoidbindClient(@NotNull ISentryClient client) Binds a different client to the scopes@NotNull SentryIdcaptureCheckIn(@NotNull CheckIn checkIn) @NotNull SentryIdcaptureEnvelope(@NotNull SentryEnvelope envelope, @Nullable Hint hint) Captures an envelope.@NotNull SentryIdcaptureEvent(@NotNull SentryEvent event, @Nullable Hint hint) Captures the event.@NotNull SentryIdcaptureEvent(@NotNull SentryEvent event, @Nullable Hint hint, @NotNull ScopeCallback callback) Captures the event.@NotNull SentryIdcaptureException(@NotNull Throwable throwable, @Nullable Hint hint) Captures the exception.@NotNull SentryIdcaptureException(@NotNull Throwable throwable, @Nullable Hint hint, @NotNull ScopeCallback callback) Captures the exception.@NotNull SentryIdcaptureMessage(@NotNull String message, @NotNull SentryLevel level) Captures the message.@NotNull SentryIdcaptureMessage(@NotNull String message, @NotNull SentryLevel level, @NotNull ScopeCallback callback) Captures the message.@NotNull SentryIdcaptureReplay(@NotNull SentryReplayEvent replay, @Nullable Hint hint) @NotNull SentryIdcaptureTransaction(@NotNull SentryTransaction transaction, @Nullable TraceContext traceContext, @Nullable Hint hint, @Nullable ProfilingTraceData profilingTraceData) Captures the transaction and enqueues it for sending to Sentry server.voidcaptureUserFeedback(@NotNull UserFeedback userFeedback) Captures a manually created user feedback and sends it to Sentry.voidDeletes current breadcrumbs from the current scope.@NotNull IHubclone()Deprecated.voidclose()Flushes out the queue for up to timeout seconds and disable the Scopes.voidclose(boolean isRestarting) Flushes out the queue for up to timeout seconds and disable the Scopes.voidconfigureScope(@Nullable ScopeType scopeType, @NotNull ScopeCallback callback) Configures the scope through the callback.@Nullable TransactionContextcontinueTrace(@Nullable String sentryTrace, @Nullable List<String> baggageHeaders) Continue a trace based on HTTP header values.voidEnds the current sessionvoidflush(long timeoutMillis) Flushes events queued up, but keeps the scopes enabled.@NotNull IScopesforkedCurrentScope(@NotNull String creator) Creates a fork of current scope without forking isolation scope.@NotNull IScopesforkedRootScopes(@NotNull String creator) Creates a fork of both current and isolation scope from root scopes.@NotNull IScopesforkedScopes(@NotNull String creator) Creates a fork of both current and isolation scope from current scopes.@Nullable BaggageHeaderReturns the "baggage" header that allows tracing across services.@NotNull String@NotNull IScopeReturns the global scope.@NotNull IScopeReturns the isolation scope of this Scopes.@NotNull SentryIdLast event id recorded in the current scope@NotNull SentryOptionsGets theSentryOptionsattached to current scope.@Nullable IScopesReturns the parent of this Scopes instance or null, if it does not have a parent.@Nullable RateLimiter@NotNull IScopegetScope()Returns the current scope of this Scopes.@Nullable ISpangetSpan()Gets the current active transaction or span.@Nullable SentryTraceHeaderReturns the "sentry-trace" header that allows tracing across services.@Nullable ITransactionReturns the transaction.booleanisAncestorOf(@Nullable IScopes otherScopes) Checks whether this Scopes instance is direct or indirect parent of the other Scopes instance.@Nullable BooleanReturns if the App has crashed (Process has terminated) during the last run.booleanCheck if Sentry is enabled/active.booleanWhether the transport is healthy.@NotNull ISentryLifecycleTokenStores this Scopes in store, making it the current one that is used by static API.voidpopScope()Deprecated.please callISentryLifecycleToken.close()on the token returned byIScopes.pushScope()orIScopes.pushIsolationScope()instead.Pushes a new scope while inheriting the current scope's data.voidremoveExtra(@NotNull String key) Removes the extra key to an arbitrary value to the current ScopevoidRemoves the tag to a string value to the current ScopevoidReport a screen has been fully loaded.voidsetActiveSpan(@Nullable ISpan span) voidSets the extra key to an arbitrary value to the current Scope, overwriting a potential previous valuevoidsetFingerprint(@NotNull List<String> fingerprint) Sets the fingerprint to group specific events together to the current Scope.voidsetLevel(@Nullable SentryLevel level) Sets the level of all events sent within current ScopevoidsetSpanContext(@NotNull Throwable throwable, @NotNull ISpan span, @NotNull String transactionName) voidSets the tag to a string value to the current Scope, overwriting a potential previous valuevoidsetTransaction(@Nullable String transaction) Sets the name of the current transaction to the current Scope.voidShallow merges user configuration (email, username, etc) to the current Scope.voidStarts a new session.@NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContext, @NotNull TransactionOptions transactionOptions) Creates a Transaction and returns the instance.voidwithIsolationScope(@NotNull ScopeCallback callback) Runs the callback with a new isolation scope which gets dropped at the end.voidwithScope(@NotNull ScopeCallback callback) Runs the callback with a new current scope which gets dropped at the end.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.sentry.IScopes
addBreadcrumb, addBreadcrumb, captureEnvelope, captureEvent, captureEvent, captureException, captureException, captureMessage, captureMessage, captureTransaction, captureTransaction, captureTransaction, configureScope, isNoOp, startTransaction, startTransaction, startTransaction
-
Constructor Details
-
Scopes
-
-
Method Details
-
getCreator
-
getScope
Description copied from interface:IScopesReturns the current scope of this Scopes. -
getIsolationScope
Description copied from interface:IScopesReturns the isolation scope of this Scopes.- Specified by:
getIsolationScopein interfaceIScopes- Returns:
- isolation scope
-
getGlobalScope
Description copied from interface:IScopesReturns the global scope.- Specified by:
getGlobalScopein interfaceIScopes- Returns:
- global scope
-
getParentScopes
Description copied from interface:IScopesReturns the parent of this Scopes instance or null, if it does not have a parent. The parent is the Scopes instance this instance was forked from.- Specified by:
getParentScopesin interfaceIScopes- Returns:
- parent Scopes or null
-
isAncestorOf
Description copied from interface:IScopesChecks whether this Scopes instance is direct or indirect parent of the other Scopes instance.- Specified by:
isAncestorOfin interfaceIScopes- Parameters:
otherScopes- Scopes instance that could be a direct or indirect child.- Returns:
- true if this Scopes instance is a direct or indirect parent of the other Scopes.
-
forkedScopes
Description copied from interface:IScopesCreates a fork of both current and isolation scope from current scopes.- Specified by:
forkedScopesin interfaceIScopes- Parameters:
creator- debug information to see why scopes where forked- Returns:
- forked Scopes
-
forkedCurrentScope
Description copied from interface:IScopesCreates a fork of current scope without forking isolation scope.- Specified by:
forkedCurrentScopein interfaceIScopes- Parameters:
creator- debug information to see why scopes where forked- Returns:
- forked Scopes
-
forkedRootScopes
Description copied from interface:IScopesCreates a fork of both current and isolation scope from root scopes.- Specified by:
forkedRootScopesin interfaceIScopes- Parameters:
creator- debug information to see why scopes where forked- Returns:
- forked Scopes
-
isEnabled
public boolean isEnabled()Description copied from interface:IScopesCheck if Sentry is enabled/active. -
captureEvent
@NotNull public @NotNull SentryId captureEvent(@NotNull @NotNull SentryEvent event, @Nullable @Nullable Hint hint) Description copied from interface:IScopesCaptures the event.- Specified by:
captureEventin interfaceIScopes- Parameters:
event- the eventhint- SDK specific but provides high level information about the origin of the event- Returns:
- The Id (SentryId object) of the event
-
captureEvent
@NotNull public @NotNull SentryId captureEvent(@NotNull @NotNull SentryEvent event, @Nullable @Nullable Hint hint, @NotNull @NotNull ScopeCallback callback) Description copied from interface:IScopesCaptures the event.- Specified by:
captureEventin interfaceIScopes- Parameters:
event- the eventhint- SDK specific but provides high level information about the origin of the eventcallback- The callback to configure the scope for a single invocation.- Returns:
- The Id (SentryId object) of the event
-
captureMessage
@NotNull public @NotNull SentryId captureMessage(@NotNull @NotNull String message, @NotNull @NotNull SentryLevel level) Description copied from interface:IScopesCaptures the message.- Specified by:
captureMessagein interfaceIScopes- Parameters:
message- The message to send.level- The message level.- Returns:
- The Id (SentryId object) of the event
-
captureMessage
@NotNull public @NotNull SentryId captureMessage(@NotNull @NotNull String message, @NotNull @NotNull SentryLevel level, @NotNull @NotNull ScopeCallback callback) Description copied from interface:IScopesCaptures the message.- Specified by:
captureMessagein interfaceIScopes- Parameters:
message- The message to send.level- The message level.callback- The callback to configure the scope for a single invocation.- Returns:
- The Id (SentryId object) of the event
-
captureEnvelope
@Internal @NotNull public @NotNull SentryId captureEnvelope(@NotNull @NotNull SentryEnvelope envelope, @Nullable @Nullable Hint hint) Description copied from interface:IScopesCaptures an envelope.- Specified by:
captureEnvelopein interfaceIScopes- Parameters:
envelope- the SentryEnvelope to send.hint- SDK specific but provides high level information about the origin of the event- Returns:
- The Id (SentryId object) of the event
-
captureException
@NotNull public @NotNull SentryId captureException(@NotNull @NotNull Throwable throwable, @Nullable @Nullable Hint hint) Description copied from interface:IScopesCaptures the exception.- Specified by:
captureExceptionin interfaceIScopes- Parameters:
throwable- The exception.hint- SDK specific but provides high level information about the origin of the event- Returns:
- The Id (SentryId object) of the event
-
captureException
@NotNull public @NotNull SentryId captureException(@NotNull @NotNull Throwable throwable, @Nullable @Nullable Hint hint, @NotNull @NotNull ScopeCallback callback) Description copied from interface:IScopesCaptures the exception.- Specified by:
captureExceptionin interfaceIScopes- Parameters:
throwable- The exception.hint- SDK specific but provides high level information about the origin of the eventcallback- The callback to configure the scope for a single invocation.- Returns:
- The Id (SentryId object) of the event
-
captureUserFeedback
Description copied from interface:IScopesCaptures a manually created user feedback and sends it to Sentry.- Specified by:
captureUserFeedbackin interfaceIScopes- Parameters:
userFeedback- The user feedback to send to Sentry.
-
startSession
public void startSession()Description copied from interface:IScopesStarts a new session. If there's a running session, it ends it before starting the new one.- Specified by:
startSessionin interfaceIScopes
-
endSession
public void endSession()Description copied from interface:IScopesEnds the current session- Specified by:
endSessionin interfaceIScopes
-
close
public void close()Description copied from interface:IScopesFlushes out the queue for up to timeout seconds and disable the Scopes. -
close
public void close(boolean isRestarting) Description copied from interface:IScopesFlushes out the queue for up to timeout seconds and disable the Scopes. -
addBreadcrumb
Description copied from interface:IScopesAdds a breadcrumb to the current Scope- Specified by:
addBreadcrumbin interfaceIScopes- Parameters:
breadcrumb- the breadcrumbhint- SDK specific but provides high level information about the origin of the event
-
addBreadcrumb
Description copied from interface:IScopesAdds a breadcrumb to the current Scope- Specified by:
addBreadcrumbin interfaceIScopes- Parameters:
breadcrumb- the breadcrumb
-
setLevel
Description copied from interface:IScopesSets the level of all events sent within current Scope -
setTransaction
Description copied from interface:IScopesSets the name of the current transaction to the current Scope.- Specified by:
setTransactionin interfaceIScopes- Parameters:
transaction- the transaction
-
setUser
Description copied from interface:IScopesShallow merges user configuration (email, username, etc) to the current Scope. -
setFingerprint
Description copied from interface:IScopesSets the fingerprint to group specific events together to the current Scope.- Specified by:
setFingerprintin interfaceIScopes- Parameters:
fingerprint- the fingerprints
-
clearBreadcrumbs
public void clearBreadcrumbs()Description copied from interface:IScopesDeletes current breadcrumbs from the current scope.- Specified by:
clearBreadcrumbsin interfaceIScopes
-
setTag
Description copied from interface:IScopesSets the tag to a string value to the current Scope, overwriting a potential previous value -
removeTag
Description copied from interface:IScopesRemoves the tag to a string value to the current Scope -
setExtra
Description copied from interface:IScopesSets the extra key to an arbitrary value to the current Scope, overwriting a potential previous value -
removeExtra
Description copied from interface:IScopesRemoves the extra key to an arbitrary value to the current Scope- Specified by:
removeExtrain interfaceIScopes- Parameters:
key- the key
-
getLastEventId
Description copied from interface:IScopesLast event id recorded in the current scope- Specified by:
getLastEventIdin interfaceIScopes- Returns:
- last SentryId
-
pushScope
Description copied from interface:IScopesPushes a new scope while inheriting the current scope's data. -
pushIsolationScope
- Specified by:
pushIsolationScopein interfaceIScopes
-
makeCurrent
Description copied from interface:IScopesStores this Scopes in store, making it the current one that is used by static API.- Specified by:
makeCurrentin interfaceIScopes- Returns:
- a token you should call .close() on when you're done.
-
popScope
Deprecated.please callISentryLifecycleToken.close()on the token returned byIScopes.pushScope()orIScopes.pushIsolationScope()instead.Description copied from interface:IScopesRemoves the first scope and restores its parent. -
withScope
Description copied from interface:IScopesRuns the callback with a new current scope which gets dropped at the end.If you're using the Sentry SDK in globalHubMode (defaults to true on Android)
Sentry.init(Sentry.OptionsConfiguration, boolean)calling withScope is discouraged, as scope changes may be dropped when executed in parallel. UseIScopes.configureScope(ScopeCallback)instead. -
withIsolationScope
Description copied from interface:IScopesRuns the callback with a new isolation scope which gets dropped at the end. Current scope is also forked.If you're using the Sentry SDK in globalHubMode (defaults to true on Android)
Sentry.init(Sentry.OptionsConfiguration, boolean)calling withScope is discouraged, as scope changes may be dropped when executed in parallel. UseIScopes.configureScope(ScopeType, ScopeCallback)instead.- Specified by:
withIsolationScopein interfaceIScopes- Parameters:
callback- the callback
-
configureScope
public void configureScope(@Nullable @Nullable ScopeType scopeType, @NotNull @NotNull ScopeCallback callback) Description copied from interface:IScopesConfigures the scope through the callback.- Specified by:
configureScopein interfaceIScopescallback- The configure scope callback.
-
bindClient
Description copied from interface:IScopesBinds a different client to the scopes- Specified by:
bindClientin interfaceIScopes- Parameters:
client- the client.
-
isHealthy
public boolean isHealthy()Description copied from interface:IScopesWhether the transport is healthy. -
flush
public void flush(long timeoutMillis) Description copied from interface:IScopesFlushes events queued up, but keeps the scopes enabled. Not implemented yet. -
clone
Deprecated.please useIScopes.forkedScopes(String)orIScopes.forkedCurrentScope(String)instead.Description copied from interface:IScopesClones the Hub -
captureTransaction
@Internal @NotNull public @NotNull SentryId captureTransaction(@NotNull @NotNull SentryTransaction transaction, @Nullable @Nullable TraceContext traceContext, @Nullable @Nullable Hint hint, @Nullable @Nullable ProfilingTraceData profilingTraceData) Description copied from interface:IScopesCaptures the transaction and enqueues it for sending to Sentry server.- Specified by:
captureTransactionin interfaceIScopes- Parameters:
transaction- the transactiontraceContext- the trace contexthint- the hintsprofilingTraceData- the profiling trace data- Returns:
- transaction's id
-
startTransaction
@NotNull public @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContext, @NotNull @NotNull TransactionOptions transactionOptions) Description copied from interface:IScopesCreates a Transaction and returns the instance. Based on the passed transaction context and transaction options the decision if transaction is sampled will be taken byTracesSampler.- Specified by:
startTransactionin interfaceIScopes- Parameters:
transactionContext- the transaction contexttransactionOptions- the transaction options- Returns:
- created transaction.
-
setSpanContext
@Internal public void setSpanContext(@NotNull @NotNull Throwable throwable, @NotNull @NotNull ISpan span, @NotNull @NotNull String transactionName) Description copied from interface:IScopesAssociatesISpanand the transaction name with theThrowable. Used to determine in which trace the exception has been thrown in framework integrations.- Specified by:
setSpanContextin interfaceIScopes- Parameters:
throwable- the throwablespan- the span contexttransactionName- the transaction name
-
getSpan
Description copied from interface:IScopesGets the current active transaction or span. -
setActiveSpan
- Specified by:
setActiveSpanin interfaceIScopes
-
getTransaction
Description copied from interface:IScopesReturns the transaction.- Specified by:
getTransactionin interfaceIScopes- Returns:
- the transaction or null when no active transaction is running.
-
getOptions
Description copied from interface:IScopesGets theSentryOptionsattached to current scope.- Specified by:
getOptionsin interfaceIScopes- Returns:
- the options attached to current scope.
-
isCrashedLastRun
Description copied from interface:IScopesReturns if the App has crashed (Process has terminated) during the last run. It only returns true or false if offline caching {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.
- Specified by:
isCrashedLastRunin interfaceIScopes- Returns:
- true if App has crashed, false otherwise, and null if not evaluated yet
-
reportFullyDisplayed
public void reportFullyDisplayed()Description copied from interface:IScopesReport a screen has been fully loaded. That means all data needed by the UI was loaded. If time-to-full-display tracing {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.
- Specified by:
reportFullyDisplayedin interfaceIScopes
-
continueTrace
@Nullable public @Nullable TransactionContext continueTrace(@Nullable @Nullable String sentryTrace, @Nullable @Nullable List<String> baggageHeaders) Description copied from interface:IScopesContinue a trace based on HTTP header values. If no "sentry-trace" header is provided a random trace ID and span ID is created.- Specified by:
continueTracein interfaceIScopes- Parameters:
sentryTrace- "sentry-trace" headerbaggageHeaders- "baggage" headers- Returns:
- a transaction context for starting a transaction or null if performance is disabled
-
getTraceparent
Description copied from interface:IScopesReturns the "sentry-trace" header that allows tracing across services. Can also be used in <meta> HTML tags. Also seeIScopes.getBaggage().- Specified by:
getTraceparentin interfaceIScopes- Returns:
- sentry trace header or null
-
getBaggage
Description copied from interface:IScopesReturns the "baggage" header that allows tracing across services. Can also be used in <meta> HTML tags. Also seeIScopes.getTraceparent().- Specified by:
getBaggagein interfaceIScopes- Returns:
- baggage header or null
-
captureCheckIn
- Specified by:
captureCheckInin interfaceIScopes
-
captureReplay
@NotNull public @NotNull SentryId captureReplay(@NotNull @NotNull SentryReplayEvent replay, @Nullable @Nullable Hint hint) - Specified by:
captureReplayin interfaceIScopes
-
getRateLimiter
- Specified by:
getRateLimiterin interfaceIScopes
-
IScopes.forkedScopes(String)orIScopes.forkedCurrentScope(String)instead.