Skip to content

Latest commit

 

History

History
58 lines (42 loc) · 1.75 KB

File metadata and controls

58 lines (42 loc) · 1.75 KB

Datadog Integration for Timber

Getting Started

To include the Datadog integration for Timber in your project, simply add the following to your application's build.gradle file.

repositories {
    maven { url "https://dl.bintray.com/datadog/datadog-maven" }
}

dependencies {
    implementation "com.datadoghq:dd-sdk-android:<latest-version>"
    implementation "com.datadoghq:dd-sdk-android-timber:<latest-version>"
}

Initial Setup

Before you can use the SDK, you need to setup the library with your application context and your API token. You can create a token from the Integrations > API in Datadog. Make sure you create a key of type Client Token.

Once Datadog is initialized, you can then create a Logger instance using the dedicated builder, and integrate it in Timber, as follows:

class SampleApplication : Application() {

    override fun onCreate() {
        super.onCreate()
        val config = DatadogConfig.Builder(BuildConfig.DD_CLIENT_TOKEN).build()
        Datadog.initialize(this, config)

        val logger = Logger.Builder()
                .setNetworkInfoEnabled(true)
                .setLogcatLogsEnabled(true)
                .setDatadogLogsEnabled(true)
                .build();
        Timber.plant(DatadogTree(logger))
    }
}

That's it, now all your Timber logs will be sent to Datadog automatically.

You can configure the logger's tags and attributes, as explained in the Datadog Android log collection documentation

Contributing

Pull requests are welcome, but please open an issue first to discuss what you would like to change. For more information, read the Contributing Guide.

License

Apache License, v2.0