Skip to content

Commit

Permalink
fix: update deprecated span processor
Browse files Browse the repository at this point in the history
  • Loading branch information
saidsef committed Feb 22, 2025
1 parent 4ddf268 commit 4f520bc
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 110 deletions.
24 changes: 6 additions & 18 deletions libs/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function setupTracing(options = {}) {
// Register the span processor with the tracer provider
const exporter = new OTLPTraceExporter(exportOptions);
const spanProcessor = new BatchSpanProcessor(exporter);
tracerProvider.addSpanProcessor(spanProcessor);
tracerProvider.spanProcessor(spanProcessor);

// Ignore spans from static assets.
const ignoreIncomingRequestHook = (req) => {
Expand All @@ -114,23 +114,11 @@ export function setupTracing(options = {}) {
registerInstrumentations({
tracerProvider: tracerProvider,
instrumentations: [
new ExpressInstrumentation({
ignoreIncomingRequestHook,
}),
new PinoInstrumentation({
logHook: (span, record) => {
record['resource.service.name'] = tracerProvider.resource.attributes['service.name'];
},
}),
new HttpInstrumentation({
requireParentforOutgoingSpans: false,
requireParentforIncomingSpans: false,
ignoreIncomingRequestHook,
}),
new ConnectInstrumentation(),
new AwsInstrumentation({
sqsExtractContextPropagationFromPayload: true,
}),
new PinoInstrumentation({ logHook: (span, record) => { record['resource.service.name'] = tracerProvider.resource.attributes['service.name']; }, }),
new HttpInstrumentation({ requireParentforOutgoingSpans: false, requireParentforIncomingSpans: false, ignoreIncomingRequestHook, }),
new ExpressInstrumentation({ ignoreIncomingRequestHook, }),
new ConnectInstrumentation(),
new AwsInstrumentation({ sqsExtractContextPropagationFromPayload: true, }),
new DnsInstrumentation(),
new RedisInstrumentation(),
],
Expand Down
169 changes: 78 additions & 91 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@saidsef/tracing-node",
"version": "3.1.0",
"version": "3.2.0",
"description": "tracing NodeJS - This is a wrapper for OpenTelemetry instrumentation packages",
"main": "libs/index.mjs",
"scripts": {
Expand Down

0 comments on commit 4f520bc

Please sign in to comment.