Package io.sentry

Class Scope

java.lang.Object
io.sentry.Scope

public final class Scope extends Object
Scope data to be sent with the event
  • Constructor Details

    • Scope

      public Scope(@NotNull @NotNull SentryOptions options)
      Scope's ctor
      Parameters:
      options - the options
    • Scope

      @Internal public Scope(@NotNull @NotNull Scope scope)
  • Method Details

    • getLevel

      @Nullable public @Nullable SentryLevel getLevel()
      Returns the Scope's SentryLevel
      Returns:
      the SentryLevel
    • setLevel

      public void setLevel(@Nullable @Nullable SentryLevel level)
      Sets the Scope's SentryLevel Level from scope exceptionally take precedence over the event
      Parameters:
      level - the SentryLevel
    • getTransactionName

      @Nullable public @Nullable String getTransactionName()
      Returns the Scope's transaction name.
      Returns:
      the transaction
    • setTransaction

      public void setTransaction(@NotNull @NotNull String transaction)
      Sets the Scope's transaction.
      Parameters:
      transaction - the transaction
    • getSpan

      @Nullable public @Nullable ISpan getSpan()
      Returns current active Span or Transaction.
      Returns:
      current active Span or Transaction or null if transaction has not been set.
    • setTransaction

      public void setTransaction(@Nullable @Nullable ITransaction transaction)
      Sets the current active transaction
      Parameters:
      transaction - the transaction
    • getUser

      @Nullable public @Nullable User getUser()
      Returns the Scope's user
      Returns:
      the user
    • setUser

      public void setUser(@Nullable @Nullable User user)
      Sets the Scope's user
      Parameters:
      user - the user
    • getRequest

      @Nullable public @Nullable Request getRequest()
      Returns the Scope's request
      Returns:
      the request
    • setRequest

      public void setRequest(@Nullable @Nullable Request request)
      Sets the Scope's request
      Parameters:
      request - the request
    • getFingerprint

      @Internal @NotNull public @NotNull List<String> getFingerprint()
      Returns the Scope's fingerprint list
      Returns:
      the fingerprint list
    • setFingerprint

      public void setFingerprint(@NotNull @NotNull List<String> fingerprint)
      Sets the Scope's fingerprint list
      Parameters:
      fingerprint - the fingerprint list
    • getBreadcrumbs

      @Internal @NotNull public @NotNull Queue<Breadcrumb> getBreadcrumbs()
      Returns the Scope's breadcrumbs queue
      Returns:
      the breadcrumbs queue
    • addBreadcrumb

      public void addBreadcrumb(@NotNull @NotNull Breadcrumb breadcrumb, @Nullable @Nullable Hint hint)
      Adds a breadcrumb to the breadcrumbs queue It also executes the BeforeBreadcrumb callback if set
      Parameters:
      breadcrumb - the breadcrumb
      hint - the hint
    • addBreadcrumb

      public void addBreadcrumb(@NotNull @NotNull Breadcrumb breadcrumb)
      Adds a breadcrumb to the breadcrumbs queue It also executes the BeforeBreadcrumb callback if set
      Parameters:
      breadcrumb - the breadcrumb
    • clearBreadcrumbs

      public void clearBreadcrumbs()
      Clear all the breadcrumbs
    • clearTransaction

      public void clearTransaction()
      Clears the transaction.
    • getTransaction

      @Nullable public @Nullable ITransaction getTransaction()
      Returns active transaction or null if there is no active transaction.
      Returns:
      the transaction
    • clear

      public void clear()
      Resets the Scope to its default state
    • getTags

      @Internal @NotNull public @NotNull Map<String,String> getTags()
      Returns the Scope's tags
      Returns:
      the tags map
    • setTag

      public void setTag(@NotNull @NotNull String key, @NotNull @NotNull String value)
      Sets a tag to Scope's tags
      Parameters:
      key - the key
      value - the value
    • removeTag

      public void removeTag(@NotNull @NotNull String key)
      Removes a tag from the Scope's tags
      Parameters:
      key - the key
    • getExtras

      @Internal @NotNull public @NotNull Map<String,Object> getExtras()
      Returns the Scope's extra map
      Returns:
      the extra map
    • setExtra

      public void setExtra(@NotNull @NotNull String key, @NotNull @NotNull String value)
      Sets an extra to the Scope's extra map
      Parameters:
      key - the key
      value - the value
    • removeExtra

      public void removeExtra(@NotNull @NotNull String key)
      Removes an extra from the Scope's extras
      Parameters:
      key - the key
    • getContexts

      @NotNull public @NotNull Contexts getContexts()
      Returns the Scope's contexts
      Returns:
      the contexts
    • setContexts

      public void setContexts(@NotNull @NotNull String key, @NotNull @NotNull Object value)
      Sets the Scope's contexts
      Parameters:
      key - the context key
      value - the context value
    • setContexts

      public void setContexts(@NotNull @NotNull String key, @NotNull @NotNull Boolean value)
      Sets the Scope's contexts
      Parameters:
      key - the context key
      value - the context value
    • setContexts

      public void setContexts(@NotNull @NotNull String key, @NotNull @NotNull String value)
      Sets the Scope's contexts
      Parameters:
      key - the context key
      value - the context value
    • setContexts

      public void setContexts(@NotNull @NotNull String key, @NotNull @NotNull Number value)
      Sets the Scope's contexts
      Parameters:
      key - the context key
      value - the context value
    • setContexts

      public void setContexts(@NotNull @NotNull String key, @NotNull @NotNull Collection<?> value)
      Sets the Scope's contexts
      Parameters:
      key - the context key
      value - the context value
    • setContexts

      public void setContexts(@NotNull @NotNull String key, @NotNull @NotNull Object[] value)
      Sets the Scope's contexts
      Parameters:
      key - the context key
      value - the context value
    • setContexts

      public void setContexts(@NotNull @NotNull String key, @NotNull @NotNull Character value)
      Sets the Scope's contexts
      Parameters:
      key - the context key
      value - the context value
    • removeContexts

      public void removeContexts(@NotNull @NotNull String key)
      Removes a value from the Scope's contexts
      Parameters:
      key - the Key
    • addAttachment

      public void addAttachment(@NotNull @NotNull Attachment attachment)
      Adds an attachment to the Scope's list of attachments. The SDK adds the attachment to every event and transaction sent to Sentry.
      Parameters:
      attachment - The attachment to add to the Scope's list of attachments.
    • clearAttachments

      public void clearAttachments()
      Clear all attachments.
    • addEventProcessor

      public void addEventProcessor(@NotNull @NotNull EventProcessor eventProcessor)
      Adds an event processor to the Scope's event processors list
      Parameters:
      eventProcessor - the event processor
    • withTransaction

      @Internal public void withTransaction(@NotNull @NotNull Scope.IWithTransaction callback)
      Mutates the current transaction atomically
      Parameters:
      callback - the IWithTransaction callback
    • getSession

      @Internal @Nullable public @Nullable Session getSession()
    • setPropagationContext

      @Internal public void setPropagationContext(@NotNull @NotNull PropagationContext propagationContext)
    • getPropagationContext

      @Internal @NotNull public @NotNull PropagationContext getPropagationContext()
    • withPropagationContext

      @Internal @NotNull public @NotNull PropagationContext withPropagationContext(@NotNull @NotNull Scope.IWithPropagationContext callback)