Custom Instrumentation of .NET Applications with the OpenTelemetry API
Support for custom instrumenting your application using the OpenTelemetry API and sending the spans to Datadog is in beta.
If your code is custom instrumented with the OpenTelemetry (OTel) API, you can configure it to generate Datadog-style spans and traces to be processed by the Datadog tracing library for your language, and send those to Datadog.
The Datadog tracing library, when configured as described here, accepts the spans and traces generated by OTel-instrumented code, processes the telemetry, and sends it to Datadog. You can use this approach, for example, if your code has already been instrumented with the OTel API, or if you want to instrument using the OTel API, and you want to gain the benefits of using the Datadog tracing libraries without changing your code.
If you’re looking for a way to instrument your code with OpenTelemetry and then send span data to Datadog without going through the Datadog tracing library, see OpenTelemetry in Datadog.
Requirements and limitations
- Datadog .NET tracing library
dd-trace-dotnet
version 2.21.0 or greater.
The following OTel features implemented in the Datadog library as noted:
Configuring OTel to use the Datadog trace provider
- Add your desired manual OTel instrumentation to your .NET code following the OTel .NET Manual Instrumentation documentation.
- Install the Datadog .NET tracing library and enable the tracer for your .NET Framework service or your .NET Core (and .NET 5+) service.
- Set
DD_TRACE_OTEL_ENABLED
environment variable to true
. - Run your application.
Datadog combines these OpenTelemetry spans with other Datadog APM spans into a single trace of your application. It supports OpenTelemetry instrumentation libraries also.
Further Reading
Additional helpful documentation, links, and articles: