- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
Instrumentation is the process of adding code to your application to capture and report observability data. Automatic instrumentation is a way to instrument applications and libraries without modifying their source code. Both OpenTelemetry and Datadog provide automatic instrumentation in their SDKs.
Datadog SDKs support adding OpenTelemetry instrumentation libraries to their existing automatic instrumentation. This provides observability for libraries not covered by Datadog SDKs without changing SDKs.
Enable OpenTelemetry support: Set the DD_TRACE_OTEL_ENABLED
environment variable to true
. This step isn’t required for the Datadog Go and Ruby APM SDKs.
Run the Datadog Agent: Datadog SDKs provide an implementation of the OpenTelemetry API and submit spans to a Datadog Agent. Ensure the Datadog Agent is running to use OpenTelemetry instrumentation with Datadog SDKs.
Disable duplicate instrumentation: When replacing a Datadog instrumentation with its OpenTelemetry equivalent, disable the Datadog instrumentation to prevent duplicate spans from appearing in the trace.
Datadog SDKs support configuration through OpenTelemetry environment variables.
Datadog SDKs implement the OpenTelemetry API by overriding the default implementations in the OpenTelemetry SDK. However, note the following limitations:
Language | Minimum version |
---|---|
Java | 1.35.0 |
Python | 2.10.0 |
Ruby | 2.1.0 |
Go | 1.67.0 |
Node.js | 4.3.0 |
PHP | 0.94.0 |
.NET | 2.53.0 |
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.
To use an OpenTelemetry instrumentation with the Datadog Java SDK:
dd.trace.otel.enabled
system property or the DD_TRACE_OTEL_ENABLED
environment variable to true
.otel.javaagent.extensions
system property or the OTEL_JAVAAGENT_EXTENSIONS
environment variable to the extension JAR path.Framework | Versions | OpenTelemetry Extension | Instrumentation Names |
---|---|---|---|
Apache CXF (Jax-WS) | 3.0+ | opentelemetry-javaagent-jaxws-2.0-cxf-3.0 | cxf |
The Datadog Python SDK supports library instrumentations using the OpenTelemetry Python Trace API.
OpenTelemetry provides an example for instrumenting a sample application.
To use OpenTelemetry instrumentations with the Datadog Python SDK, perform the following steps:
opentelemetry-python-contrib
library.The Datadog Ruby SDK supports library instrumentation using the OpenTelemetry Ruby Trace API.
OpenTelemetry provides an example for instrumenting a sample application.
To use OpenTelemetry integrations with the Datadog Ruby SDK, perform the following steps:
opentelemetry-ruby-contrib
library.The Datadog SDK for Go supports library instrumentations written using the Opentelemetry-Go Trace API, including the opentelemetry-go-contrib/instrumentation
libraries.
To use OpenTelemetry integrations with the Datadog Go SDK, perform the following steps:
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")
}
The Datadog Node.js SDK supports library instrumentations using the OpenTelemetry Node.js Trace API.
To use OpenTelemetry instrumentations with the Datadog Node.js SDK, perform the following steps:
opentelemetry-js-contrib
library.The following example demonstrates how to instrument the http
and express
OpenTelemetry integrations with the Datadog Node.js SDK:
const tracer = require('dd-trace').init()
const { TracerProvider } = tracer
const provider = new TracerProvider()
provider.register()
const { registerInstrumentations } = require('@opentelemetry/instrumentation')
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http')
const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-express')
// Register the instrumentation with the Datadog trace provider
// and the OpenTelemetry instrumentation of your choice
registerInstrumentations({
instrumentations: [
new HttpInstrumentation({
ignoreIncomingRequestHook (req) {
// Ignore spans created from requests to the agent
return req.path === '/v0.4/traces' || req.path === '/v0.7/config' ||
req.path === '/telemetry/proxy/api/v2/apmtelemetry'
},
ignoreOutgoingRequestHook (req) {
// Ignore spans created from requests to the agent
return req.path === '/v0.4/traces' || req.path === '/v0.7/config' ||
req.path === '/telemetry/proxy/api/v2/apmtelemetry'
}
}),
new ExpressInstrumentation()
],
tracerProvider: provider
})
const express = require('express')
const http = require('http')
// app code below ....
To avoid duplicate spans, disable the corresponding Datadog instrumentations.
Set the DD_TRACE_DISABLED_INSTRUMENTATIONS
environment variable to a comma-separated list of integration names to disable. For example, to disable Datadog instrumentations for the libraries used in the Setup example, set the following:
DD_TRACE_DISABLED_INSTRUMENTATIONS=http,dns,express,net
The Datadog PHP SDK supports library instrumentation using the stable
OpenTelemetry PHP Trace API.
OpenTelemetry provides an example for instrumenting a sample application.
To use OpenTelemetry integrations with the Datadog PHP SDK:
opentelemetry-php-contrib
library.You can also find the sample Slim4OtelDropIn PHP application with OpenTelemetry and Datadog auto instrumentations in the DataDog/trace-examples
GitHub repository.
To avoid duplicate spans, you can disable the corresponding Datadog integrations. Set the DD_TRACE_<INTEGRATION>_ENABLED
environment variable to 0
or false
to disable an integration(see Integration names).
Use the integration name when setting integration-specific configuration for example: Laravel is DD_TRACE_LARAVEL_ENABLED
.
DD_TRACE_LARAVEL_ENABLED=false
The Datadog .NET SDK supports library instrumentations that come with built-in OpenTelemetry support.
To use OpenTelemetry instrumentation libraries with the Datadog .NET SDK:
DD_TRACE_OTEL_ENABLED
environment variable to true
.ActivitySource
Library | Versions | NuGet package | Integration Name | Setup instructions |
---|---|---|---|---|
Azure Service Bus | 7.14.0+ | Azure.Messaging.ServiceBus | AzureServiceBus | See Azure SDK section below |
The Azure SDK provides built-in OpenTelemetry support. Enable it by setting the AZURE_EXPERIMENTAL_ENABLE_ACTIVITY_SOURCE
environment variable to true
or by setting the Azure.Experimental.EnableActivitySource
context switch to true
in your application code. See Azure SDK documentation for more details.