Compatibility requirements
The Datadog Java SDK supports library instrumentations using OpenTelemetry’s instrumentation API and javaagent
extension API.
Each instrumentation must be packaged as an OpenTelemetry extension in its own JAR.
OpenTelemetry provides an example extension project that registers a custom instrumentation for Servlet 3 classes.
The Datadog SDK for Java also accepts select individual instrumentation JARs produced by OpenTelemetry’s opentelemetry-java-instrumentation
build, for example the CFX instrumentation JAR.
OpenTelemetry incubator APIs are not supported.
Setup
To use an OpenTelemetry instrumentation with the Datadog Java SDK:
- Set the
dd.trace.otel.enabled
system property or the DD_TRACE_OTEL_ENABLED
environment variable to true
. - Copy the OpenTelemetry extension JAR containing the instrumentation to the same container as the application.
- Set the
otel.javaagent.extensions
system property or the OTEL_JAVAAGENT_EXTENSIONS
environment variable to the extension JAR path.
Verified OpenTelemetry extensions
Compatibility requirements
The Datadog Python SDK supports library instrumentations using the OpenTelemetry Python Trace API.
OpenTelemetry provides an example for instrumenting a sample application.
Setup
To use OpenTelemetry instrumentations with the Datadog Python SDK, perform the following steps:
- Follow the instructions in the OpenTelemetry API section in the Datadog Python library docs.
- Follow the steps for instrumenting your service with your chosen
opentelemetry-python-contrib
library.
Compatibility requirements
The Datadog Ruby SDK supports library instrumentation using the OpenTelemetry Ruby Trace API.
OpenTelemetry provides an example for instrumenting a sample application.
Setup
To use OpenTelemetry integrations with the Datadog Ruby SDK, perform the following steps:
- Follow the instructions in configuring OpenTelemetry in the Datadog Ruby SDK documentation.
- Follow the steps for instrumenting your service with your chosen
opentelemetry-ruby-contrib
library.
Compatibility requirements
The Datadog SDK for Go supports library instrumentations written using the Opentelemetry-Go Trace API, including the opentelemetry-go-contrib/instrumentation
libraries.
Setup
To use OpenTelemetry integrations with the Datadog Go SDK, perform the following steps:
- Follow the instructions in the Imports and Setup sections of the Go Custom Instrumentation using OpenTelemetry API page.
- Follow the steps for instrumenting your service with your chosen
opentelemetry-go-contrib
library.
The following is an example instrumenting the net/http
library with the Datadog Tracer and Opentelemetry’s net/http
integration:
import (
"fmt"
"log"
"net/http"
ddotel "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/opentelemetry"
ddtracer "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel"
)
func main() {
// register tracer
provider := ddotel.NewTracerProvider(ddtracer.WithDebugMode(true))
defer provider.Shutdown()
otel.SetTracerProvider(provider)
// configure the server with otelhttp instrumentation as you normally would using opentelemetry: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
var mux http.ServeMux
mux.Handle("/hello", http.HandlerFunc(hello))
http.HandleFunc("/hello", hello)
log.Fatal(http.ListenAndServe(":8080", otelhttp.NewHandler(&mux, "server")))
}
func hello(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "hello\n")
}