Skip to content

Commit

Permalink
fix: span processor v2 - package version bump (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
saidsef authored Feb 22, 2025
1 parent 5739467 commit 0b93197
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions libs/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ export function setupTracing(options = {}) {
concurrencyLimit = 10,
} = options;

// Register the span processor with the tracer provider
const exporter = new OTLPTraceExporter(exportOptions);
const spanProcessor = new BatchSpanProcessor(exporter);

tracerProvider = new NodeTracerProvider({
spanProcessors: [spanProcessor],
resource: new Resource({
[SemanticResourceAttributes.CONTAINER_NAME]: containerName || serviceName,
[SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: deploymentEnvironment,
Expand All @@ -84,13 +89,13 @@ export function setupTracing(options = {}) {
// Initialize the tracer provider with propagators
tracerProvider.register({
propagator: new CompositePropagator({
propagators: [
new W3CBaggagePropagator(),
new W3CTraceContextPropagator(),
new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }),
],
}),
});
propagators: [
new W3CBaggagePropagator(),
new W3CTraceContextPropagator(),
new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }),
],
}),
});

// Configure exporter with the Collector endpoint - uses gRPC
const exportOptions = {
Expand All @@ -99,11 +104,6 @@ export function setupTracing(options = {}) {
timeoutMillis: 1000,
};

// Register the span processor with the tracer provider
const exporter = new OTLPTraceExporter(exportOptions);
const spanProcessor = new BatchSpanProcessor(exporter);
tracerProvider.activeSpanProcessor(spanProcessor);

// Ignore spans from static assets.
const ignoreIncomingRequestHook = (req) => {
const isStaticAsset = !!req.url.match(/^\/metrics|\/healthz.*$/);
Expand All @@ -121,8 +121,8 @@ export function setupTracing(options = {}) {
new AwsInstrumentation({ sqsExtractContextPropagationFromPayload: true, }),
new DnsInstrumentation(),
new RedisInstrumentation(),
],
});
],
});

// Return the tracer for the service
return tracerProvider.getTracer(serviceName);
Expand Down
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.2.1",
"version": "3.2.2",
"description": "tracing NodeJS - This is a wrapper for OpenTelemetry instrumentation packages",
"main": "libs/index.mjs",
"scripts": {
Expand Down

0 comments on commit 0b93197

Please sign in to comment.