Package io.sentry
Class Sentry
java.lang.Object
io.sentry.Sentry
Sentry SDK main API entry point
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSentry.OptionsConfiguration<T extends SentryOptions>Configuration options callback -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddBreadcrumb(@NotNull Breadcrumb breadcrumb) Adds a breadcrumb to the current Scopestatic voidaddBreadcrumb(@NotNull Breadcrumb breadcrumb, @Nullable Hint hint) Adds a breadcrumb to the current Scopestatic voidaddBreadcrumb(@NotNull String message) Adds a breadcrumb to the current Scopestatic voidaddBreadcrumb(@NotNull String message, @NotNull String category) Adds a breadcrumb to the current Scopestatic voidbindClient(@NotNull ISentryClient client) Binds a different client to the current hubstatic @NotNull SentryIdcaptureCheckIn(@NotNull CheckIn checkIn) static @NotNull SentryIdcaptureEvent(@NotNull SentryEvent event) Captures the event.static @NotNull SentryIdcaptureEvent(@NotNull SentryEvent event, @NotNull ScopeCallback callback) Captures the event.static @NotNull SentryIdcaptureEvent(@NotNull SentryEvent event, @Nullable Hint hint) Captures the event.static @NotNull SentryIdcaptureEvent(@NotNull SentryEvent event, @Nullable Hint hint, @NotNull ScopeCallback callback) Captures the event.static @NotNull SentryIdcaptureException(@NotNull Throwable throwable) Captures the exception.static @NotNull SentryIdcaptureException(@NotNull Throwable throwable, @NotNull ScopeCallback callback) Captures the exception.static @NotNull SentryIdcaptureException(@NotNull Throwable throwable, @Nullable Hint hint) Captures the exception.static @NotNull SentryIdcaptureException(@NotNull Throwable throwable, @Nullable Hint hint, @NotNull ScopeCallback callback) Captures the exception.static @NotNull SentryIdcaptureMessage(@NotNull String message) Captures the message.static @NotNull SentryIdcaptureMessage(@NotNull String message, @NotNull ScopeCallback callback) Captures the message.static @NotNull SentryIdcaptureMessage(@NotNull String message, @NotNull SentryLevel level) Captures the message.static @NotNull SentryIdcaptureMessage(@NotNull String message, @NotNull SentryLevel level, @NotNull ScopeCallback callback) Captures the message.static voidcaptureUserFeedback(@NotNull UserFeedback userFeedback) Captures a manually created user feedback and sends it to Sentry.static voidDeletes current breadcrumbs from the current scope.static @NotNull IHubReturns a new hub which is cloned from the mainHub.static voidclose()Close the SDKstatic voidconfigureScope(@NotNull ScopeCallback callback) Configures the scope through the callback.static @Nullable TransactionContextcontinueTrace(@Nullable String sentryTrace, @Nullable List<String> baggageHeaders) Continue a trace based on HTTP header values.static voidEnds the current sessionstatic voidflush(long timeoutMillis) Flushes events queued up to the current hub.static @Nullable BaggageHeaderReturns the "baggage" header that allows tracing across services.static @NotNull IHubReturns the current (threads) hub, if none, clones the mainHub and returns it.static @NotNull SentryIdLast event id recorded in the current scopestatic @Nullable ISpangetSpan()Gets the current active transaction or span.static @Nullable SentryTraceHeaderReturns the "sentry-trace" header that allows tracing across services.static voidinit()Initializes the SDKstatic <T extends SentryOptions>
voidinit(@NotNull OptionsContainer<T> clazz, @NotNull Sentry.OptionsConfiguration<T> optionsConfiguration) Initializes the SDKstatic <T extends SentryOptions>
voidinit(@NotNull OptionsContainer<T> clazz, @NotNull Sentry.OptionsConfiguration<T> optionsConfiguration, boolean globalHubMode) Initializes the SDKstatic voidinit(@NotNull Sentry.OptionsConfiguration<SentryOptions> optionsConfiguration) Initializes the SDK with an optional configuration options callback.static voidinit(@NotNull Sentry.OptionsConfiguration<SentryOptions> optionsConfiguration, boolean globalHubMode) Initializes the SDK with an optional configuration options callback.static voidinit(@NotNull SentryOptions options) Initializes the SDK with a SentryOptions.static voidInitializes the SDKstatic @Nullable BooleanReturns if the App has crashed (Process has terminated) during the last run.static booleanCheck if the current Hub is enabled/active.static booleanstatic voidpopScope()Removes the first scopestatic voidPushes a new scope while inheriting the current scope's data.static voidremoveExtra(@NotNull String key) Removes the extra key to an arbitrary value to the current Scopestatic voidRemoves the tag to a string value to the current Scopestatic voidDeprecated.static voidReport a screen has been fully loaded.static voidsetCurrentHub(@NotNull IHub hub) static voidSets the extra key to an arbitrary value to the current Scope, overwriting a potential previous valuestatic voidsetFingerprint(@NotNull List<String> fingerprint) Sets the fingerprint to group specific events together to the current Scope.static voidsetLevel(@Nullable SentryLevel level) Sets the level of all events sent within current Scopestatic voidSets the tag to a string value to the current Scope, overwriting a potential previous valuestatic voidsetTransaction(@Nullable String transaction) Sets the name of the current transaction to the current Scope.static voidShallow merges user configuration (email, username, etc) to the current Scope.static voidStarts a new session.static @NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts) Creates a Transaction and returns the instance.static @NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContext, @NotNull TransactionOptions transactionOptions) Creates a Transaction and returns the instance.static @NotNull ITransactionstartTransaction(@NotNull String name, @NotNull String operation) Creates a Transaction and returns the instance.static @NotNull ITransactionstartTransaction(@NotNull String name, @NotNull String operation, @NotNull TransactionOptions transactionOptions) Creates a Transaction and returns the instance.static @NotNull ITransactionstartTransaction(@NotNull String name, @NotNull String operation, @Nullable String description, @NotNull TransactionOptions transactionOptions) Creates a Transaction and returns the instance.static @Nullable SentryTraceHeaderDeprecated.please usegetTraceparent()instead.static voidwithScope(@NotNull ScopeCallback callback) Runs the callback with a new scope which gets dropped at the end
-
Method Details
-
getCurrentHub
Returns the current (threads) hub, if none, clones the mainHub and returns it.- Returns:
- the hub
-
cloneMainHub
Returns a new hub which is cloned from the mainHub.- Returns:
- the hub
-
setCurrentHub
-
isEnabled
public static boolean isEnabled()Check if the current Hub is enabled/active.- Returns:
- true if its enabled or false otherwise.
-
init
public static void init()Initializes the SDK -
init
Initializes the SDK- Parameters:
dsn- The Sentry DSN
-
init
public static <T extends SentryOptions> void init(@NotNull @NotNull OptionsContainer<T> clazz, @NotNull @NotNull Sentry.OptionsConfiguration<T> optionsConfiguration) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException Initializes the SDK- Type Parameters:
T- class that extends SentryOptions- Parameters:
clazz- OptionsContainer for SentryOptionsoptionsConfiguration- configuration options callback- Throws:
IllegalAccessException- the IllegalAccessExceptionInstantiationException- the InstantiationExceptionNoSuchMethodException- the NoSuchMethodExceptionInvocationTargetException- the InvocationTargetException
-
init
public static <T extends SentryOptions> void init(@NotNull @NotNull OptionsContainer<T> clazz, @NotNull @NotNull Sentry.OptionsConfiguration<T> optionsConfiguration, boolean globalHubMode) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException Initializes the SDK- Type Parameters:
T- class that extends SentryOptions- Parameters:
clazz- OptionsContainer for SentryOptionsoptionsConfiguration- configuration options callbackglobalHubMode- the globalHubMode- Throws:
IllegalAccessException- the IllegalAccessExceptionInstantiationException- the InstantiationExceptionNoSuchMethodException- the NoSuchMethodExceptionInvocationTargetException- the InvocationTargetException
-
init
public static void init(@NotNull @NotNull Sentry.OptionsConfiguration<SentryOptions> optionsConfiguration) Initializes the SDK with an optional configuration options callback.- Parameters:
optionsConfiguration- configuration options callback
-
init
public static void init(@NotNull @NotNull Sentry.OptionsConfiguration<SentryOptions> optionsConfiguration, boolean globalHubMode) Initializes the SDK with an optional configuration options callback.- Parameters:
optionsConfiguration- configuration options callbackglobalHubMode- the globalHubMode
-
init
Initializes the SDK with a SentryOptions.- Parameters:
options- options the SentryOptions
-
close
public static void close()Close the SDK -
captureEvent
Captures the event.- Parameters:
event- the event- Returns:
- The Id (SentryId object) of the event
-
captureEvent
@NotNull public static @NotNull SentryId captureEvent(@NotNull @NotNull SentryEvent event, @NotNull @NotNull ScopeCallback callback) Captures the event.- Parameters:
event- The event.callback- The callback to configure the scope for a single invocation.- Returns:
- The Id (SentryId object) of the event
-
captureEvent
@NotNull public static @NotNull SentryId captureEvent(@NotNull @NotNull SentryEvent event, @Nullable @Nullable Hint 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 public static @NotNull SentryId captureEvent(@NotNull @NotNull SentryEvent event, @Nullable @Nullable Hint hint, @NotNull @NotNull ScopeCallback callback) Captures the event.- Parameters:
event- The event.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
-
captureMessage
Captures the message.- Parameters:
message- The message to send.- Returns:
- The Id (SentryId object) of the event
-
captureMessage
@NotNull public static @NotNull SentryId captureMessage(@NotNull @NotNull String message, @NotNull @NotNull ScopeCallback callback) Captures the message.- Parameters:
message- The message to send.callback- The callback to configure the scope for a single invocation.- Returns:
- The Id (SentryId object) of the event
-
captureMessage
@NotNull public static @NotNull SentryId captureMessage(@NotNull @NotNull 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
-
captureMessage
@NotNull public static @NotNull SentryId captureMessage(@NotNull @NotNull String message, @NotNull @NotNull SentryLevel level, @NotNull @NotNull ScopeCallback callback) Captures the message.- 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
-
captureException
Captures the exception.- Parameters:
throwable- The exception.- Returns:
- The Id (SentryId object) of the event
-
captureException
@NotNull public static @NotNull SentryId captureException(@NotNull @NotNull Throwable throwable, @NotNull @NotNull ScopeCallback callback) Captures the exception.- Parameters:
throwable- The exception.callback- The callback to configure the scope for a single invocation.- Returns:
- The Id (SentryId object) of the event
-
captureException
@NotNull public static @NotNull SentryId captureException(@NotNull @NotNull Throwable throwable, @Nullable @Nullable Hint 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 public static @NotNull SentryId captureException(@NotNull @NotNull Throwable throwable, @Nullable @Nullable Hint hint, @NotNull @NotNull ScopeCallback callback) Captures the exception.- 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
Captures a manually created user feedback and sends it to Sentry.- Parameters:
userFeedback- The user feedback to send to Sentry.
-
addBreadcrumb
public static void addBreadcrumb(@NotNull @NotNull Breadcrumb breadcrumb, @Nullable @Nullable Hint 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
Adds a breadcrumb to the current Scope- Parameters:
breadcrumb- the breadcrumb
-
addBreadcrumb
Adds a breadcrumb to the current Scope- Parameters:
message- rendered as text and the whitespace is preserved.
-
addBreadcrumb
public static void addBreadcrumb(@NotNull @NotNull String message, @NotNull @NotNull 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
Sets the level of all events sent within current Scope- Parameters:
level- the Sentry level
-
setTransaction
Sets the name of the current transaction to the current Scope.- Parameters:
transaction- the transaction
-
setUser
Shallow merges user configuration (email, username, etc) to the current Scope.- Parameters:
user- the user
-
setFingerprint
Sets the fingerprint to group specific events together to the current Scope.- Parameters:
fingerprint- the fingerprints
-
clearBreadcrumbs
public static void clearBreadcrumbs()Deletes current breadcrumbs from the current scope. -
setTag
Sets the tag to a string value to the current Scope, overwriting a potential previous value- Parameters:
key- the keyvalue- the value
-
removeTag
Removes the tag to a string value to the current Scope- Parameters:
key- the key
-
setExtra
Sets the extra key to an arbitrary value to the current Scope, overwriting a potential previous value- Parameters:
key- the keyvalue- the value
-
removeExtra
Removes the extra key to an arbitrary value to the current Scope- Parameters:
key- the key
-
getLastEventId
Last event id recorded in the current scope- Returns:
- last SentryId
-
pushScope
public static void pushScope()Pushes a new scope while inheriting the current scope's data. -
popScope
public static void popScope()Removes the first scope -
withScope
Runs the callback with a new scope which gets dropped at the end- Parameters:
callback- the callback
-
configureScope
Configures the scope through the callback.- Parameters:
callback- The configure scope callback.
-
bindClient
Binds a different client to the current hub- Parameters:
client- the client.
-
isHealthy
public static boolean isHealthy() -
flush
public static void flush(long timeoutMillis) Flushes events queued up to the current hub. Not implemented yet.- Parameters:
timeoutMillis- time in milliseconds
-
startSession
public static void startSession()Starts a new session. If there's a running session, it ends it before starting the new one. -
endSession
public static void endSession()Ends the current session -
startTransaction
@NotNull public static @NotNull ITransaction startTransaction(@NotNull @NotNull String name, @NotNull @NotNull String operation) Creates a Transaction and returns the instance. Started transaction is set on the scope.- Parameters:
name- the transaction nameoperation- the operation- Returns:
- created transaction
-
startTransaction
@NotNull public static @NotNull ITransaction startTransaction(@NotNull @NotNull String name, @NotNull @NotNull String operation, @NotNull @NotNull TransactionOptions transactionOptions) Creates a Transaction and returns the instance.- Parameters:
name- the transaction nameoperation- the operationtransactionOptions- options for the transaction- Returns:
- created transaction
-
startTransaction
@NotNull public static @NotNull ITransaction startTransaction(@NotNull @NotNull String name, @NotNull @NotNull String operation, @Nullable @Nullable String description, @NotNull @NotNull TransactionOptions transactionOptions) Creates a Transaction and returns the instance.- Parameters:
name- the transaction nameoperation- the operationdescription- the descriptiontransactionOptions- options for the transaction- Returns:
- created transaction
-
startTransaction
@NotNull public static @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContexts) Creates a Transaction and returns the instance.- Parameters:
transactionContexts- the transaction contexts- Returns:
- created transaction
-
startTransaction
@NotNull public static @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContext, @NotNull @NotNull TransactionOptions transactionOptions) Creates a Transaction and returns the instance.- Parameters:
transactionContext- the transaction contexttransactionOptions- options for the transaction- Returns:
- created transaction.
-
traceHeaders
Deprecated.please usegetTraceparent()instead.Returns the "sentry-trace" header that allows tracing across services. Can also be used in <meta> HTML tags. Also seegetBaggage().- Returns:
- sentry trace header or null
-
getSpan
Gets the current active transaction or span.- Returns:
- the active span or null when no active transaction is running. In case of globalHubMode=true, always the active transaction is returned, rather than the last active span.
-
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
-
reportFullyDisplayed
public static void reportFullyDisplayed()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.
-
reportFullDisplayed
Deprecated. -
continueTrace
@Nullable public static @Nullable TransactionContext continueTrace(@Nullable @Nullable String sentryTrace, @Nullable @Nullable List<String> baggageHeaders) Continue a trace based on HTTP header values. If no "sentry-trace" header is provided a random trace ID and span ID is created.- Parameters:
sentryTrace- "sentry-trace" headerbaggageHeaders- "baggage" headers- Returns:
- a transaction context for starting a transaction or null if performance is disabled
-
getTraceparent
Returns the "sentry-trace" header that allows tracing across services. Can also be used in <meta> HTML tags. Also seegetBaggage().- Returns:
- sentry trace header or null
-
getBaggage
Returns the "baggage" header that allows tracing across services. Can also be used in <meta> HTML tags. Also seegetTraceparent().- Returns:
- baggage header or null
-
captureCheckIn
-
reportFullyDisplayed().