@saidsef/tracing-node 3.5.4 → 3.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/libs/index.mjs +10 -11
  2. package/package.json +3 -3
package/libs/index.mjs CHANGED
@@ -17,7 +17,7 @@
17
17
  */
18
18
 
19
19
  import {AwsInstrumentation} from '@opentelemetry/instrumentation-aws-sdk';
20
- import {B3Propagator, B3InjectEncoding} from '@opentelemetry/propagator-b3';
20
+ import {AsyncHooksContextManager} from '@opentelemetry/context-async-hooks';
21
21
  import {BatchSpanProcessor} from '@opentelemetry/sdk-trace-base';
22
22
  import {CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator} from '@opentelemetry/core';
23
23
  import {ConnectInstrumentation} from '@opentelemetry/instrumentation-connect';
@@ -68,7 +68,7 @@ export function setupTracing(options = {}) {
68
68
 
69
69
  // Configure exporter with the Collector endpoint - uses gRPC
70
70
  const exportOptions = {
71
- concurrencyLimit: concurrencyLimit,
71
+ concurrencyLimit: parseInt(concurrencyLimit, 10),
72
72
  url: url,
73
73
  timeoutMillis: 1000,
74
74
  };
@@ -92,29 +92,28 @@ export function setupTracing(options = {}) {
92
92
 
93
93
  // Initialize the tracer provider with propagators
94
94
  tracerProvider.register({
95
+ contextManager: new AsyncHooksContextManager().enable(),
95
96
  propagator: new CompositePropagator({
96
97
  propagators: [
97
- new W3CBaggagePropagator(),
98
98
  new W3CTraceContextPropagator(),
99
- new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }),
99
+ new W3CBaggagePropagator(),
100
100
  ],
101
101
  }),
102
102
  });
103
103
 
104
104
  // Ignore spans from static assets.
105
105
  const ignoreIncomingRequestHook = (req) => {
106
- const isStaticAsset = !!req.url.match(/^\/metrics|\/healthz.*$/);
107
- return isStaticAsset;
106
+ return req.url.startsWith('/metrics') || req.url.startsWith('/healthz');
108
107
  };
109
108
 
110
109
  // Register instrumentations
111
110
  const instrumentations = [
112
- new HttpInstrumentation({ serverName: serviceName, requireParentforOutgoingSpans: true, requireParentforIncomingSpans: true, ignoreIncomingRequestHook, }),
111
+ new HttpInstrumentation({serverName: serviceName, ignoreIncomingRequestHook,}),
113
112
  new ExpressInstrumentation({ ignoreIncomingRequestHook, }),
114
- new PinoInstrumentation(),
113
+ new PinoInstrumentation({logHook: (span, record) => {record['trace_id'] = span.spanContext().traceId;record['span_id'] = span.spanContext().spanId;},}),
115
114
  new ConnectInstrumentation(),
116
115
  new AwsInstrumentation({ sqsExtractContextPropagationFromPayload: true, }),
117
- new IORedisInstrumentation({ requireParentSpan: true, }),
116
+ new IORedisInstrumentation(),
118
117
  ];
119
118
 
120
119
  if (enableFsInstrumentation) {
@@ -131,8 +130,8 @@ export function setupTracing(options = {}) {
131
130
 
132
131
  // Register instrumentations
133
132
  registerInstrumentations({
134
- tracerProvider: tracerProvider,
135
- instrumentations: instrumentations,
133
+ tracerProvider: tracerProvider,
134
+ instrumentations: instrumentations,
136
135
  });
137
136
 
138
137
  // Return the tracer for the service
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saidsef/tracing-node",
3
- "version": "3.5.4",
3
+ "version": "3.7.2",
4
4
  "description": "tracing NodeJS - Wrapper for OpenTelemetry instrumentation packages",
5
5
  "main": "libs/index.mjs",
6
6
  "scripts": {
@@ -31,9 +31,10 @@
31
31
  "homepage": "https://github.com/saidsef/tracing-node#readme",
32
32
  "dependencies": {
33
33
  "@opentelemetry/api": "^1.9.0",
34
+ "@opentelemetry/context-async-hooks": "^2.0.1",
34
35
  "@opentelemetry/exporter-trace-otlp-grpc": "^0.203.0",
35
36
  "@opentelemetry/instrumentation": "^0.203.0",
36
- "@opentelemetry/instrumentation-aws-sdk": "^0.56.0",
37
+ "@opentelemetry/instrumentation-aws-sdk": "^0.57.0",
37
38
  "@opentelemetry/instrumentation-connect": "^0.47.0",
38
39
  "@opentelemetry/instrumentation-dns": "^0.47.0",
39
40
  "@opentelemetry/instrumentation-express": "^0.52.0",
@@ -41,7 +42,6 @@
41
42
  "@opentelemetry/instrumentation-http": "^0.203.0",
42
43
  "@opentelemetry/instrumentation-ioredis": "^0.51.0",
43
44
  "@opentelemetry/instrumentation-pino": "^0.50.0",
44
- "@opentelemetry/propagator-b3": "^2.0.0",
45
45
  "@opentelemetry/resources": "^2.0.1",
46
46
  "@opentelemetry/sdk-trace-base": "^2.0.0",
47
47
  "@opentelemetry/sdk-trace-node": "^2.0.0",