Configuration.Builder - DataDog/dd-sdk-android GitHub Wiki

class Builder@JvmOverloadsconstructor(clientToken: String, env: String, variant: String = NO_VARIANT, service: String? = null)

A Builder class for a Configuration.

Parameters

clientToken your API key of type Client Token
env the environment name that will be sent with each event. This can be used to filter your events on different environments (e.g.: "staging" vs. "production").
variant the variant of your application, which should be the value from your BuildConfig.FLAVOR constant if you have different flavors, empty string otherwise.
service the service name (if set to null, it'll be set to your application's package name, e.g.: com.example.android)

Constructors

Builder

@JvmOverloads

constructor(clientToken: String, env: String, variant: String = NO_VARIANT, service: String? = null)

Parameters
clientToken your API key of type Client Token
env the environment name that will be sent with each event. This can be used to filter your events on different environments (e.g.: "staging" vs. "production").
variant the variant of your application, which should be the value from your BuildConfig.FLAVOR constant if you have different flavors, empty string otherwise.
service the service name (if set to null, it'll be set to your application's package name, e.g.: com.example.android)

Functions

build

fun build(): Configuration

Builds a Configuration based on the current state of this Builder.

setAdditionalConfiguration

fun setAdditionalConfiguration(additionalConfig: Map<String, Any>): Configuration.Builder

Allows to provide additional configuration values which can be used by the SDK.

Parameters
additionalConfig Additional configuration values.

setBackpressureStrategy

fun setBackpressureStrategy(backpressureStrategy: BackPressureStrategy): Configuration.Builder

Sets the strategy to handle scalability issues. Many operations (data processing, event I/O, …) are queued in background threads. This configuration lets one decide how to handle the edge case when the queue starts growing, which can lead to a lot of memory usage, delayed processing, and possibly OOM or ANR.

Parameters
backpressureStrategy the backpressure strategy (default strategy ignores new tasks if a queue reaches 1024 items)

setBatchProcessingLevel

fun setBatchProcessingLevel(batchProcessingLevel: BatchProcessingLevel): Configuration.Builder

Defines the Batch processing level, defining the maximum number of batches processed sequentially without a delay within one reading/uploading cycle.

Parameters
batchProcessingLevel the desired batch processing level. By default it's set to BatchProcessingLevel.MEDIUM.
See also
BatchProcessingLevel

setBatchSize

fun setBatchSize(batchSize: BatchSize): Configuration.Builder

Defines the batch size (impacts the size and number of requests performed by Datadog).

Parameters
batchSize the desired batch size

setCrashReportsEnabled

fun setCrashReportsEnabled(crashReportsEnabled: Boolean): Configuration.Builder

Allows to control if JVM crashes are tracked or not. Default value is true.

Parameters
crashReportsEnabled whether crashes are tracked and sent to Datadog

setEncryption

fun setEncryption(dataEncryption: Encryption): Configuration.Builder

Allows to set the encryption for the local data. By default no encryption is used for the local data.

Parameters
dataEncryption An encryption object complying Encryption interface.

setFirstPartyHosts

fun setFirstPartyHosts(hosts: List<String>): Configuration.Builder

Sets the list of first party hosts. Requests made to a URL with any one of these hosts (or any subdomain) will:

  • be considered a first party resource and categorised as such in your RUM dashboard;
  • be wrapped in a Span and have DataDog trace id injected to get a full flame-graph in APM in case of OkHttp instrumentation usage.
Parameters
hosts a list of all the hosts that you own.

setFirstPartyHostsWithHeaderType

fun setFirstPartyHostsWithHeaderType(hostsWithHeaderType: Map<String, Set<TracingHeaderType>>): Configuration.Builder

Sets the list of first party hosts and specifies the type of HTTP headers used for distributed tracing. Requests made to a URL with any one of these hosts (or any subdomain) will:

  • be considered a first party resource and categorised as such in your RUM dashboard;
  • be wrapped in a Span and have trace id of the specified types injected to get a full flame-graph in APM. Multiple header types are supported for each host.
Parameters
hostsWithHeaderType a list of all the hosts that you own and the tracing headers to be used for each host. See DatadogInterceptor

setPersistenceStrategyFactory

fun setPersistenceStrategyFactory(persistenceStrategyFactory: PersistenceStrategy.Factory?): Configuration.Builder

Allows to use a custom persistence strategy.

Parameters
persistenceStrategyFactory the persistence strategy to use (or null to use the default one)

setProxy

fun setProxy(proxy: Proxy, authenticator: Authenticator?): Configuration.Builder

Enables a custom proxy for uploading tracked data to Datadog's intake.

Parameters
proxy the Proxy configuration
authenticator the optional Authenticator for the proxy

setUploadFrequency

fun setUploadFrequency(uploadFrequency: UploadFrequency): Configuration.Builder

Defines the preferred upload frequency.

Parameters
uploadFrequency the desired upload frequency policy

setUploadSchedulerStrategy

fun setUploadSchedulerStrategy(uploadSchedulerStrategy: UploadSchedulerStrategy?): Configuration.Builder

Sets the strategy to schedule data uploads.

Parameters
uploadSchedulerStrategy the upload scheduler strategy, or null to use the default strategy (default: null)

setUseDeveloperModeWhenDebuggable

fun setUseDeveloperModeWhenDebuggable(developerModeEnabled: Boolean): Configuration.Builder

Sets the DataDog SDK to be more verbose when an application is set to debuggable. This is equivalent to setting: setSessionSampleRate(100) setBatchSize(BatchSize.SMALL) setUploadFrequency(UploadFrequency.FREQUENT) Datadog.setVerbosity(Log.VERBOSE) These settings will override your configuration, but only when the application is debuggable

Parameters
developerModeEnabled Enable or disable extra debug info when an app is debuggable

useSite

fun useSite(site: DatadogSite): Configuration.Builder

Let the SDK target your preferred Datadog's site.