Package io.sentry
Class HubAdapter
java.lang.Object
io.sentry.HubAdapter
- All Implemented Interfaces:
IHub
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addBreadcrumb
(@NotNull Breadcrumb breadcrumb) Adds a breadcrumb to the current Scopevoid
addBreadcrumb
(@NotNull Breadcrumb breadcrumb, @Nullable Hint hint) Adds a breadcrumb to the current Scopevoid
bindClient
(@NotNull ISentryClient client) Binds a different client to the hub@NotNull SentryId
captureCheckIn
(@NotNull CheckIn checkIn) @NotNull SentryId
captureEnvelope
(@NotNull SentryEnvelope envelope, @Nullable Hint hint) Captures an envelope.@NotNull SentryId
captureEvent
(@NotNull SentryEvent event, @Nullable Hint hint) Captures the event.@NotNull SentryId
captureEvent
(@NotNull SentryEvent event, @Nullable Hint hint, @NotNull ScopeCallback callback) Captures the event.@NotNull SentryId
captureException
(@NotNull Throwable throwable, @Nullable Hint hint) Captures the exception.@NotNull SentryId
captureException
(@NotNull Throwable throwable, @Nullable Hint hint, @NotNull ScopeCallback callback) Captures the exception.@NotNull SentryId
captureMessage
(@NotNull String message, @NotNull SentryLevel level) Captures the message.@NotNull SentryId
captureMessage
(@NotNull String message, @NotNull SentryLevel level, @NotNull ScopeCallback callback) Captures the message.@NotNull SentryId
captureReplay
(@NotNull SentryReplayEvent replay, @Nullable Hint hint) @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.void
captureUserFeedback
(@NotNull UserFeedback userFeedback) Captures a manually created user feedback and sends it to Sentry.void
Deletes current breadcrumbs from the current scope.@NotNull IHub
clone()
Clones the Hubvoid
close()
Flushes out the queue for up to timeout seconds and disable the Hub.void
close
(boolean isRestarting) Flushes out the queue for up to timeout seconds and disable the Hub.void
configureScope
(@NotNull ScopeCallback callback) Configures the scope through the callback.@Nullable TransactionContext
continueTrace
(@Nullable String sentryTrace, @Nullable List<String> baggageHeaders) Continue a trace based on HTTP header values.void
Ends the current sessionvoid
flush
(long timeoutMillis) Flushes events queued up, but keeps the Hub enabled.@Nullable BaggageHeader
Returns the "baggage" header that allows tracing across services.static HubAdapter
@NotNull SentryId
Last event id recorded in the current scope@NotNull SentryOptions
Gets theSentryOptions
attached to current scope.@Nullable RateLimiter
@Nullable ISpan
getSpan()
Gets the current active transaction or span.@Nullable SentryTraceHeader
Returns the "sentry-trace" header that allows tracing across services.@Nullable ITransaction
Returns the transaction.@Nullable Boolean
Returns if the App has crashed (Process has terminated) during the last run.boolean
Check if the Hub is enabled/active.boolean
Whether the transport is healthy.@NotNull MetricsApi
metrics()
void
popScope()
Removes the first scopevoid
Pushes a new scope while inheriting the current scope's data.void
removeExtra
(@NotNull String key) Removes the extra key to an arbitrary value to the current Scopevoid
Removes the tag to a string value to the current Scopevoid
Report a screen has been fully loaded.void
Sets the extra key to an arbitrary value to the current Scope, overwriting a potential previous valuevoid
setFingerprint
(@NotNull List<String> fingerprint) Sets the fingerprint to group specific events together to the current Scope.void
setLevel
(@Nullable SentryLevel level) Sets the level of all events sent within current Scopevoid
setSpanContext
(@NotNull Throwable throwable, @NotNull ISpan span, @NotNull String transactionName) void
Sets the tag to a string value to the current Scope, overwriting a potential previous valuevoid
setTransaction
(@Nullable String transaction) Sets the name of the current transaction to the current Scope.void
Shallow merges user configuration (email, username, etc) to the current Scope.void
Starts a new session.@NotNull ITransaction
startTransaction
(@NotNull TransactionContext transactionContext, @NotNull TransactionOptions transactionOptions) Creates a Transaction and returns the instance.@Nullable SentryTraceHeader
Deprecated.void
withScope
(@NotNull ScopeCallback callback) Runs the callback with a new scope which gets dropped at the end.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.sentry.IHub
addBreadcrumb, addBreadcrumb, captureEnvelope, captureEvent, captureEvent, captureException, captureException, captureMessage, captureMessage, captureTransaction, captureTransaction, captureTransaction, reportFullDisplayed, startTransaction, startTransaction, startTransaction
-
Method Details
-
getInstance
-
isEnabled
public boolean isEnabled()Description copied from interface:IHub
Check if the Hub is enabled/active. -
captureEvent
@NotNull public @NotNull SentryId captureEvent(@NotNull @NotNull SentryEvent event, @Nullable @Nullable Hint hint) Description copied from interface:IHub
Captures the event.- Specified by:
captureEvent
in interfaceIHub
- 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:IHub
Captures the event.- Specified by:
captureEvent
in interfaceIHub
- 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:IHub
Captures the message.- Specified by:
captureMessage
in interfaceIHub
- 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:IHub
Captures the message.- Specified by:
captureMessage
in interfaceIHub
- 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:IHub
Captures an envelope.- Specified by:
captureEnvelope
in interfaceIHub
- 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:IHub
Captures the exception.- Specified by:
captureException
in interfaceIHub
- 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:IHub
Captures the exception.- Specified by:
captureException
in interfaceIHub
- 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:IHub
Captures a manually created user feedback and sends it to Sentry.- Specified by:
captureUserFeedback
in interfaceIHub
- Parameters:
userFeedback
- The user feedback to send to Sentry.
-
startSession
public void startSession()Description copied from interface:IHub
Starts a new session. If there's a running session, it ends it before starting the new one.- Specified by:
startSession
in interfaceIHub
-
endSession
public void endSession()Description copied from interface:IHub
Ends the current session- Specified by:
endSession
in interfaceIHub
-
close
public void close(boolean isRestarting) Description copied from interface:IHub
Flushes out the queue for up to timeout seconds and disable the Hub. -
close
public void close()Description copied from interface:IHub
Flushes out the queue for up to timeout seconds and disable the Hub. -
addBreadcrumb
Description copied from interface:IHub
Adds a breadcrumb to the current Scope- Specified by:
addBreadcrumb
in interfaceIHub
- Parameters:
breadcrumb
- the breadcrumbhint
- SDK specific but provides high level information about the origin of the event
-
addBreadcrumb
Description copied from interface:IHub
Adds a breadcrumb to the current Scope- Specified by:
addBreadcrumb
in interfaceIHub
- Parameters:
breadcrumb
- the breadcrumb
-
setLevel
Description copied from interface:IHub
Sets the level of all events sent within current Scope -
setTransaction
Description copied from interface:IHub
Sets the name of the current transaction to the current Scope.- Specified by:
setTransaction
in interfaceIHub
- Parameters:
transaction
- the transaction
-
setUser
Description copied from interface:IHub
Shallow merges user configuration (email, username, etc) to the current Scope. -
setFingerprint
Description copied from interface:IHub
Sets the fingerprint to group specific events together to the current Scope.- Specified by:
setFingerprint
in interfaceIHub
- Parameters:
fingerprint
- the fingerprints
-
clearBreadcrumbs
public void clearBreadcrumbs()Description copied from interface:IHub
Deletes current breadcrumbs from the current scope.- Specified by:
clearBreadcrumbs
in interfaceIHub
-
setTag
Description copied from interface:IHub
Sets the tag to a string value to the current Scope, overwriting a potential previous value -
removeTag
Description copied from interface:IHub
Removes the tag to a string value to the current Scope -
setExtra
Description copied from interface:IHub
Sets the extra key to an arbitrary value to the current Scope, overwriting a potential previous value -
removeExtra
Description copied from interface:IHub
Removes the extra key to an arbitrary value to the current Scope- Specified by:
removeExtra
in interfaceIHub
- Parameters:
key
- the key
-
getLastEventId
Description copied from interface:IHub
Last event id recorded in the current scope- Specified by:
getLastEventId
in interfaceIHub
- Returns:
- last SentryId
-
pushScope
public void pushScope()Description copied from interface:IHub
Pushes a new scope while inheriting the current scope's data. -
popScope
public void popScope()Description copied from interface:IHub
Removes the first scope -
withScope
Description copied from interface:IHub
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)Sentry.init(Sentry.OptionsConfiguration, boolean)
calling withScope is discouraged, as scope changes may be dropped when executed in parallel. UseIHub.configureScope(ScopeCallback)
instead. -
configureScope
Description copied from interface:IHub
Configures the scope through the callback.- Specified by:
configureScope
in interfaceIHub
- Parameters:
callback
- The configure scope callback.
-
bindClient
Description copied from interface:IHub
Binds a different client to the hub- Specified by:
bindClient
in interfaceIHub
- Parameters:
client
- the client.
-
isHealthy
public boolean isHealthy()Description copied from interface:IHub
Whether the transport is healthy. -
flush
public void flush(long timeoutMillis) Description copied from interface:IHub
Flushes events queued up, but keeps the Hub enabled. Not implemented yet. -
clone
Description copied from interface:IHub
Clones the Hub -
captureTransaction
@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:IHub
Captures the transaction and enqueues it for sending to Sentry server.- Specified by:
captureTransaction
in interfaceIHub
- 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:IHub
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 byTracesSampler
.- Specified by:
startTransaction
in interfaceIHub
- Parameters:
transactionContext
- the transaction contexttransactionOptions
- the transaction options- Returns:
- created transaction.
-
traceHeaders
Deprecated.Description copied from interface:IHub
Returns the "sentry-trace" header that allows tracing across services. Can also be used in <meta> HTML tags. Also seeIHub.getBaggage()
.- Specified by:
traceHeaders
in interfaceIHub
- Returns:
- sentry trace header or null
-
setSpanContext
public void setSpanContext(@NotNull @NotNull Throwable throwable, @NotNull @NotNull ISpan span, @NotNull @NotNull String transactionName) Description copied from interface:IHub
AssociatesISpan
and the transaction name with theThrowable
. Used to determine in which trace the exception has been thrown in framework integrations.- Specified by:
setSpanContext
in interfaceIHub
- Parameters:
throwable
- the throwablespan
- the span contexttransactionName
- the transaction name
-
getSpan
Description copied from interface:IHub
Gets the current active transaction or span. -
getTransaction
Description copied from interface:IHub
Returns the transaction.- Specified by:
getTransaction
in interfaceIHub
- Returns:
- the transaction or null when no active transaction is running.
-
getOptions
Description copied from interface:IHub
Gets theSentryOptions
attached to current scope.- Specified by:
getOptions
in interfaceIHub
- Returns:
- the options attached to current scope.
-
isCrashedLastRun
Description copied from interface:IHub
Returns 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:
isCrashedLastRun
in interfaceIHub
- Returns:
- true if App has crashed, false otherwise, and null if not evaluated yet
-
reportFullyDisplayed
public void reportFullyDisplayed()Description copied from interface:IHub
Report 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:
reportFullyDisplayed
in interfaceIHub
-
continueTrace
@Nullable public @Nullable TransactionContext continueTrace(@Nullable @Nullable String sentryTrace, @Nullable @Nullable List<String> baggageHeaders) Description copied from interface:IHub
Continue 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:
continueTrace
in interfaceIHub
- 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:IHub
Returns the "sentry-trace" header that allows tracing across services. Can also be used in <meta> HTML tags. Also seeIHub.getBaggage()
.- Specified by:
getTraceparent
in interfaceIHub
- Returns:
- sentry trace header or null
-
getBaggage
Description copied from interface:IHub
Returns the "baggage" header that allows tracing across services. Can also be used in <meta> HTML tags. Also seeIHub.getTraceparent()
.- Specified by:
getBaggage
in interfaceIHub
- Returns:
- baggage header or null
-
captureCheckIn
- Specified by:
captureCheckIn
in interfaceIHub
-
captureReplay
@NotNull public @NotNull SentryId captureReplay(@NotNull @NotNull SentryReplayEvent replay, @Nullable @Nullable Hint hint) - Specified by:
captureReplay
in interfaceIHub
-
getRateLimiter
- Specified by:
getRateLimiter
in interfaceIHub
-
metrics
-