-
Notifications
You must be signed in to change notification settings - Fork 358
Description
Tracer Version(s)
5.76.0
Node.js Version(s)
22.16
Bug Report
When using dd-trace (v5.76.0) with @opentelemetry/api versions newer than 1.4.1 (e.g., 1.9.0), the TracerProvider registration appears to succeed, but all custom spans created via the OpenTelemetry API become no-ops with trace IDs showing as all zeros (00000000000000000000000000000000).
Environment
- dd-trace version: 5.76.0
- @opentelemetry/api version: 1.9.0 (fails), 1.4.1 (works)
- Node.js version: 22.16.0
- Platform: Windows/Linux
- Runtime: Node.js with TypeScript
Expected Behavior
According to Datadog Node.js Custom Instrumentation using the OpenTelemetry API docs when registering dd-trace's TracerProvider with the OpenTelemetry API, custom spans created using trace.getTracer() should:
- Be properly instrumented and sent to Datadog
- Have valid trace IDs that correlate with dd-trace's native instrumentation
- Maintain proper parent-child relationships with auto-instrumented spans
Actual Behavior
When using @opentelemetry/[email protected]:
- TracerProvider registration succeeds without errors
- trace.getTracer() returns a tracer instance
- tracer.startActiveSpan() appears to work
- However, all spans are no-ops with trace IDs of 00000000000000000000000000000000
- No trace data is sent to Datadog for these custom spans
- Auto-instrumentation via dd-trace continues to work normally
Reproduction Code
Prerequisites
- Datadog agent running on default port: 8126
Set up package.json with @opentelemetry/api @1.9.0:
{
"name": "testapp",
"version": "1.0.0",
"description": "Test app for dd-trace with OpenTelemetry tracing",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"start": "npx tsx app.ts",
"clean": "rm -rf dist"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/express": "^5.0.5",
"@types/node": "^24.9.2",
"tsx": "^4.20.6",
"typescript": "^5.9.3"
},
"dependencies": {
"@opentelemetry/api": "1.9.0",
"dd-trace": "^5.76.0",
"express": "^5.1.0"
}
}
Create instrumentation file (datadog.ts):
import tracer from 'dd-trace'
tracer.init({
service: 'test-service',
env: 'dev',
version: '1.0.0',
// Agent configuration (optional - defaults shown)
hostname: 'localhost',
port: 8126,
// Log injection and runtime metrics
logInjection: true,
runtimeMetrics: true,
remoteConfig: {
pollInterval: 0 // Disables remote config polling
}
});
const provider = new tracer.TracerProvider();
provider.register();
export default tracer;Create application file (app.ts):
import tracer from 'dd-trace'
tracer.init({
service: 'test-service',
env: 'dev',
version: '1.0.0',
// Agent configuration (optional - defaults shown)
hostname: 'localhost',
port: 8126,
// Log injection and runtime metrics
logInjection: true,
runtimeMetrics: true,
remoteConfig: {
pollInterval: 0 // Disables remote config polling
}
});
const provider = new tracer.TracerProvider();
provider.register();
export default tracer;
Set up tsconfig.json:
{
"compilerOptions": {
"target": "ES2022",
"module": "commonjs",
"lib": ["ES2022"],
"outDir": "./dist",
"rootDir": ".",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"removeComments": true
},
"exclude": ["node_modules", "dist"]
}
Install dependencies, run and observe:
npm install
npm run start
# Make request to http://localhost:3000/test
# Check console output: The Trace ID will be all zeros. Downgrading to 1.4.1 fixes this.
Error Logs
No response
Tracer Config
No response
Operating System
No response
Bundling
Unsure