Package io.sentry
Class Sentry
- java.lang.Object
-
- io.sentry.Sentry
-
public final class Sentry extends java.lang.ObjectSentry SDK main API entry point
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSentry.OptionsConfiguration<T extends SentryOptions>Configuration options callback
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddBreadcrumb(@NotNull Breadcrumb breadcrumb)Adds a breadcrumb to the current Scopestatic voidaddBreadcrumb(@NotNull Breadcrumb breadcrumb, @Nullable java.lang.Object hint)Adds a breadcrumb to the current Scopestatic voidaddBreadcrumb(@NotNull java.lang.String message)Adds a breadcrumb to the current Scopestatic voidaddBreadcrumb(@NotNull java.lang.String message, @NotNull java.lang.String category)Adds a breadcrumb to the current Scopestatic voidbindClient(@NotNull ISentryClient client)Binds a different client to the current hubstatic @NotNull SentryIdcaptureEvent(@NotNull SentryEvent event)Captures the event.static @NotNull SentryIdcaptureEvent(@NotNull SentryEvent event, @Nullable java.lang.Object hint)Captures the event.static @NotNull SentryIdcaptureException(@NotNull java.lang.Throwable throwable)Captures the exception.static @NotNull SentryIdcaptureException(@NotNull java.lang.Throwable throwable, @Nullable java.lang.Object hint)Captures the exception.static @NotNull SentryIdcaptureMessage(@NotNull java.lang.String message)Captures the message.static @NotNull SentryIdcaptureMessage(@NotNull java.lang.String message, @NotNull SentryLevel level)Captures the message.static voidcaptureUserFeedback(@NotNull UserFeedback userFeedback)Captures a manually created user feedback and sends it to Sentry.static voidclearBreadcrumbs()Deletes current breadcrumbs from the current scope.static voidclose()Close the SDKstatic voidconfigureScope(@NotNull ScopeCallback callback)Configures the scope through the callback.static voidendSession()Ends the current sessionstatic voidflush(long timeoutMillis)Flushes events queued up to the current hub.static @NotNull IHubgetCurrentHub()Returns the current (threads) hub, if none, clones the mainHub and returns it.static @NotNull SentryIdgetLastEventId()Last event id recorded in the current scopestatic @Nullable ISpangetSpan()Gets the current active transaction or span.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 voidinit(@NotNull java.lang.String dsn)Initializes the SDKstatic booleanisEnabled()Check if the current Hub is enabled/active.static voidpopScope()Removes the first scopestatic voidpushScope()Pushes a new scope while inheriting the current scope's data.static voidremoveExtra(@NotNull java.lang.String key)Removes the extra key to an arbitrary value to the current Scopestatic voidremoveTag(@NotNull java.lang.String key)Removes the tag to a string value to the current Scopestatic voidsetCurrentHub(@NotNull IHub hub)static voidsetExtra(@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 valuestatic voidsetFingerprint(@NotNull java.util.List<java.lang.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 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 valuestatic voidsetTransaction(@Nullable java.lang.String transaction)Sets the name of the current transaction to the current Scope.static voidsetUser(@Nullable User user)Shallow merges user configuration (email, username, etc) to the current Scope.static voidstartSession()Starts a new session.static @NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts)Creates a Transaction and returns the instance.static @NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts, boolean bindToScope)Creates a Transaction and returns the instance.static @NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts, @NotNull CustomSamplingContext customSamplingContext)Creates a Transaction and returns the instance.static @NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts, @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope)Creates a Transaction and returns the instance.static @NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts, @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope, @Nullable java.util.Date startTimestamp)static @NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts, @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope, @Nullable java.util.Date startTimestamp, boolean waitForChildren, @Nullable TransactionFinishedCallback transactionFinishedCallback)static @NotNull ITransactionstartTransaction(@NotNull java.lang.String name, @NotNull java.lang.String operation)Creates a Transaction and returns the instance.static @NotNull ITransactionstartTransaction(@NotNull java.lang.String name, @NotNull java.lang.String operation, boolean bindToScope)Creates a Transaction and returns the instance.static @NotNull ITransactionstartTransaction(@NotNull java.lang.String name, @NotNull java.lang.String operation, @NotNull CustomSamplingContext customSamplingContext)Creates a Transaction and returns the instance.static @NotNull ITransactionstartTransaction(@NotNull java.lang.String name, @NotNull java.lang.String operation, @NotNull CustomSamplingContext customSamplingContext, boolean bindToScope)Creates a Transaction and returns the instance.static @NotNull ITransactionstartTransaction(@NotNull java.lang.String name, @NotNull java.lang.String operation, @Nullable java.lang.String description)Creates a Transaction and returns the instance.static @NotNull ITransactionstartTransaction(@NotNull java.lang.String name, @NotNull java.lang.String operation, @Nullable java.lang.String description, boolean bindToScope)Creates a Transaction and returns the instance.static @Nullable SentryTraceHeadertraceHeaders()Returns trace header of active transaction ornullif no transaction is active.static voidwithScope(@NotNull ScopeCallback callback)Runs the callback with a new scope which gets dropped at the end
-
-
-
Method Detail
-
getCurrentHub
@Internal @NotNull public static @NotNull IHub getCurrentHub()
Returns the current (threads) hub, if none, clones the mainHub and returns it.- Returns:
- the hub
-
setCurrentHub
@Internal public static void setCurrentHub(@NotNull @NotNull IHub hub)
-
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
public static void init(@NotNull @NotNull java.lang.String dsn)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 java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
Initializes the SDK- Type Parameters:
T- class that extends SentryOptions- Parameters:
clazz- OptionsContainer for SentryOptionsoptionsConfiguration- configuration options callback- Throws:
java.lang.IllegalAccessException- the IllegalAccessExceptionjava.lang.InstantiationException- the InstantiationExceptionjava.lang.NoSuchMethodException- the NoSuchMethodExceptionjava.lang.reflect.InvocationTargetException- the InvocationTargetException
-
init
public static <T extends SentryOptions> void init(@NotNull @NotNull OptionsContainer<T> clazz, @NotNull @NotNull Sentry.OptionsConfiguration<T> optionsConfiguration, boolean globalHubMode) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
Initializes the SDK- Type Parameters:
T- class that extends SentryOptions- Parameters:
clazz- OptionsContainer for SentryOptionsoptionsConfiguration- configuration options callbackglobalHubMode- the globalHubMode- Throws:
java.lang.IllegalAccessException- the IllegalAccessExceptionjava.lang.InstantiationException- the InstantiationExceptionjava.lang.NoSuchMethodException- the NoSuchMethodExceptionjava.lang.reflect.InvocationTargetException- 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
@Internal public static void init(@NotNull @NotNull SentryOptions options)Initializes the SDK with a SentryOptions.- Parameters:
options- options the SentryOptions
-
close
public static void close()
Close the SDK
-
captureEvent
@NotNull public static @NotNull SentryId captureEvent(@NotNull @NotNull SentryEvent event)
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, @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
-
captureMessage
@NotNull public static @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 public static @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
-
captureException
@NotNull public static @NotNull SentryId captureException(@NotNull @NotNull java.lang.Throwable throwable)
Captures the exception.- Parameters:
throwable- The exception.- Returns:
- The Id (SentryId object) of the event
-
captureException
@NotNull public static @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
-
captureUserFeedback
public static 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.
-
addBreadcrumb
public static 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
public static void addBreadcrumb(@NotNull @NotNull Breadcrumb breadcrumb)Adds a breadcrumb to the current Scope- Parameters:
breadcrumb- the breadcrumb
-
addBreadcrumb
public static 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
public static 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
public static void setLevel(@Nullable @Nullable SentryLevel level)Sets the level of all events sent within current Scope- Parameters:
level- the Sentry level
-
setTransaction
public static void setTransaction(@Nullable @Nullable java.lang.String transaction)Sets the name of the current transaction to the current Scope.- Parameters:
transaction- the transaction
-
setUser
public static void setUser(@Nullable @Nullable User user)Shallow merges user configuration (email, username, etc) to the current Scope.- Parameters:
user- the user
-
setFingerprint
public static 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
public static void clearBreadcrumbs()
Deletes current breadcrumbs from the current scope.
-
setTag
public static 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
public static void removeTag(@NotNull @NotNull java.lang.String key)Removes the tag to a string value to the current Scope- Parameters:
key- the key
-
setExtra
public static 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
public static 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 public static @NotNull SentryId 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
public static void withScope(@NotNull @NotNull ScopeCallback callback)Runs the callback with a new scope which gets dropped at the end- Parameters:
callback- the callback
-
configureScope
public static void configureScope(@NotNull @NotNull ScopeCallback callback)Configures the scope through the callback.- Parameters:
callback- The configure scope callback.
-
bindClient
public static void bindClient(@NotNull @NotNull ISentryClient client)Binds a different client to the current hub- Parameters:
client- the client.
-
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 java.lang.String name, @NotNull @NotNull java.lang.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 java.lang.String name, @NotNull @NotNull java.lang.String operation, boolean bindToScope)
Creates a Transaction and returns the instance.- Parameters:
name- the transaction nameoperation- the operationbindToScope- if transaction should be bound to scope- Returns:
- created transaction
-
startTransaction
@NotNull public static @NotNull ITransaction startTransaction(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.String operation, @Nullable @Nullable java.lang.String description)
Creates a Transaction and returns the instance.- Parameters:
name- the transaction nameoperation- the operationdescription- the description- Returns:
- created transaction
-
startTransaction
@NotNull public static @NotNull ITransaction startTransaction(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.String operation, @Nullable @Nullable java.lang.String description, boolean bindToScope)
Creates a Transaction and returns the instance.- Parameters:
name- the transaction nameoperation- the operationdescription- the descriptionbindToScope- if transaction should be bound to scope- 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 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 public static @NotNull ITransaction startTransaction(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.String operation, @NotNull @NotNull 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 public static @NotNull ITransaction startTransaction(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.String operation, @NotNull @NotNull 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 public static @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContexts, @NotNull @NotNull 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 public static @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 public static @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContexts, @Nullable @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope, @Nullable @Nullable java.util.Date startTimestamp)
-
startTransaction
@Internal @NotNull public static @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)
-
traceHeaders
@Nullable public static @Nullable SentryTraceHeader traceHeaders()
Returns trace header of active transaction ornullif no transaction is active.- Returns:
- trace header or null
-
getSpan
@Nullable public static @Nullable ISpan getSpan()
Gets the current active transaction or span.- Returns:
- the active span or null when no active transaction is running
-
-