-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-instrument @opentelemetry/sdk-trace-node (#3248)
- Loading branch information
Stephen Belanger
authored
Jun 20, 2023
1 parent
51dd34b
commit 89da666
Showing
8 changed files
with
83 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict' | ||
|
||
process.env.DD_TRACE_OTEL_ENABLED = '1' | ||
|
||
require('dd-trace').init() | ||
|
||
const opentelemetry = require('@opentelemetry/sdk-node') | ||
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger') | ||
|
||
const sdk = new opentelemetry.NodeSDK({ | ||
traceExporter: new JaegerExporter() | ||
}) | ||
|
||
sdk.start() | ||
|
||
const otelTracer = opentelemetry.api.trace.getTracer( | ||
'my-service-tracer' | ||
) | ||
|
||
otelTracer.startActiveSpan('otel-sub', otelSpan => { | ||
setImmediate(() => { | ||
otelSpan.end() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict' | ||
|
||
const { addHook } = require('./helpers/instrument') | ||
const shimmer = require('../../datadog-shimmer') | ||
const tracer = require('../../dd-trace') | ||
|
||
if (process.env.DD_TRACE_OTEL_ENABLED) { | ||
addHook({ | ||
name: '@opentelemetry/sdk-trace-node', | ||
file: 'build/src/NodeTracerProvider.js', | ||
versions: ['*'] | ||
}, (mod) => { | ||
shimmer.wrap(mod, 'NodeTracerProvider', () => { | ||
return tracer.TracerProvider | ||
}) | ||
return mod | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters