dd-trace is OpenTracing compliant. You can use the OpenTracing JavaScript API with dd-trace as the backing implementation.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/datadog/dd-trace-js/llms.txt
Use this file to discover all available pages before exploring further.
Setup
initGlobalTracer, all OpenTracing API calls use dd-trace as the backend:
Datadog-specific tags
The following OpenTracing tags have special meaning in Datadog and override default behavior:| Tag | Description |
|---|---|
service.name | The service name for the span. Falls back to the tracer’s service name if not set. |
resource.name | The resource name for the span. Falls back to the operation name if not set. |
span.type | The span type (e.g., web, db, cache, rpc). Falls back to custom if not set. |
Context propagation
Use the OpenTracinginject and extract methods to propagate spans across service boundaries:
Supported formats
| Format constant | String value | Description |
|---|---|---|
FORMAT_HTTP_HEADERS | 'http_headers' | HTTP header map |
FORMAT_TEXT_MAP | 'text_map' | Plain text key-value map |
FORMAT_BINARY | 'binary' | Binary buffer |
Migration from OpenTracing
If you are migrating existing OpenTracing instrumentation to use dd-trace directly:- Replace
opentracing.globalTracer()calls with the dd-tracetracersingleton. - Replace
tracer.startSpan()/span.finish()withtracer.trace()ortracer.wrap()where possible — these manage span lifecycle automatically. - Use
span.setTag()orspan.addTags()instead of the OpenTracing tag methods.
dd-trace extends the OpenTracing
Tracer interface. All OpenTracing API methods work correctly. However, using the dd-trace native API (tracer.trace(), tracer.wrap(), tracer.scope()) is recommended for new code, as it provides automatic scope and lifecycle management.