Package io.sentry
Interface IHub
-
- All Known Implementing Classes:
Hub,HubAdapter,NoOpHub
public interface IHubSDK API contract which combines a client and scope management
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidaddBreadcrumb(@NotNull Breadcrumb breadcrumb)Adds a breadcrumb to the current ScopevoidaddBreadcrumb(@NotNull Breadcrumb breadcrumb, @Nullable java.lang.Object hint)Adds a breadcrumb to the current Scopedefault voidaddBreadcrumb(@NotNull java.lang.String message)Adds a breadcrumb to the current Scopedefault voidaddBreadcrumb(@NotNull java.lang.String message, @NotNull java.lang.String category)Adds a breadcrumb to the current ScopevoidbindClient(@NotNull ISentryClient client)Binds a different client to the hubdefault @NotNull SentryIdcaptureEnvelope(@NotNull SentryEnvelope envelope)Captures an envelope.@NotNull SentryIdcaptureEnvelope(@NotNull SentryEnvelope envelope, @Nullable java.lang.Object hint)Captures an envelope.default @NotNull SentryIdcaptureEvent(@NotNull SentryEvent event)Captures the event.@NotNull SentryIdcaptureEvent(@NotNull SentryEvent event, @Nullable java.lang.Object hint)Captures the event.default @NotNull SentryIdcaptureException(@NotNull java.lang.Throwable throwable)Captures the exception.@NotNull SentryIdcaptureException(@NotNull java.lang.Throwable throwable, @Nullable java.lang.Object hint)Captures the exception.default @NotNull SentryIdcaptureMessage(@NotNull java.lang.String message)Captures the message.@NotNull SentryIdcaptureMessage(@NotNull java.lang.String message, @NotNull SentryLevel level)Captures the message.default @NotNull SentryIdcaptureTransaction(@NotNull SentryTransaction transaction, @Nullable TraceState traceState)Captures the transaction and enqueues it for sending to Sentry server.@NotNull SentryIdcaptureTransaction(@NotNull SentryTransaction transaction, @Nullable TraceState traceState, @Nullable java.lang.Object hint)Captures the transaction and enqueues it for sending to Sentry server.default @NotNull SentryIdcaptureTransaction(@NotNull SentryTransaction transaction, @Nullable java.lang.Object hint)voidcaptureUserFeedback(@NotNull UserFeedback userFeedback)Captures a manually created user feedback and sends it to Sentry.voidclearBreadcrumbs()Deletes 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.voidendSession()Ends the current sessionvoidflush(long timeoutMillis)Flushes events queued up, but keeps the Hub enabled.@NotNull SentryIdgetLastEventId()Last event id recorded in the current scope@NotNull SentryOptionsgetOptions()Gets theSentryOptionsattached to current scope.@Nullable ISpangetSpan()Gets the current active transaction or span.@Nullable java.lang.BooleanisCrashedLastRun()Returns if the App has crashed (Process has terminated) during the last run.booleanisEnabled()Check if the Hub is enabled/active.voidpopScope()Removes the first scopevoidpushScope()Pushes a new scope while inheriting the current scope's data.voidremoveExtra(@NotNull java.lang.String key)Removes the extra key to an arbitrary value to the current ScopevoidremoveTag(@NotNull java.lang.String key)Removes the tag to a string value to the current ScopevoidsetExtra(@NotNull java.lang.String key, @NotNull java.lang.String value)Sets the extra key to an arbitrary value to the current Scope, overwriting a potential previous valuevoidsetFingerprint(@NotNull java.util.List<java.lang.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 java.lang.Throwable throwable, @NotNull ISpan span, @NotNull java.lang.String transactionName)AssociatesISpanand the transaction name with theThrowable.voidsetTag(@NotNull java.lang.String key, @NotNull java.lang.String value)Sets the tag to a string value to the current Scope, overwriting a potential previous valuevoidsetTransaction(@Nullable java.lang.String transaction)Sets the name of the current transaction to the current Scope.voidsetUser(@Nullable User user)Shallow merges user configuration (email, username, etc) to the current Scope.voidstartSession()Starts a new session.default @NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts)Creates a Transaction and returns the instance.default @NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts, boolean bindToScope)Creates a Transaction and returns the instance.default @NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts, @Nullable CustomSamplingContext customSamplingContext)Creates a Transaction and returns the instance.@NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts, @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope)Creates a Transaction and returns the instance.@NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts, @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope, @Nullable java.util.Date startTimestamp)@NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts, @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope, @Nullable java.util.Date startTimestamp, boolean waitForChildren, @Nullable TransactionFinishedCallback transactionFinishedCallback)default @NotNull ITransactionstartTransaction(@NotNull java.lang.String name, @NotNull java.lang.String operation)Creates a Transaction and returns the instance.default @NotNull ITransactionstartTransaction(@NotNull java.lang.String name, @NotNull java.lang.String operation, boolean bindToScope)Creates a Transaction and returns the instance.default @NotNull ITransactionstartTransaction(@NotNull java.lang.String name, @NotNull java.lang.String operation, @Nullable CustomSamplingContext customSamplingContext)Creates a Transaction and returns the instance.default @NotNull ITransactionstartTransaction(@NotNull java.lang.String name, @NotNull java.lang.String operation, @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope)Creates a Transaction and returns the instance.default @NotNull ITransactionstartTransaction(@NotNull java.lang.String name, @NotNull java.lang.String operation, @Nullable java.util.Date startTimestamp, boolean waitForChildren, @Nullable TransactionFinishedCallback transactionFinishedCallback)@Nullable SentryTraceHeadertraceHeaders()Returns trace header of active transaction ornullif no transaction is active.voidwithScope(@NotNull ScopeCallback callback)Runs the callback with a new scope which gets dropped at the end
-
-
-
Method Detail
-
isEnabled
boolean isEnabled()
Check if the Hub is enabled/active.- Returns:
- true if its enabled or false otherwise.
-
captureEvent
@NotNull @NotNull SentryId captureEvent(@NotNull @NotNull SentryEvent event, @Nullable @Nullable java.lang.Object hint)
Captures the event.- 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 default @NotNull SentryId captureEvent(@NotNull @NotNull SentryEvent event)
Captures the event.- Parameters:
event- the event- Returns:
- The Id (SentryId object) of the event
-
captureMessage
@NotNull default @NotNull SentryId captureMessage(@NotNull @NotNull java.lang.String message)
Captures the message.- Parameters:
message- The message to send.- Returns:
- The Id (SentryId object) of the event
-
captureMessage
@NotNull @NotNull SentryId captureMessage(@NotNull @NotNull java.lang.String message, @NotNull @NotNull SentryLevel level)
Captures the message.- Parameters:
message- The message to send.level- The message level.- Returns:
- The Id (SentryId object) of the event
-
captureEnvelope
@NotNull @NotNull SentryId captureEnvelope(@NotNull @NotNull SentryEnvelope envelope, @Nullable @Nullable java.lang.Object hint)
Captures an envelope.- 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
-
captureEnvelope
@NotNull default @NotNull SentryId captureEnvelope(@NotNull @NotNull SentryEnvelope envelope)
Captures an envelope.- Parameters:
envelope- the SentryEnvelope to send.- Returns:
- The Id (SentryId object) of the event
-
captureException
@NotNull @NotNull SentryId captureException(@NotNull @NotNull java.lang.Throwable throwable, @Nullable @Nullable java.lang.Object hint)
Captures the exception.- 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 default @NotNull SentryId captureException(@NotNull @NotNull java.lang.Throwable throwable)
Captures the exception.- Parameters:
throwable- The exception.- Returns:
- The Id (SentryId object) of the event
-
captureUserFeedback
void captureUserFeedback(@NotNull @NotNull UserFeedback userFeedback)Captures a manually created user feedback and sends it to Sentry.- Parameters:
userFeedback- The user feedback to send to Sentry.
-
startSession
void startSession()
Starts a new session. If there's a running session, it ends it before starting the new one.
-
endSession
void endSession()
Ends the current session
-
close
void close()
Flushes out the queue for up to timeout seconds and disable the Hub.
-
addBreadcrumb
void addBreadcrumb(@NotNull @NotNull Breadcrumb breadcrumb, @Nullable @Nullable java.lang.Object hint)Adds a breadcrumb to the current Scope- Parameters:
breadcrumb- the breadcrumbhint- SDK specific but provides high level information about the origin of the event
-
addBreadcrumb
default void addBreadcrumb(@NotNull @NotNull Breadcrumb breadcrumb)Adds a breadcrumb to the current Scope- Parameters:
breadcrumb- the breadcrumb
-
addBreadcrumb
default void addBreadcrumb(@NotNull @NotNull java.lang.String message)Adds a breadcrumb to the current Scope- Parameters:
message- rendered as text and the whitespace is preserved.
-
addBreadcrumb
default void addBreadcrumb(@NotNull @NotNull java.lang.String message, @NotNull @NotNull java.lang.String category)Adds a breadcrumb to the current Scope- Parameters:
message- rendered as text and the whitespace is preserved.category- Categories are dotted strings that indicate what the crumb is or where it comes from.
-
setLevel
void setLevel(@Nullable @Nullable SentryLevel level)Sets the level of all events sent within current Scope- Parameters:
level- the Sentry level
-
setTransaction
void setTransaction(@Nullable @Nullable java.lang.String transaction)Sets the name of the current transaction to the current Scope.- Parameters:
transaction- the transaction
-
setUser
void setUser(@Nullable @Nullable User user)Shallow merges user configuration (email, username, etc) to the current Scope.- Parameters:
user- the user
-
setFingerprint
void setFingerprint(@NotNull @NotNull java.util.List<java.lang.String> fingerprint)Sets the fingerprint to group specific events together to the current Scope.- Parameters:
fingerprint- the fingerprints
-
clearBreadcrumbs
void clearBreadcrumbs()
Deletes current breadcrumbs from the current scope.
-
setTag
void setTag(@NotNull @NotNull java.lang.String key, @NotNull @NotNull java.lang.String value)Sets the tag to a string value to the current Scope, overwriting a potential previous value- Parameters:
key- the keyvalue- the value
-
removeTag
void removeTag(@NotNull @NotNull java.lang.String key)Removes the tag to a string value to the current Scope- Parameters:
key- the key
-
setExtra
void setExtra(@NotNull @NotNull java.lang.String key, @NotNull @NotNull java.lang.String value)Sets the extra key to an arbitrary value to the current Scope, overwriting a potential previous value- Parameters:
key- the keyvalue- the value
-
removeExtra
void removeExtra(@NotNull @NotNull java.lang.String key)Removes the extra key to an arbitrary value to the current Scope- Parameters:
key- the key
-
getLastEventId
@NotNull @NotNull SentryId getLastEventId()
Last event id recorded in the current scope- Returns:
- last SentryId
-
pushScope
void pushScope()
Pushes a new scope while inheriting the current scope's data.
-
popScope
void popScope()
Removes the first scope
-
withScope
void withScope(@NotNull @NotNull ScopeCallback callback)Runs the callback with a new scope which gets dropped at the end- Parameters:
callback- the callback
-
configureScope
void configureScope(@NotNull @NotNull ScopeCallback callback)Configures the scope through the callback.- Parameters:
callback- The configure scope callback.
-
bindClient
void bindClient(@NotNull @NotNull ISentryClient client)Binds a different client to the hub- Parameters:
client- the client.
-
flush
void flush(long timeoutMillis)
Flushes events queued up, but keeps the Hub enabled. Not implemented yet.- Parameters:
timeoutMillis- time in milliseconds
-
clone
@NotNull @NotNull IHub clone()
Clones the Hub- Returns:
- the cloned Hub
-
captureTransaction
@Internal @NotNull @NotNull SentryId captureTransaction(@NotNull @NotNull SentryTransaction transaction, @Nullable @Nullable TraceState traceState, @Nullable @Nullable java.lang.Object hint)
Captures the transaction and enqueues it for sending to Sentry server.- Parameters:
transaction- the transactiontraceState- the trace statehint- the hint- Returns:
- transaction's id
-
captureTransaction
@Internal @NotNull default @NotNull SentryId captureTransaction(@NotNull @NotNull SentryTransaction transaction, @Nullable @Nullable java.lang.Object hint)
-
captureTransaction
@Internal @NotNull default @NotNull SentryId captureTransaction(@NotNull @NotNull SentryTransaction transaction, @Nullable @Nullable TraceState traceState)
Captures the transaction and enqueues it for sending to Sentry server.- Parameters:
transaction- the transactiontraceState- the trace state- Returns:
- transaction's id
-
startTransaction
@NotNull default @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContexts)
Creates a Transaction and returns the instance.- Parameters:
transactionContexts- the transaction contexts- Returns:
- created transaction
-
startTransaction
@NotNull default @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContexts, boolean bindToScope)
Creates a Transaction and returns the instance.- Parameters:
transactionContexts- the transaction contextsbindToScope- if transaction should be bound to scope- Returns:
- created transaction
-
startTransaction
@NotNull default @NotNull ITransaction startTransaction(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.String operation, @Nullable @Nullable CustomSamplingContext customSamplingContext)
Creates a Transaction and returns the instance. Based on the passed sampling context the decision if transaction is sampled will be taken byTracesSampler.- Parameters:
name- the transaction nameoperation- the operationcustomSamplingContext- the sampling context- Returns:
- created transaction.
-
startTransaction
@NotNull default @NotNull ITransaction startTransaction(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.String operation, @Nullable @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope)
Creates a Transaction and returns the instance. Based on the passed sampling context the decision if transaction is sampled will be taken byTracesSampler.- Parameters:
name- the transaction nameoperation- the operationcustomSamplingContext- the sampling contextbindToScope- if transaction should be bound to scope- Returns:
- created transaction.
-
startTransaction
@NotNull default @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContexts, @Nullable @Nullable CustomSamplingContext customSamplingContext)
Creates a Transaction and returns the instance. Based on the passed transaction and sampling contexts the decision if transaction is sampled will be taken byTracesSampler.- Parameters:
transactionContexts- the transaction contextcustomSamplingContext- the sampling context- Returns:
- created transaction.
-
startTransaction
@NotNull @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContexts, @Nullable @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope)
Creates a Transaction and returns the instance. Based on the passed transaction and sampling contexts the decision if transaction is sampled will be taken byTracesSampler.- Parameters:
transactionContexts- the transaction contextcustomSamplingContext- the sampling contextbindToScope- if transaction should be bound to scope- Returns:
- created transaction.
-
startTransaction
@Internal @NotNull @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContexts, @Nullable @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope, @Nullable @Nullable java.util.Date startTimestamp)
-
startTransaction
@Internal @NotNull @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContexts, @Nullable @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope, @Nullable @Nullable java.util.Date startTimestamp, boolean waitForChildren, @Nullable @Nullable TransactionFinishedCallback transactionFinishedCallback)
-
startTransaction
@NotNull default @NotNull ITransaction startTransaction(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.String operation)
Creates a Transaction and returns the instance. Based on theSentryOptions.getTracesSampleRate()the decision if transaction is sampled will be taken byTracesSampler.- Parameters:
name- the transaction nameoperation- the operation- Returns:
- created transaction
-
startTransaction
@Internal @NotNull default @NotNull ITransaction startTransaction(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.String operation, @Nullable @Nullable java.util.Date startTimestamp, boolean waitForChildren, @Nullable @Nullable TransactionFinishedCallback transactionFinishedCallback)
-
startTransaction
@NotNull default @NotNull ITransaction startTransaction(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.String operation, boolean bindToScope)
Creates a Transaction and returns the instance. Based on theSentryOptions.getTracesSampleRate()the decision if transaction is sampled will be taken byTracesSampler.- Parameters:
name- the transaction nameoperation- the operationbindToScope- if transaction should be bound to scope- Returns:
- created transaction
-
traceHeaders
@Nullable @Nullable SentryTraceHeader traceHeaders()
Returns trace header of active transaction ornullif no transaction is active.- Returns:
- trace header or null
-
setSpanContext
@Internal void setSpanContext(@NotNull @NotNull java.lang.Throwable throwable, @NotNull @NotNull ISpan span, @NotNull @NotNull java.lang.String transactionName)AssociatesISpanand the transaction name with theThrowable. Used to determine in which trace the exception has been thrown in framework integrations.- Parameters:
throwable- the throwablespan- the span contexttransactionName- the transaction name
-
getSpan
@Nullable @Nullable ISpan getSpan()
Gets the current active transaction or span.- Returns:
- the active span or null when no active transaction is running
-
getOptions
@NotNull @NotNull SentryOptions getOptions()
Gets theSentryOptionsattached to current scope.- Returns:
- the options attached to current scope.
-
isCrashedLastRun
@Nullable @Nullable java.lang.Boolean isCrashedLastRun()
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.
- Returns:
- true if App has crashed, false otherwise, and null if not evaluated yet
-
-