Package io.sentry
Class Hub
java.lang.Object
io.sentry.Hub
- All Implemented Interfaces:
IHub
-
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 hub@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 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()Clones the Hubvoidclose()Flushes out the queue for up to timeout seconds and disable the Hub.voidconfigureScope(@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 Hub enabled.@Nullable BaggageHeaderReturns the "baggage" header that allows tracing across services.@NotNull SentryIdLast event id recorded in the current scope@NotNull SentryOptionsGets theSentryOptionsattached to current scope.@Nullable RateLimiter@Nullable ISpangetSpan()Gets the current active transaction or span.@Nullable SentryTraceHeaderReturns the "sentry-trace" header that allows tracing across services.@Nullable ITransactionReturns the transaction.@Nullable BooleanReturns if the App has crashed (Process has terminated) during the last run.booleanCheck if the Hub is enabled/active.booleanWhether the transport is healthy.voidpopScope()Removes the first scopevoidPushes 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.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.@Nullable SentryTraceHeaderDeprecated.voidwithScope(@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, waitMethods inherited from interface io.sentry.IHub
addBreadcrumb, addBreadcrumb, captureEnvelope, captureEvent, captureEvent, captureException, captureException, captureMessage, captureMessage, captureTransaction, captureTransaction, captureTransaction, reportFullDisplayed, startTransaction, startTransaction, startTransaction
-
Constructor Details
-
Hub
-
-
Method Details
-
isEnabled
public boolean isEnabled()Description copied from interface:IHubCheck if the Hub is enabled/active. -
captureEvent
@NotNull public @NotNull SentryId captureEvent(@NotNull @NotNull SentryEvent event, @Nullable @Nullable Hint hint) Description copied from interface:IHubCaptures the event.- Specified by:
captureEventin 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:IHubCaptures the event.- Specified by:
captureEventin 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:IHubCaptures the message.- Specified by:
captureMessagein 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:IHubCaptures the message.- Specified by:
captureMessagein 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:IHubCaptures an envelope.- Specified by:
captureEnvelopein 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:IHubCaptures the exception.- Specified by:
captureExceptionin 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:IHubCaptures the exception.- Specified by:
captureExceptionin 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:IHubCaptures a manually created user feedback and sends it to Sentry.- Specified by:
captureUserFeedbackin interfaceIHub- Parameters:
userFeedback- The user feedback to send to Sentry.
-
startSession
public void startSession()Description copied from interface:IHubStarts a new session. If there's a running session, it ends it before starting the new one.- Specified by:
startSessionin interfaceIHub
-
endSession
public void endSession()Description copied from interface:IHubEnds the current session- Specified by:
endSessionin interfaceIHub
-
close
public void close()Description copied from interface:IHubFlushes out the queue for up to timeout seconds and disable the Hub. -
addBreadcrumb
Description copied from interface:IHubAdds a breadcrumb to the current Scope- Specified by:
addBreadcrumbin interfaceIHub- Parameters:
breadcrumb- the breadcrumbhint- SDK specific but provides high level information about the origin of the event
-
addBreadcrumb
Description copied from interface:IHubAdds a breadcrumb to the current Scope- Specified by:
addBreadcrumbin interfaceIHub- Parameters:
breadcrumb- the breadcrumb
-
setLevel
Description copied from interface:IHubSets the level of all events sent within current Scope -
setTransaction
Description copied from interface:IHubSets the name of the current transaction to the current Scope.- Specified by:
setTransactionin interfaceIHub- Parameters:
transaction- the transaction
-
setUser
Description copied from interface:IHubShallow merges user configuration (email, username, etc) to the current Scope. -
setFingerprint
Description copied from interface:IHubSets the fingerprint to group specific events together to the current Scope.- Specified by:
setFingerprintin interfaceIHub- Parameters:
fingerprint- the fingerprints
-
clearBreadcrumbs
public void clearBreadcrumbs()Description copied from interface:IHubDeletes current breadcrumbs from the current scope.- Specified by:
clearBreadcrumbsin interfaceIHub
-
setTag
Description copied from interface:IHubSets the tag to a string value to the current Scope, overwriting a potential previous value -
removeTag
Description copied from interface:IHubRemoves the tag to a string value to the current Scope -
setExtra
Description copied from interface:IHubSets the extra key to an arbitrary value to the current Scope, overwriting a potential previous value -
removeExtra
Description copied from interface:IHubRemoves the extra key to an arbitrary value to the current Scope- Specified by:
removeExtrain interfaceIHub- Parameters:
key- the key
-
getLastEventId
Description copied from interface:IHubLast event id recorded in the current scope- Specified by:
getLastEventIdin interfaceIHub- Returns:
- last SentryId
-
pushScope
public void pushScope()Description copied from interface:IHubPushes a new scope while inheriting the current scope's data. -
getOptions
Description copied from interface:IHubGets theSentryOptionsattached to current scope.- Specified by:
getOptionsin interfaceIHub- Returns:
- the options attached to current scope.
-
isCrashedLastRun
Description copied from interface:IHubReturns 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 interfaceIHub- Returns:
- true if App has crashed, false otherwise, and null if not evaluated yet
-
reportFullyDisplayed
public void reportFullyDisplayed()Description copied from interface:IHubReport 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 interfaceIHub
-
popScope
public void popScope()Description copied from interface:IHubRemoves the first scope -
withScope
Description copied from interface:IHubRuns 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:IHubConfigures the scope through the callback.- Specified by:
configureScopein interfaceIHub- Parameters:
callback- The configure scope callback.
-
bindClient
Description copied from interface:IHubBinds a different client to the hub- Specified by:
bindClientin interfaceIHub- Parameters:
client- the client.
-
isHealthy
public boolean isHealthy()Description copied from interface:IHubWhether the transport is healthy. -
flush
public void flush(long timeoutMillis) Description copied from interface:IHubFlushes events queued up, but keeps the Hub enabled. Not implemented yet. -
clone
Description copied from interface:IHubClones 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:IHubCaptures the transaction and enqueues it for sending to Sentry server.- Specified by:
captureTransactionin 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:IHubCreates 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 interfaceIHub- Parameters:
transactionContext- the transaction contexttransactionOptions- the transaction options- Returns:
- created transaction.
-
traceHeaders
Deprecated.Description copied from interface:IHubReturns the "sentry-trace" header that allows tracing across services. Can also be used in <meta> HTML tags. Also seeIHub.getBaggage().- Specified by:
traceHeadersin interfaceIHub- Returns:
- sentry trace header or null
-
getSpan
Description copied from interface:IHubGets the current active transaction or span. -
getTransaction
Description copied from interface:IHubReturns the transaction.- Specified by:
getTransactionin interfaceIHub- Returns:
- the transaction or null when no active transaction is running.
-
setSpanContext
@Internal public void setSpanContext(@NotNull @NotNull Throwable throwable, @NotNull @NotNull ISpan span, @NotNull @NotNull String transactionName) Description copied from interface:IHubAssociatesISpanand the transaction name with theThrowable. Used to determine in which trace the exception has been thrown in framework integrations.- Specified by:
setSpanContextin interfaceIHub- Parameters:
throwable- the throwablespan- the span contexttransactionName- the transaction name
-
continueTrace
@Nullable public @Nullable TransactionContext continueTrace(@Nullable @Nullable String sentryTrace, @Nullable @Nullable List<String> baggageHeaders) Description copied from interface:IHubContinue 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 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:IHubReturns the "sentry-trace" header that allows tracing across services. Can also be used in <meta> HTML tags. Also seeIHub.getBaggage().- Specified by:
getTraceparentin interfaceIHub- Returns:
- sentry trace header or null
-
getBaggage
Description copied from interface:IHubReturns the "baggage" header that allows tracing across services. Can also be used in <meta> HTML tags. Also seeIHub.getTraceparent().- Specified by:
getBaggagein interfaceIHub- Returns:
- baggage header or null
-
captureCheckIn
- Specified by:
captureCheckInin interfaceIHub
-
getRateLimiter
- Specified by:
getRateLimiterin interfaceIHub
-