Package io.sentry
Class HubAdapter
- java.lang.Object
-
- io.sentry.HubAdapter
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBreadcrumb(@NotNull Breadcrumb breadcrumb, @Nullable java.lang.Object hint)Adds a breadcrumb to the current ScopevoidbindClient(@NotNull ISentryClient client)Binds a different client to the hub@NotNull SentryIdcaptureEnvelope(@NotNull SentryEnvelope envelope, @Nullable java.lang.Object hint)Captures an envelope.@NotNull SentryIdcaptureEvent(@NotNull SentryEvent event, @Nullable java.lang.Object hint)Captures the event.@NotNull SentryIdcaptureException(@NotNull java.lang.Throwable throwable, @Nullable java.lang.Object hint)Captures the exception.@NotNull SentryIdcaptureMessage(@NotNull java.lang.String message, @NotNull SentryLevel level)Captures the message.@NotNull SentryIdcaptureTransaction(@NotNull SentryTransaction transaction, @Nullable TraceState traceState, @Nullable java.lang.Object hint)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.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.static HubAdaptergetInstance()@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.@NotNull ITransactionstartTransaction(@NotNull TransactionContext transactionContexts)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)@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-
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, addBreadcrumb, captureEnvelope, captureEvent, captureException, captureMessage, captureTransaction, captureTransaction, startTransaction, startTransaction, startTransaction, startTransaction, startTransaction, startTransaction, startTransaction
-
-
-
-
Method Detail
-
getInstance
public static HubAdapter getInstance()
-
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 java.lang.Object 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
-
captureMessage
@NotNull public @NotNull SentryId captureMessage(@NotNull @NotNull java.lang.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
-
captureEnvelope
@Internal @NotNull public @NotNull SentryId captureEnvelope(@NotNull @NotNull SentryEnvelope envelope, @Nullable @Nullable java.lang.Object 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 java.lang.Throwable throwable, @Nullable @Nullable java.lang.Object 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
-
captureUserFeedback
public void captureUserFeedback(@NotNull @NotNull UserFeedback userFeedback)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
public void addBreadcrumb(@NotNull @NotNull Breadcrumb breadcrumb, @Nullable @Nullable java.lang.Object hint)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
-
setLevel
public void setLevel(@Nullable @Nullable SentryLevel level)Description copied from interface:IHubSets the level of all events sent within current Scope
-
setTransaction
public void setTransaction(@Nullable @Nullable java.lang.String transaction)Description copied from interface:IHubSets the name of the current transaction to the current Scope.- Specified by:
setTransactionin interfaceIHub- Parameters:
transaction- the transaction
-
setUser
public void setUser(@Nullable @Nullable User user)Description copied from interface:IHubShallow merges user configuration (email, username, etc) to the current Scope.
-
setFingerprint
public void setFingerprint(@NotNull @NotNull java.util.List<java.lang.String> fingerprint)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
public void setTag(@NotNull @NotNull java.lang.String key, @NotNull @NotNull java.lang.String value)Description copied from interface:IHubSets the tag to a string value to the current Scope, overwriting a potential previous value
-
removeTag
public void removeTag(@NotNull @NotNull java.lang.String key)Description copied from interface:IHubRemoves the tag to a string value to the current Scope
-
setExtra
public void setExtra(@NotNull @NotNull java.lang.String key, @NotNull @NotNull java.lang.String value)Description copied from interface:IHubSets the extra key to an arbitrary value to the current Scope, overwriting a potential previous value
-
removeExtra
public void removeExtra(@NotNull @NotNull java.lang.String key)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
@NotNull public @NotNull SentryId 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.
-
popScope
public void popScope()
Description copied from interface:IHubRemoves the first scope
-
withScope
public void withScope(@NotNull @NotNull ScopeCallback callback)Description copied from interface:IHubRuns the callback with a new scope which gets dropped at the end
-
configureScope
public void configureScope(@NotNull @NotNull ScopeCallback callback)Description copied from interface:IHubConfigures the scope through the callback.- Specified by:
configureScopein interfaceIHub- Parameters:
callback- The configure scope callback.
-
bindClient
public void bindClient(@NotNull @NotNull ISentryClient client)Description copied from interface:IHubBinds a different client to the hub- Specified by:
bindClientin interfaceIHub- Parameters:
client- the client.
-
flush
public void flush(long timeoutMillis)
Description copied from interface:IHubFlushes events queued up, but keeps the Hub enabled. Not implemented yet.
-
captureTransaction
@NotNull public @NotNull SentryId captureTransaction(@NotNull @NotNull SentryTransaction transaction, @Nullable @Nullable TraceState traceState, @Nullable @Nullable java.lang.Object hint)
Description copied from interface:IHubCaptures the transaction and enqueues it for sending to Sentry server.- Specified by:
captureTransactionin interfaceIHub- Parameters:
transaction- the transactiontraceState- the trace statehint- the hint- Returns:
- transaction's id
-
startTransaction
@NotNull public @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContexts)
Description copied from interface:IHubCreates a Transaction and returns the instance.- Specified by:
startTransactionin interfaceIHub- Parameters:
transactionContexts- the transaction contexts- Returns:
- created transaction
-
startTransaction
@NotNull public @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContexts, @Nullable @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope)
Description copied from interface:IHubCreates a Transaction and returns the instance. Based on the passed transaction and sampling contexts the decision if transaction is sampled will be taken byTracesSampler.- Specified by:
startTransactionin interfaceIHub- Parameters:
transactionContexts- the transaction contextcustomSamplingContext- the sampling contextbindToScope- if transaction should be bound to scope- Returns:
- created transaction.
-
startTransaction
@Internal @NotNull public @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContexts, @Nullable @Nullable CustomSamplingContext customSamplingContext, boolean bindToScope, @Nullable @Nullable java.util.Date startTimestamp)
- Specified by:
startTransactionin interfaceIHub
-
startTransaction
@Internal @NotNull public @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)
- Specified by:
startTransactionin interfaceIHub
-
traceHeaders
@Nullable public @Nullable SentryTraceHeader traceHeaders()
Description copied from interface:IHubReturns trace header of active transaction ornullif no transaction is active.- Specified by:
traceHeadersin interfaceIHub- Returns:
- trace header or null
-
setSpanContext
public void setSpanContext(@NotNull @NotNull java.lang.Throwable throwable, @NotNull @NotNull ISpan span, @NotNull @NotNull java.lang.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
-
getSpan
@Nullable public @Nullable ISpan getSpan()
Description copied from interface:IHubGets the current active transaction or span.
-
getOptions
@NotNull public @NotNull SentryOptions getOptions()
Description copied from interface:IHubGets theSentryOptionsattached to current scope.- Specified by:
getOptionsin interfaceIHub- Returns:
- the options attached to current scope.
-
isCrashedLastRun
@Nullable public @Nullable java.lang.Boolean 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
-
-