Package io.sentry

Class NoOpScopes

java.lang.Object
io.sentry.NoOpScopes
All Implemented Interfaces:
IScopes

public final class NoOpScopes extends Object implements IScopes
  • Method Details

    • getInstance

      public static NoOpScopes getInstance()
    • isEnabled

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

      @NotNull public @NotNull SentryId captureEvent(@NotNull @NotNull SentryEvent event, @Nullable @Nullable Hint hint)
      Description copied from interface: IScopes
      Captures the event.
      Specified by:
      captureEvent in interface IScopes
      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
    • captureEvent

      @NotNull public @NotNull SentryId captureEvent(@NotNull @NotNull SentryEvent event, @Nullable @Nullable Hint hint, @NotNull @NotNull ScopeCallback callback)
      Description copied from interface: IScopes
      Captures the event.
      Specified by:
      captureEvent in interface IScopes
      Parameters:
      event - the event
      hint - SDK specific but provides high level information about the origin of the event
      callback - The callback to configure the scope for a single invocation.
      Returns:
      The Id (SentryId object) of the event
    • captureMessage

      @NotNull public @NotNull SentryId captureMessage(@NotNull @NotNull String message, @NotNull @NotNull SentryLevel level)
      Description copied from interface: IScopes
      Captures the message.
      Specified by:
      captureMessage in interface IScopes
      Parameters:
      message - The message to send.
      level - The message level.
      Returns:
      The Id (SentryId object) of the event
    • captureMessage

      @NotNull public @NotNull SentryId captureMessage(@NotNull @NotNull String message, @NotNull @NotNull SentryLevel level, @NotNull @NotNull ScopeCallback callback)
      Description copied from interface: IScopes
      Captures the message.
      Specified by:
      captureMessage in interface IScopes
      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
    • captureEnvelope

      @NotNull public @NotNull SentryId captureEnvelope(@NotNull @NotNull SentryEnvelope envelope, @Nullable @Nullable Hint hint)
      Description copied from interface: IScopes
      Captures an envelope.
      Specified by:
      captureEnvelope in interface IScopes
      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 Throwable throwable, @Nullable @Nullable Hint hint)
      Description copied from interface: IScopes
      Captures the exception.
      Specified by:
      captureException in interface IScopes
      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 @NotNull SentryId captureException(@NotNull @NotNull Throwable throwable, @Nullable @Nullable Hint hint, @NotNull @NotNull ScopeCallback callback)
      Description copied from interface: IScopes
      Captures the exception.
      Specified by:
      captureException in interface IScopes
      Parameters:
      throwable - The exception.
      hint - SDK specific but provides high level information about the origin of the event
      callback - The callback to configure the scope for a single invocation.
      Returns:
      The Id (SentryId object) of the event
    • captureUserFeedback

      public void captureUserFeedback(@NotNull @NotNull UserFeedback userFeedback)
      Description copied from interface: IScopes
      Captures a manually created user feedback and sends it to Sentry.
      Specified by:
      captureUserFeedback in interface IScopes
      Parameters:
      userFeedback - The user feedback to send to Sentry.
    • startSession

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

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

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

      public void close(boolean isRestarting)
      Description copied from interface: IScopes
      Flushes out the queue for up to timeout seconds and disable the Scopes.
      Specified by:
      close in interface IScopes
      Parameters:
      isRestarting - if true, avoids locking the main thread when finishing the queue.
    • addBreadcrumb

      public void addBreadcrumb(@NotNull @NotNull Breadcrumb breadcrumb, @Nullable @Nullable Hint hint)
      Description copied from interface: IScopes
      Adds a breadcrumb to the current Scope
      Specified by:
      addBreadcrumb in interface IScopes
      Parameters:
      breadcrumb - the breadcrumb
      hint - SDK specific but provides high level information about the origin of the event
    • addBreadcrumb

      public void addBreadcrumb(@NotNull @NotNull Breadcrumb breadcrumb)
      Description copied from interface: IScopes
      Adds a breadcrumb to the current Scope
      Specified by:
      addBreadcrumb in interface IScopes
      Parameters:
      breadcrumb - the breadcrumb
    • setLevel

      public void setLevel(@Nullable @Nullable SentryLevel level)
      Description copied from interface: IScopes
      Sets the level of all events sent within current Scope
      Specified by:
      setLevel in interface IScopes
      Parameters:
      level - the Sentry level
    • setTransaction

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

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

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

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

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

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

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

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

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

      @NotNull public @NotNull ISentryLifecycleToken pushScope()
      Description copied from interface: IScopes
      Pushes a new scope while inheriting the current scope's data.
      Specified by:
      pushScope in interface IScopes
    • pushIsolationScope

      @NotNull public @NotNull ISentryLifecycleToken pushIsolationScope()
      Specified by:
      pushIsolationScope in interface IScopes
    • popScope

      @Deprecated public void popScope()
      Deprecated.
      please call ISentryLifecycleToken.close() on the token returned by IScopes.pushScope() or IScopes.pushIsolationScope() instead.
      Description copied from interface: IScopes
      Removes the first scope and restores its parent.
      Specified by:
      popScope in interface IScopes
    • withScope

      public void withScope(@NotNull @NotNull ScopeCallback callback)
      Description copied from interface: IScopes
      Runs the callback with a new current scope which gets dropped at the end.

      If you're using the Sentry SDK in globalHubMode (defaults to true on Android) Sentry.init(Sentry.OptionsConfiguration, boolean) calling withScope is discouraged, as scope changes may be dropped when executed in parallel. Use IScopes.configureScope(ScopeCallback) instead.

      Specified by:
      withScope in interface IScopes
      Parameters:
      callback - the callback
    • withIsolationScope

      public void withIsolationScope(@NotNull @NotNull ScopeCallback callback)
      Description copied from interface: IScopes
      Runs the callback with a new isolation scope which gets dropped at the end. Current scope is also forked.

      If you're using the Sentry SDK in globalHubMode (defaults to true on Android) Sentry.init(Sentry.OptionsConfiguration, boolean) calling withScope is discouraged, as scope changes may be dropped when executed in parallel. Use IScopes.configureScope(ScopeType, ScopeCallback) instead.

      Specified by:
      withIsolationScope in interface IScopes
      Parameters:
      callback - the callback
    • configureScope

      public void configureScope(@Nullable @Nullable ScopeType scopeType, @NotNull @NotNull ScopeCallback callback)
      Description copied from interface: IScopes
      Configures the scope through the callback.
      Specified by:
      configureScope in interface IScopes
      callback - The configure scope callback.
    • bindClient

      public void bindClient(@NotNull @NotNull ISentryClient client)
      Description copied from interface: IScopes
      Binds a different client to the scopes
      Specified by:
      bindClient in interface IScopes
      Parameters:
      client - the client.
    • isHealthy

      public boolean isHealthy()
      Description copied from interface: IScopes
      Whether the transport is healthy.
      Specified by:
      isHealthy in interface IScopes
      Returns:
      true if the transport is healthy
    • flush

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

      @Deprecated @NotNull public @NotNull IHub clone()
      Description copied from interface: IScopes
      Clones the Hub
      Specified by:
      clone in interface IScopes
      Overrides:
      clone in class Object
      Returns:
      the cloned Hub
    • forkedScopes

      @NotNull public @NotNull IScopes forkedScopes(@NotNull @NotNull String creator)
      Description copied from interface: IScopes
      Creates a fork of both current and isolation scope from current scopes.
      Specified by:
      forkedScopes in interface IScopes
      Parameters:
      creator - debug information to see why scopes where forked
      Returns:
      forked Scopes
    • forkedCurrentScope

      @NotNull public @NotNull IScopes forkedCurrentScope(@NotNull @NotNull String creator)
      Description copied from interface: IScopes
      Creates a fork of current scope without forking isolation scope.
      Specified by:
      forkedCurrentScope in interface IScopes
      Parameters:
      creator - debug information to see why scopes where forked
      Returns:
      forked Scopes
    • forkedRootScopes

      @NotNull public @NotNull IScopes forkedRootScopes(@NotNull @NotNull String creator)
      Description copied from interface: IScopes
      Creates a fork of both current and isolation scope from root scopes.
      Specified by:
      forkedRootScopes in interface IScopes
      Parameters:
      creator - debug information to see why scopes where forked
      Returns:
      forked Scopes
    • makeCurrent

      @NotNull public @NotNull ISentryLifecycleToken makeCurrent()
      Description copied from interface: IScopes
      Stores this Scopes in store, making it the current one that is used by static API.
      Specified by:
      makeCurrent in interface IScopes
      Returns:
      a token you should call .close() on when you're done.
    • getScope

      @Internal @NotNull public @NotNull IScope getScope()
      Description copied from interface: IScopes
      Returns the current scope of this Scopes.
      Specified by:
      getScope in interface IScopes
      Returns:
      scope
    • getIsolationScope

      @Internal @NotNull public @NotNull IScope getIsolationScope()
      Description copied from interface: IScopes
      Returns the isolation scope of this Scopes.
      Specified by:
      getIsolationScope in interface IScopes
      Returns:
      isolation scope
    • getGlobalScope

      @Internal @NotNull public @NotNull IScope getGlobalScope()
      Description copied from interface: IScopes
      Returns the global scope.
      Specified by:
      getGlobalScope in interface IScopes
      Returns:
      global scope
    • getParentScopes

      @Nullable public @Nullable IScopes getParentScopes()
      Description copied from interface: IScopes
      Returns the parent of this Scopes instance or null, if it does not have a parent. The parent is the Scopes instance this instance was forked from.
      Specified by:
      getParentScopes in interface IScopes
      Returns:
      parent Scopes or null
    • isAncestorOf

      public boolean isAncestorOf(@Nullable @Nullable IScopes otherScopes)
      Description copied from interface: IScopes
      Checks whether this Scopes instance is direct or indirect parent of the other Scopes instance.
      Specified by:
      isAncestorOf in interface IScopes
      Parameters:
      otherScopes - Scopes instance that could be a direct or indirect child.
      Returns:
      true if this Scopes instance is a direct or indirect parent of the other Scopes.
    • captureTransaction

      @NotNull public @NotNull SentryId captureTransaction(@NotNull @NotNull SentryTransaction transaction, @Nullable @Nullable TraceContext traceContext, @Nullable @Nullable Hint hint, @Nullable @Nullable ProfilingTraceData profilingTraceData)
      Description copied from interface: IScopes
      Captures the transaction and enqueues it for sending to Sentry server.
      Specified by:
      captureTransaction in interface IScopes
      Parameters:
      transaction - the transaction
      traceContext - the trace context
      hint - the hints
      profilingTraceData - the profiling trace data
      Returns:
      transaction's id
    • startTransaction

      @NotNull public @NotNull ITransaction startTransaction(@NotNull @NotNull TransactionContext transactionContext, @NotNull @NotNull TransactionOptions transactionOptions)
      Description copied from interface: IScopes
      Creates a Transaction and returns the instance. Based on the passed transaction context and transaction options the decision if transaction is sampled will be taken by TracesSampler.
      Specified by:
      startTransaction in interface IScopes
      Parameters:
      transactionContext - the transaction context
      transactionOptions - the transaction options
      Returns:
      created transaction.
    • setSpanContext

      public void setSpanContext(@NotNull @NotNull Throwable throwable, @NotNull @NotNull ISpan spanContext, @NotNull @NotNull String transactionName)
      Description copied from interface: IScopes
      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 IScopes
      Parameters:
      throwable - the throwable
      spanContext - the span context
      transactionName - the transaction name
    • getSpan

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

      public void setActiveSpan(@Nullable @Nullable ISpan span)
      Specified by:
      setActiveSpan in interface IScopes
    • getTransaction

      @Nullable public @Nullable ITransaction getTransaction()
      Description copied from interface: IScopes
      Returns the transaction.
      Specified by:
      getTransaction in interface IScopes
      Returns:
      the transaction or null when no active transaction is running.
    • getOptions

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

      @Nullable public @Nullable Boolean isCrashedLastRun()
      Description copied from interface: IScopes
      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 IScopes
      Returns:
      true if App has crashed, false otherwise, and null if not evaluated yet
    • reportFullyDisplayed

      public void reportFullyDisplayed()
      Description copied from interface: IScopes
      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.

      Specified by:
      reportFullyDisplayed in interface IScopes
    • continueTrace

      @Nullable public @Nullable TransactionContext continueTrace(@Nullable @Nullable String sentryTrace, @Nullable @Nullable List<String> baggageHeaders)
      Description copied from interface: IScopes
      Continue a trace based on HTTP header values. If no "sentry-trace" header is provided a random trace ID and span ID is created.
      Specified by:
      continueTrace in interface IScopes
      Parameters:
      sentryTrace - "sentry-trace" header
      baggageHeaders - "baggage" headers
      Returns:
      a transaction context for starting a transaction or null if performance is disabled
    • getTraceparent

      @Nullable public @Nullable SentryTraceHeader getTraceparent()
      Description copied from interface: IScopes
      Returns the "sentry-trace" header that allows tracing across services. Can also be used in <meta> HTML tags. Also see IScopes.getBaggage().
      Specified by:
      getTraceparent in interface IScopes
      Returns:
      sentry trace header or null
    • getBaggage

      @Nullable public @Nullable BaggageHeader getBaggage()
      Description copied from interface: IScopes
      Returns the "baggage" header that allows tracing across services. Can also be used in <meta> HTML tags. Also see IScopes.getTraceparent().
      Specified by:
      getBaggage in interface IScopes
      Returns:
      baggage header or null
    • captureCheckIn

      @Experimental @NotNull public @NotNull SentryId captureCheckIn(@NotNull @NotNull CheckIn checkIn)
      Specified by:
      captureCheckIn in interface IScopes
    • getRateLimiter

      @Nullable public @Nullable RateLimiter getRateLimiter()
      Specified by:
      getRateLimiter in interface IScopes
    • isNoOp

      public boolean isNoOp()
      Specified by:
      isNoOp in interface IScopes
    • captureReplay

      @NotNull public @NotNull SentryId captureReplay(@NotNull @NotNull SentryReplayEvent replay, @Nullable @Nullable Hint hint)
      Specified by:
      captureReplay in interface IScopes