Package io.sentry

Class SentryOptions


  • public class SentryOptions
    extends java.lang.Object
    Sentry SDK options
    • Constructor Detail

      • SentryOptions

        public SentryOptions()
        SentryOptions ctor It adds and set default things
    • Method Detail

      • addEventProcessor

        public void addEventProcessor​(@NotNull
                                      @NotNull EventProcessor eventProcessor)
        Adds an event processor
        Parameters:
        eventProcessor - the event processor
      • getEventProcessors

        @NotNull
        public @NotNull java.util.List<EventProcessor> getEventProcessors()
        Returns the list of event processors
        Returns:
        the event processor list
      • addIntegration

        public void addIntegration​(@NotNull
                                   @NotNull Integration integration)
        Adds an integration
        Parameters:
        integration - the integration
      • getIntegrations

        @NotNull
        public @NotNull java.util.List<Integration> getIntegrations()
        Returns the list of integrations
        Returns:
        the integration list
      • getDsn

        @Nullable
        public @Nullable java.lang.String getDsn()
        Returns the DSN
        Returns:
        the DSN or null if not set
      • setDsn

        public void setDsn​(@Nullable
                           @Nullable java.lang.String dsn)
        Sets the DSN
        Parameters:
        dsn - the DSN
      • isDebug

        public boolean isDebug()
        Check if debug mode is ON Default is OFF
        Returns:
        true if ON or false otherwise
      • setDebug

        public void setDebug​(@Nullable
                             @Nullable java.lang.Boolean debug)
        Sets the debug mode to ON or OFF Default is OFF
        Parameters:
        debug - true if ON or false otherwise
      • getLogger

        @NotNull
        public @NotNull ILogger getLogger()
        Returns the Logger interface
        Returns:
        the logger
      • setLogger

        public void setLogger​(@Nullable
                              @Nullable ILogger logger)
        Sets the Logger interface if null, logger will be NoOp
        Parameters:
        logger - the logger interface
      • getDiagnosticLevel

        @NotNull
        public @NotNull SentryLevel getDiagnosticLevel()
        Returns the minimum LogLevel
        Returns:
        the log level
      • setDiagnosticLevel

        public void setDiagnosticLevel​(@Nullable
                                       @Nullable SentryLevel diagnosticLevel)
        Sets the minimum LogLevel if null, it uses the default min. LogLevel Default is DEBUG
        Parameters:
        diagnosticLevel - the log level
      • getSerializer

        @NotNull
        public @NotNull ISerializer getSerializer()
        Returns the Serializer interface
        Returns:
        the serializer
      • setSerializer

        public void setSerializer​(@Nullable
                                  @Nullable ISerializer serializer)
        Sets the Serializer interface if null, Serializer will be NoOp
        Parameters:
        serializer - the serializer
      • getEnvelopeReader

        @NotNull
        public @NotNull IEnvelopeReader getEnvelopeReader()
      • setEnvelopeReader

        public void setEnvelopeReader​(@Nullable
                                      @Nullable IEnvelopeReader envelopeReader)
      • isEnableNdk

        public boolean isEnableNdk()
        Check if NDK is ON or OFF Default is ON
        Returns:
        true if ON or false otherwise
      • setEnableNdk

        public void setEnableNdk​(boolean enableNdk)
        Sets NDK to ON or OFF
        Parameters:
        enableNdk - true if ON or false otherwise
      • getShutdownTimeout

        public long getShutdownTimeout()
        Returns the shutdown timeout in Millis
        Returns:
        the timeout in Millis
      • setShutdownTimeout

        public void setShutdownTimeout​(long shutdownTimeoutMillis)
        Sets the shutdown timeout in Millis Default is 2000 = 2s
        Parameters:
        shutdownTimeoutMillis - the shutdown timeout in millis
      • getSentryClientName

        @Nullable
        public @Nullable java.lang.String getSentryClientName()
        Returns the Sentry client name
        Returns:
        the Sentry client name or null if not set
      • setSentryClientName

        public void setSentryClientName​(@Nullable
                                        @Nullable java.lang.String sentryClientName)
        Sets the Sentry client name
        Parameters:
        sentryClientName - the Sentry client name
      • getBeforeSend

        @Nullable
        public @Nullable SentryOptions.BeforeSendCallback getBeforeSend()
        Returns the BeforeSend callback
        Returns:
        the beforeSend callback or null if not set
      • setBeforeSend

        public void setBeforeSend​(@Nullable
                                  @Nullable SentryOptions.BeforeSendCallback beforeSend)
        Sets the beforeSend callback
        Parameters:
        beforeSend - the beforeSend callback
      • getBeforeBreadcrumb

        @Nullable
        public @Nullable SentryOptions.BeforeBreadcrumbCallback getBeforeBreadcrumb()
        Returns the beforeBreadcrumb callback
        Returns:
        the beforeBreadcrumb callback or null if not set
      • setBeforeBreadcrumb

        public void setBeforeBreadcrumb​(@Nullable
                                        @Nullable SentryOptions.BeforeBreadcrumbCallback beforeBreadcrumb)
        Sets the beforeBreadcrumb callback
        Parameters:
        beforeBreadcrumb - the beforeBreadcrumb callback
      • getCacheDirPath

        @Nullable
        public @Nullable java.lang.String getCacheDirPath()
        Returns the cache dir. path if set
        Returns:
        the cache dir. path or null if not set
      • getOutboxPath

        @Nullable
        public @Nullable java.lang.String getOutboxPath()
        Returns the outbox path if cacheDirPath is set
        Returns:
        the outbox path or null if not set
      • setCacheDirPath

        public void setCacheDirPath​(@Nullable
                                    @Nullable java.lang.String cacheDirPath)
        Sets the cache dir. path
        Parameters:
        cacheDirPath - the cache dir. path
      • getCacheDirSize

        @Deprecated
        public int getCacheDirSize()
        Deprecated.
        Returns the cache dir. size Default is 30
        Returns:
        the cache dir. size
      • setCacheDirSize

        @Deprecated
        public void setCacheDirSize​(int cacheDirSize)
        Deprecated.
        Sets the cache dir. size Default is 30
        Parameters:
        cacheDirSize - the cache dir. size
      • getMaxBreadcrumbs

        public int getMaxBreadcrumbs()
        Returns the max Breadcrumbs Default is 100
        Returns:
        the max breadcrumbs
      • setMaxBreadcrumbs

        public void setMaxBreadcrumbs​(int maxBreadcrumbs)
        Sets the max breadcrumbs Default is 100
        Parameters:
        maxBreadcrumbs - the max breadcrumbs
      • getRelease

        @Nullable
        public @Nullable java.lang.String getRelease()
        Returns the release
        Returns:
        the release or null if not set
      • setRelease

        public void setRelease​(@Nullable
                               @Nullable java.lang.String release)
        Sets the release
        Parameters:
        release - the release
      • getEnvironment

        @Nullable
        public @Nullable java.lang.String getEnvironment()
        Returns the environment
        Returns:
        the environment or null if not set
      • setEnvironment

        public void setEnvironment​(@Nullable
                                   @Nullable java.lang.String environment)
        Sets the environment
        Parameters:
        environment - the environment
      • getProxy

        @Nullable
        public @Nullable SentryOptions.Proxy getProxy()
        Returns the proxy if set
        Returns:
        the proxy or null if not set
      • setProxy

        public void setProxy​(@Nullable
                             @Nullable SentryOptions.Proxy proxy)
        Sets the proxy
        Parameters:
        proxy - the proxy
      • getSampleRate

        @Nullable
        public @Nullable java.lang.Double getSampleRate()
        Returns the sample rate Default is null (disabled)
        Returns:
        the sample rate
      • setSampleRate

        public void setSampleRate​(java.lang.Double sampleRate)
        Sets the sampleRate Can be anything between 0.01 and 1.0 or null (default), to disable it.
        Parameters:
        sampleRate - the sample rate
      • getTracesSampleRate

        @Nullable
        public @Nullable java.lang.Double getTracesSampleRate()
        Returns the traces sample rate Default is null (disabled)
        Returns:
        the sample rate
      • setTracesSampleRate

        public void setTracesSampleRate​(@Nullable
                                        @Nullable java.lang.Double tracesSampleRate)
        Sets the tracesSampleRate Can be anything between 0.0 and 1.0 or null (default), to disable it.
        Parameters:
        tracesSampleRate - the sample rate
      • getTracesSampler

        @Nullable
        public @Nullable SentryOptions.TracesSamplerCallback getTracesSampler()
        Returns the callback used to determine if transaction is sampled.
        Returns:
        the callback
      • setTracesSampler

        public void setTracesSampler​(@Nullable
                                     @Nullable SentryOptions.TracesSamplerCallback tracesSampler)
        Sets the callback used to determine if transaction is sampled.
        Parameters:
        tracesSampler - the callback
      • getInAppExcludes

        @NotNull
        public @NotNull java.util.List<java.lang.String> getInAppExcludes()
        the list of inApp excludes
        Returns:
        the inApp excludes list
      • addInAppExclude

        public void addInAppExclude​(@NotNull
                                    @NotNull java.lang.String exclude)
        Adds an inApp exclude
        Parameters:
        exclude - the inApp exclude module/package
      • getInAppIncludes

        @NotNull
        public @NotNull java.util.List<java.lang.String> getInAppIncludes()
        Returns the inApp includes list
        Returns:
        the inApp includes list
      • addInAppInclude

        public void addInAppInclude​(@NotNull
                                    @NotNull java.lang.String include)
        Adds an inApp include
        Parameters:
        include - the inApp include module/package
      • getTransportFactory

        @NotNull
        public @NotNull ITransportFactory getTransportFactory()
        Returns the TransportFactory interface
        Returns:
        the transport factory
      • setTransportFactory

        public void setTransportFactory​(@Nullable
                                        @Nullable ITransportFactory transportFactory)
        Sets the TransportFactory interface
        Parameters:
        transportFactory - the transport factory
      • getDist

        @Nullable
        public @Nullable java.lang.String getDist()
        Sets the distribution
        Returns:
        the distribution or null if not set
      • setDist

        public void setDist​(@Nullable
                            @Nullable java.lang.String dist)
        Sets the distribution
        Parameters:
        dist - the distribution
      • getTransportGate

        @NotNull
        public @NotNull ITransportGate getTransportGate()
        Returns the TransportGate interface
        Returns:
        the transport gate
      • setTransportGate

        public void setTransportGate​(@Nullable
                                     @Nullable ITransportGate transportGate)
        Sets the TransportGate interface
        Parameters:
        transportGate - the transport gate
      • isAttachStacktrace

        public boolean isAttachStacktrace()
        Checks if the AttachStacktrace is enabled or not
        Returns:
        true if enabled or false otherwise
      • setAttachStacktrace

        public void setAttachStacktrace​(boolean attachStacktrace)
        Sets the attachStacktrace to enabled or disabled
        Parameters:
        attachStacktrace - true if enabled or false otherwise
      • isAttachThreads

        public boolean isAttachThreads()
        Checks if the AttachThreads is enabled or not
        Returns:
        true if enabled or false otherwise
      • setAttachThreads

        public void setAttachThreads​(boolean attachThreads)
        Sets the attachThreads to enabled or disabled
        Parameters:
        attachThreads - true if enabled or false otherwise
      • isEnableAutoSessionTracking

        public boolean isEnableAutoSessionTracking()
        Returns if the automatic session tracking is enabled or not
        Returns:
        true if enabled or false otherwise
      • setEnableAutoSessionTracking

        public void setEnableAutoSessionTracking​(boolean enableAutoSessionTracking)
        Enable or disable the automatic session tracking
        Parameters:
        enableAutoSessionTracking - true if enabled or false otherwise
      • isEnableSessionTracking

        @Deprecated
        @ScheduledForRemoval
        public boolean isEnableSessionTracking()
      • setEnableSessionTracking

        @Deprecated
        @ScheduledForRemoval
        public void setEnableSessionTracking​(boolean enableSessionTracking)
      • getServerName

        @Nullable
        public @Nullable java.lang.String getServerName()
        Gets the default server name to be used in Sentry events.
        Returns:
        the default server name or null if none set
      • setServerName

        public void setServerName​(@Nullable
                                  @Nullable java.lang.String serverName)
        Sets the default server name to be used in Sentry events.
        Parameters:
        serverName - the default server name or null if none should be used
      • isAttachServerName

        public boolean isAttachServerName()
        Returns if SDK automatically resolves and attaches server name to events.
        Returns:
        true if enabled false if otherwise
      • setAttachServerName

        public void setAttachServerName​(boolean attachServerName)
        Sets if SDK should automatically resolve and attache server name to events.
        Parameters:
        attachServerName - true if enabled false if otherwise
      • getSessionTrackingIntervalMillis

        public long getSessionTrackingIntervalMillis()
        Returns the session tracking interval in millis
        Returns:
        the interval in millis
      • setSessionTrackingIntervalMillis

        public void setSessionTrackingIntervalMillis​(long sessionTrackingIntervalMillis)
        Sets the session tracking interval in millis
        Parameters:
        sessionTrackingIntervalMillis - the interval in millis
      • getDistinctId

        @Internal
        @Nullable
        public @Nullable java.lang.String getDistinctId()
        Returns the distinct Id
        Returns:
        the distinct Id
      • setDistinctId

        @Internal
        public void setDistinctId​(@Nullable
                                  @Nullable java.lang.String distinctId)
        Sets the distinct Id
        Parameters:
        distinctId - the distinct Id
      • getFlushTimeoutMillis

        public long getFlushTimeoutMillis()
        Returns the flush timeout in millis
        Returns:
        the timeout in millis
      • setFlushTimeoutMillis

        public void setFlushTimeoutMillis​(long flushTimeoutMillis)
        Sets the flush timeout in millis
        Parameters:
        flushTimeoutMillis - the timeout in millis
      • isEnableUncaughtExceptionHandler

        public boolean isEnableUncaughtExceptionHandler()
        Checks if the default UncaughtExceptionHandlerIntegration is enabled or not.
        Returns:
        true if enabled or false otherwise.
      • getEnableUncaughtExceptionHandler

        @Nullable
        public @Nullable java.lang.Boolean getEnableUncaughtExceptionHandler()
        Checks if the default UncaughtExceptionHandlerIntegration is enabled or disabled or not set.
        Returns:
        true if enabled, false otherwise or null if not set.
      • setEnableUncaughtExceptionHandler

        public void setEnableUncaughtExceptionHandler​(@Nullable
                                                      @Nullable java.lang.Boolean enableUncaughtExceptionHandler)
        Enable or disable the default UncaughtExceptionHandlerIntegration.
        Parameters:
        enableUncaughtExceptionHandler - true if enabled or false otherwise.
      • getConnectionTimeoutMillis

        public int getConnectionTimeoutMillis()
        Returns the connection timeout in milliseconds.
        Returns:
        the connectionTimeoutMillis
      • setConnectionTimeoutMillis

        public void setConnectionTimeoutMillis​(int connectionTimeoutMillis)
        Sets the connection timeout in milliseconds.
        Parameters:
        connectionTimeoutMillis - the connectionTimeoutMillis
      • getReadTimeoutMillis

        public int getReadTimeoutMillis()
        Returns the read timeout in milliseconds
        Returns:
        the readTimeoutMillis
      • setReadTimeoutMillis

        public void setReadTimeoutMillis​(int readTimeoutMillis)
        Sets the read timeout in milliseconds
        Parameters:
        readTimeoutMillis - the readTimeoutMillis
      • getEnvelopeDiskCache

        @NotNull
        public @NotNull IEnvelopeCache getEnvelopeDiskCache()
        Returns the EnvelopeCache interface
        Returns:
        the EnvelopeCache object
      • setEnvelopeDiskCache

        public void setEnvelopeDiskCache​(@Nullable
                                         @Nullable IEnvelopeCache envelopeDiskCache)
        Sets the EnvelopeCache interface
        Parameters:
        envelopeDiskCache - the EnvelopeCache object
      • getMaxQueueSize

        public int getMaxQueueSize()
        Returns the Max queue size
        Returns:
        the max queue size
      • setMaxQueueSize

        public void setMaxQueueSize​(int maxQueueSize)
        Sets the max queue size if maxQueueSize is bigger than 0
        Parameters:
        maxQueueSize - max queue size
      • getSdkVersion

        @Nullable
        public @Nullable SdkVersion getSdkVersion()
        Returns the SdkVersion object
        Returns:
        the SdkVersion object or null
      • getSslSocketFactory

        @Nullable
        public @Nullable javax.net.ssl.SSLSocketFactory getSslSocketFactory()
        Returns SSLSocketFactory
        Returns:
        SSLSocketFactory object or null
      • setSslSocketFactory

        public void setSslSocketFactory​(@Nullable
                                        @Nullable javax.net.ssl.SSLSocketFactory sslSocketFactory)
        Set custom SSLSocketFactory that is trusted to self-signed certificates
        Parameters:
        sslSocketFactory - SSLSocketFactory object
      • getHostnameVerifier

        @Nullable
        public @Nullable javax.net.ssl.HostnameVerifier getHostnameVerifier()
        Returns HostnameVerifier
        Returns:
        HostnameVerifier objecr or null
      • setHostnameVerifier

        public void setHostnameVerifier​(@Nullable
                                        @Nullable javax.net.ssl.HostnameVerifier hostnameVerifier)
        Set custom HostnameVerifier
        Parameters:
        hostnameVerifier - the HostnameVerifier
      • setSdkVersion

        @Internal
        public void setSdkVersion​(@Nullable
                                  @Nullable SdkVersion sdkVersion)
        Sets the SdkVersion object
        Parameters:
        sdkVersion - the SdkVersion object or null
      • isSendDefaultPii

        public boolean isSendDefaultPii()
      • setSendDefaultPii

        public void setSendDefaultPii​(boolean sendDefaultPii)
      • addScopeObserver

        public void addScopeObserver​(@NotNull
                                     @NotNull IScopeObserver observer)
        Adds a Scope observer
        Parameters:
        observer - the Observer
      • isEnableScopeSync

        public boolean isEnableScopeSync()
        Returns if the Java to NDK Scope sync is enabled
        Returns:
        true if enabled or false otherwise
      • setEnableScopeSync

        public void setEnableScopeSync​(boolean enableScopeSync)
        Enables or not the Java to NDK Scope sync
        Parameters:
        enableScopeSync - true if enabled or false otherwise
      • isEnableExternalConfiguration

        public boolean isEnableExternalConfiguration()
        Returns if loading properties from external sources is enabled.
        Returns:
        true if enabled or false otherwise
      • setEnableExternalConfiguration

        public void setEnableExternalConfiguration​(boolean enableExternalConfiguration)
        Enables loading options from external sources like sentry.properties file or environment variables, system properties.
        Parameters:
        enableExternalConfiguration - true if enabled or false otherwise
      • getTags

        @NotNull
        public @NotNull java.util.Map<java.lang.String,​java.lang.String> getTags()
        Returns tags applied to all events and transactions.
        Returns:
        the tags map
      • setTag

        public void setTag​(@NotNull
                           @NotNull java.lang.String key,
                           @NotNull
                           @NotNull java.lang.String value)
        Sets a tag that is applied to all events and transactions.
        Parameters:
        key - the key
        value - the value
      • getMaxAttachmentSize

        public long getMaxAttachmentSize()
        Returns the maximum attachment size for each attachment in MiB.
        Returns:
        the maximum attachment size in MiB.
      • setMaxAttachmentSize

        public void setMaxAttachmentSize​(long maxAttachmentSize)
        Sets the max attachment size for each attachment in bytes. Default is 20 MiB. Please also check the maximum attachment size of Relay to make sure your attachments don't get discarded there: https://docs.sentry.io/product/relay/options/
        Parameters:
        maxAttachmentSize - the max attachment size in bytes.
      • isEnableDeduplication

        public boolean isEnableDeduplication()
        Returns if event deduplication is turned on.
        Returns:
        if event deduplication is turned on.
      • setEnableDeduplication

        public void setEnableDeduplication​(@Nullable
                                           @Nullable java.lang.Boolean enableDeduplication)
        Enables or disables event deduplication.
        Parameters:
        enableDeduplication - true if enabled false otherwise
      • isTracingEnabled

        public boolean isTracingEnabled()
        Returns if tracing should be enabled. If tracing is disabled, starting transactions returns NoOpTransaction.
        Returns:
        if tracing is enabled.
      • getIgnoredExceptionsForType

        @NotNull
        public @NotNull java.util.Set<java.lang.Class<? extends java.lang.Throwable>> getIgnoredExceptionsForType()
        Returns the list of exception classes that once captured will not be sent to Sentry as SentryEvent.
        Returns:
        the list of exception classes that once captured will not be sent to Sentry as SentryEvent.
      • addIgnoredExceptionForType

        public void addIgnoredExceptionForType​(@NotNull
                                               @NotNull java.lang.Class<? extends java.lang.Throwable> exceptionType)
        Adds exception type to the list of ignored exceptions.
        Parameters:
        exceptionType - - the exception type
      • getMaxSpans

        @Experimental
        public int getMaxSpans()
        Returns the maximum number of spans that can be attached to single transaction.
        Returns:
        the maximum number of spans that can be attached to single transaction.
      • setMaxSpans

        @Experimental
        public void setMaxSpans​(int maxSpans)
        Sets the maximum number of spans that can be attached to single transaction.
        Parameters:
        maxSpans - maximum number of spans that can be attached to single transaction.
      • isEnableShutdownHook

        public boolean isEnableShutdownHook()
        True if ShutdownHookIntegration is enabled, false otherwise.
        Returns:
        true if enabled or false otherwise.
      • setEnableShutdownHook

        public void setEnableShutdownHook​(boolean enableShutdownHook)
        Enables or disable ShutdownHookIntegration.
        Parameters:
        enableShutdownHook - true if enabled or false otherwise.
      • getMaxCacheItems

        public int getMaxCacheItems()
        The max cache items for capping the number of events Default is 30
        Returns:
        the maxCacheItems
      • setMaxCacheItems

        public void setMaxCacheItems​(int maxCacheItems)
        Sets the max cache items for capping the number of events
        Parameters:
        maxCacheItems - the maxCacheItems
      • setMaxRequestBodySize

        public void setMaxRequestBodySize​(@NotNull
                                          @NotNull SentryOptions.RequestSize maxRequestBodySize)
      • isTraceSampling

        @Experimental
        public boolean isTraceSampling()
        Note: this is an experimental API and will be removed without notice.
      • setTraceSampling

        @Experimental
        public void setTraceSampling​(boolean traceSampling)
        Note: this is an experimental API and will be removed without notice.
        Parameters:
        traceSampling - - if trace sampling should be enabled
      • getTracingOrigins

        @NotNull
        public @NotNull java.util.List<java.lang.String> getTracingOrigins()
        Returns a list of origins to which `sentry-trace` header should be sent in HTTP integrations.
        Returns:
        the list of origins
      • addTracingOrigin

        public void addTracingOrigin​(@NotNull
                                     @NotNull java.lang.String tracingOrigin)
        Adds an origin to which `sentry-trace` header should be sent in HTTP integrations.
        Parameters:
        tracingOrigin - - the tracing origin
      • getProguardUuid

        @Nullable
        public @Nullable java.lang.String getProguardUuid()
        Returns a Proguard UUID.
        Returns:
        the Proguard UUIDs.
      • setProguardUuid

        public void setProguardUuid​(@Nullable
                                    @Nullable java.lang.String proguardUuid)
        Sets a Proguard UUID.
        Parameters:
        proguardUuid - - the Proguard UUID