Package io.sentry

Class HubAdapter

  • All Implemented Interfaces:
    IHub

    public final class HubAdapter
    extends java.lang.Object
    implements IHub
    • Method Detail

      • getInstance

        public static HubAdapter getInstance()
      • isEnabled

        public boolean isEnabled()
        Description copied from interface: IHub
        Check if the Hub is enabled/active.
        Specified by:
        isEnabled in interface IHub
        Returns:
        true if its enabled or false otherwise.
      • captureEvent

        @NotNull
        public @NotNull SentryId captureEvent​(@NotNull
                                              @NotNull SentryEvent event,
                                              @Nullable
                                              @Nullable java.lang.Object hint)
        Description copied from interface: IHub
        Captures the event.
        Specified by:
        captureEvent in interface IHub
        Parameters:
        event - the event
        hint - 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: IHub
        Captures the message.
        Specified by:
        captureMessage in interface IHub
        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: IHub
        Captures an envelope.
        Specified by:
        captureEnvelope in interface IHub
        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: IHub
        Captures the exception.
        Specified by:
        captureException in interface IHub
        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: IHub
        Captures a manually created user feedback and sends it to Sentry.
        Specified by:
        captureUserFeedback in interface IHub
        Parameters:
        userFeedback - The user feedback to send to Sentry.
      • startSession

        public void startSession()
        Description copied from interface: IHub
        Starts a new session. If there's a running session, it ends it before starting the new one.
        Specified by:
        startSession in interface IHub
      • endSession

        public void endSession()
        Description copied from interface: IHub
        Ends the current session
        Specified by:
        endSession in interface IHub
      • close

        public void close()
        Description copied from interface: IHub
        Flushes out the queue for up to timeout seconds and disable the Hub.
        Specified by:
        close in interface IHub
      • addBreadcrumb

        public void addBreadcrumb​(@NotNull
                                  @NotNull Breadcrumb breadcrumb,
                                  @Nullable
                                  @Nullable java.lang.Object hint)
        Description copied from interface: IHub
        Adds a breadcrumb to the current Scope
        Specified by:
        addBreadcrumb in interface IHub
        Parameters:
        breadcrumb - the breadcrumb
        hint - 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: IHub
        Sets the level of all events sent within current Scope
        Specified by:
        setLevel in interface IHub
        Parameters:
        level - the Sentry level
      • setTransaction

        public void setTransaction​(@Nullable
                                   @Nullable java.lang.String transaction)
        Description copied from interface: IHub
        Sets the name of the current transaction to the current Scope.
        Specified by:
        setTransaction in interface IHub
        Parameters:
        transaction - the transaction
      • setUser

        public void setUser​(@Nullable
                            @Nullable User user)
        Description copied from interface: IHub
        Shallow merges user configuration (email, username, etc) to the current Scope.
        Specified by:
        setUser in interface IHub
        Parameters:
        user - the user
      • setFingerprint

        public void setFingerprint​(@NotNull
                                   @NotNull java.util.List<java.lang.String> fingerprint)
        Description copied from interface: IHub
        Sets the fingerprint to group specific events together to the current Scope.
        Specified by:
        setFingerprint in interface IHub
        Parameters:
        fingerprint - the fingerprints
      • clearBreadcrumbs

        public void clearBreadcrumbs()
        Description copied from interface: IHub
        Deletes current breadcrumbs from the current scope.
        Specified by:
        clearBreadcrumbs in interface IHub
      • setTag

        public void setTag​(@NotNull
                           @NotNull java.lang.String key,
                           @NotNull
                           @NotNull java.lang.String value)
        Description copied from interface: IHub
        Sets the tag to a string value to the current Scope, overwriting a potential previous value
        Specified by:
        setTag in interface IHub
        Parameters:
        key - the key
        value - the value
      • removeTag

        public void removeTag​(@NotNull
                              @NotNull java.lang.String key)
        Description copied from interface: IHub
        Removes the tag to a string value to the current Scope
        Specified by:
        removeTag in interface IHub
        Parameters:
        key - the key
      • setExtra

        public void setExtra​(@NotNull
                             @NotNull java.lang.String key,
                             @NotNull
                             @NotNull java.lang.String value)
        Description copied from interface: IHub
        Sets the extra key to an arbitrary value to the current Scope, overwriting a potential previous value
        Specified by:
        setExtra in interface IHub
        Parameters:
        key - the key
        value - the value
      • removeExtra

        public void removeExtra​(@NotNull
                                @NotNull java.lang.String key)
        Description copied from interface: IHub
        Removes the extra key to an arbitrary value to the current Scope
        Specified by:
        removeExtra in interface IHub
        Parameters:
        key - the key
      • getLastEventId

        @NotNull
        public @NotNull SentryId getLastEventId()
        Description copied from interface: IHub
        Last event id recorded in the current scope
        Specified by:
        getLastEventId in interface IHub
        Returns:
        last SentryId
      • pushScope

        public void pushScope()
        Description copied from interface: IHub
        Pushes a new scope while inheriting the current scope's data.
        Specified by:
        pushScope in interface IHub
      • popScope

        public void popScope()
        Description copied from interface: IHub
        Removes the first scope
        Specified by:
        popScope in interface IHub
      • withScope

        public void withScope​(@NotNull
                              @NotNull ScopeCallback callback)
        Description copied from interface: IHub
        Runs the callback with a new scope which gets dropped at the end
        Specified by:
        withScope in interface IHub
        Parameters:
        callback - the callback
      • configureScope

        public void configureScope​(@NotNull
                                   @NotNull ScopeCallback callback)
        Description copied from interface: IHub
        Configures the scope through the callback.
        Specified by:
        configureScope in interface IHub
        Parameters:
        callback - The configure scope callback.
      • bindClient

        public void bindClient​(@NotNull
                               @NotNull ISentryClient client)
        Description copied from interface: IHub
        Binds a different client to the hub
        Specified by:
        bindClient in interface IHub
        Parameters:
        client - the client.
      • flush

        public void flush​(long timeoutMillis)
        Description copied from interface: IHub
        Flushes events queued up, but keeps the Hub enabled. Not implemented yet.
        Specified by:
        flush in interface IHub
        Parameters:
        timeoutMillis - time in milliseconds
      • clone

        @NotNull
        public @NotNull IHub clone()
        Description copied from interface: IHub
        Clones the Hub
        Specified by:
        clone in interface IHub
        Overrides:
        clone in class java.lang.Object
        Returns:
        the cloned Hub
      • captureTransaction

        @NotNull
        public @NotNull SentryId captureTransaction​(@NotNull
                                                    @NotNull SentryTransaction transaction,
                                                    @Nullable
                                                    @Nullable TraceState traceState,
                                                    @Nullable
                                                    @Nullable java.lang.Object hint)
        Description copied from interface: IHub
        Captures the transaction and enqueues it for sending to Sentry server.
        Specified by:
        captureTransaction in interface IHub
        Parameters:
        transaction - the transaction
        traceState - the trace state
        hint - the hint
        Returns:
        transaction's id
      • startTransaction

        @NotNull
        public @NotNull ITransaction startTransaction​(@NotNull
                                                      @NotNull TransactionContext transactionContexts)
        Description copied from interface: IHub
        Creates a Transaction and returns the instance.
        Specified by:
        startTransaction in interface IHub
        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: IHub
        Creates a Transaction and returns the instance. Based on the passed transaction and sampling contexts the decision if transaction is sampled will be taken by TracesSampler.
        Specified by:
        startTransaction in interface IHub
        Parameters:
        transactionContexts - the transaction context
        customSamplingContext - the sampling context
        bindToScope - if transaction should be bound to scope
        Returns:
        created transaction.
      • traceHeaders

        @Nullable
        public @Nullable SentryTraceHeader traceHeaders()
        Description copied from interface: IHub
        Returns trace header of active transaction or null if no transaction is active.
        Specified by:
        traceHeaders in interface IHub
        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: IHub
        Associates ISpan and the transaction name with the Throwable. Used to determine in which trace the exception has been thrown in framework integrations.
        Specified by:
        setSpanContext in interface IHub
        Parameters:
        throwable - the throwable
        span - the span context
        transactionName - the transaction name
      • getSpan

        @Nullable
        public @Nullable ISpan getSpan()
        Description copied from interface: IHub
        Gets the current active transaction or span.
        Specified by:
        getSpan in interface IHub
        Returns:
        the active span or null when no active transaction is running
      • getOptions

        @NotNull
        public @NotNull SentryOptions getOptions()
        Description copied from interface: IHub
        Gets the SentryOptions attached to current scope.
        Specified by:
        getOptions in interface IHub
        Returns:
        the options attached to current scope.
      • isCrashedLastRun

        @Nullable
        public @Nullable java.lang.Boolean isCrashedLastRun()
        Description copied from interface: IHub
        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.

        Specified by:
        isCrashedLastRun in interface IHub
        Returns:
        true if App has crashed, false otherwise, and null if not evaluated yet