

# Telemetry providers
<a name="observability-telemetry-providers"></a>

The SDK currently supports [OpenTelemetry](https://opentelemetry.io/) (OTel) as a provider. The SDK might offer additional telemetry providers in the future.

**Topics**
+ [Configure the OpenTelemetry-based telemetry provider](observability-telemetry-providers-otel.md)

# Configure the OpenTelemetry-based telemetry provider
<a name="observability-telemetry-providers-otel"></a>

The SDK for Kotlin provides an implementation of the `TelemetryProvider` interface backed by OpenTelemetry.

## Prerequisites
<a name="observability-telemetry-providers-otel-prereqs"></a>

Update your project dependencies to add the OpenTelemetry provider as shown in the following Gradle snippet. You can navigate to the *X.Y.Z* link to see the latest version available.

```
dependencies {
    implementation(platform("aws.smithy.kotlin:bom:[https://github.com/smithy-lang/smithy-kotlin/releases/latest](https://github.com/smithy-lang/smithy-kotlin/releases/latest)"))
    implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:[https://search.maven.org/#search|gav|1|g:io.opentelemetry.instrumentation%20AND%20a:opentelemetry-instrumentation-bom](https://search.maven.org/#search|gav|1|g:io.opentelemetry.instrumentation%20AND%20a:opentelemetry-instrumentation-bom)"))
    implementation("aws.smithy.kotlin:telemetry-provider-otel")

    // OPTIONAL: If you use log4j, the following entry enables the ability to export logs through OTel.
    runtimeOnly("io.opentelemetry.instrumentation:opentelemetry-log4j-appender-2.17")
}
```

## Configure the SDK
<a name="observability-telemetry-providers-otel-conf"></a>

The following code configures a service client by using the OpenTelemetry telemetry provider.

```
import aws.sdk.kotlin.services.s3.S3Client
import aws.smithy.kotlin.runtime.telemetry.otel.OpenTelemetryProvider
import io.opentelemetry.api.GlobalOpenTelemetry
import kotlinx.coroutines.runBlocking

fun main() = runBlocking {
    val otelProvider = OpenTelemetryProvider(GlobalOpenTelemetry.get())

    S3Client.fromEnvironment().use { s3 ->
        telemetryProvider = otelProvider
        …
    }
}
```

**Note**  
A discussion of how to configure the OpenTelemetry SDK is outside of the scope of this guide. The [OpenTelemetry Java documentation](https://opentelemetry.io/docs/instrumentation/java/) contains configuration information on the various approaches: [manually](https://opentelemetry.io/docs/instrumentation/java/manual/), automatically through the [ Java agent](https://opentelemetry.io/docs/instrumentation/java/automatic/), or the (optional) [collector](https://opentelemetry.io/docs/collector/).

## Resources
<a name="observability-telemetry-providers-otel-res"></a>

The following resources are available to help you get started with OpenTelemetry.
+ [AWS Distro for OpenTelemetry](https://aws-otel.github.io/docs/introduction) - AWS OTeL Distro homepage
+ [aws-otel-java-instrumentation](https://github.com/aws-observability/aws-otel-java-instrumentation) - AWS Distro for OpenTelemetry Java Instrumentation Library
+ [aws-otel-lambda](https://github.com/aws-observability/aws-otel-lambda) - AWS managed OpenTelemetry Lambda layers
+ [aws-otel-collector](https://github.com/aws-observability/aws-otel-collector) - AWS Distro for OpenTelemetry Collector
+ [AWS Observability Best Practices](https://aws-observability.github.io/observability-best-practices/) - General best practices for observability specific to AWS