Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

fix: otel context propagation #269

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion detectors/node/resource-detector-deployment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@opentelemetry/api": "^1.6.0"
},
"dependencies": {
"@opentelemetry/resources": "~1.17.1",
"@opentelemetry/resources": "^1.17.1",
"@opentelemetry/semantic-conventions": "^1.17.1",
"opentelemetry-resource-detector-sync-api": "^0.29.0"
},
Expand Down
2 changes: 1 addition & 1 deletion detectors/node/resource-detector-git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@opentelemetry/api": "^1.6.0"
},
"dependencies": {
"@opentelemetry/resources": "~1.17.1",
"@opentelemetry/resources": "^1.17.1",
"@opentelemetry/semantic-conventions": "^1.17.1",
"opentelemetry-resource-detector-sync-api": "^0.29.0",
"uuid": "^8.3.2"
Expand Down
2 changes: 1 addition & 1 deletion detectors/node/resource-detector-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@opentelemetry/api": "^1.6.0"
},
"dependencies": {
"@opentelemetry/resources": "~1.17.1",
"@opentelemetry/resources": "^1.17.1",
"@opentelemetry/semantic-conventions": "^1.17.1",
"opentelemetry-resource-detector-sync-api": "^0.29.0",
"uuid": "^8.3.2"
Expand Down
2 changes: 1 addition & 1 deletion detectors/resource-detector-sync-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@opentelemetry/api": "^1.6.0"
},
"dependencies": {
"@opentelemetry/resources": "~1.17.1"
"@opentelemetry/resources": "^1.17.1"
},
"devDependencies": {
"@opentelemetry/api": "^1.6.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/instrumentation-elasticsearch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"dependencies": {
"@opentelemetry/core": "^1.17.1",
"@opentelemetry/instrumentation": "^0.44.0",
"@opentelemetry/instrumentation": "^0.45.1",
"@opentelemetry/semantic-conventions": "^1.17.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/instrumentation-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"@opentelemetry/core": "^1.17.1",
"@opentelemetry/instrumentation": "^0.44.0",
"@opentelemetry/instrumentation": "^0.45.1",
"@opentelemetry/semantic-conventions": "^1.17.1",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.7"
Expand Down
2 changes: 1 addition & 1 deletion packages/instrumentation-kafkajs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@opentelemetry/api": "^1.6.0"
},
"dependencies": {
"@opentelemetry/instrumentation": "^0.44.0",
"@opentelemetry/instrumentation": "^0.45.1",
"@opentelemetry/semantic-conventions": "^1.17.1"
},
"devDependencies": {
Expand Down
19 changes: 4 additions & 15 deletions packages/instrumentation-kafkajs/src/kafkajs.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
import {
SpanKind,
Span,
SpanStatusCode,
Context,
propagation,
Link,
trace,
context,
diag,
ROOT_CONTEXT,
} from '@opentelemetry/api';
import { SpanKind, Span, SpanStatusCode, Context, propagation, Link, trace, context, diag } from '@opentelemetry/api';
import {
SemanticAttributes,
MessagingOperationValues,
Expand Down Expand Up @@ -137,7 +126,7 @@ export class KafkaJsInstrumentation extends InstrumentationBase<typeof kafkaJs>
const self = this;
return function (payload: EachMessagePayload): Promise<void> {
const propagatedContext: Context = propagation.extract(
ROOT_CONTEXT,
context.active(),
payload.message.headers,
bufferTextMapGetter
);
Expand All @@ -163,12 +152,12 @@ export class KafkaJsInstrumentation extends InstrumentationBase<typeof kafkaJs>
payload.batch.topic,
undefined,
MessagingOperationValues.RECEIVE,
ROOT_CONTEXT
context.active()
);
return context.with(trace.setSpan(context.active(), receivingSpan), () => {
const spans = payload.batch.messages.map((message: KafkaMessage) => {
const propagatedContext: Context = propagation.extract(
ROOT_CONTEXT,
context.active(),
message.headers,
bufferTextMapGetter
);
Expand Down
2 changes: 2 additions & 0 deletions packages/instrumentation-kafkajs/test/kafkajs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import { propagation, context, SpanKind, SpanStatusCode, Span } from '@opentelemetry/api';
import { MessagingDestinationKindValues, SemanticAttributes } from '@opentelemetry/semantic-conventions';
import { getTestSpans, registerInstrumentationTesting } from '@opentelemetry/contrib-test-utils';
import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks';

const instrumentation = registerInstrumentationTesting(new KafkaJsInstrumentation());

Expand All @@ -26,6 +27,7 @@ import { DummyPropagation } from './DummyPropagation';
import { W3CBaggagePropagator, CompositePropagator } from '@opentelemetry/core';

describe('instrumentation-kafkajs', () => {
context.setGlobalContextManager(new AsyncHooksContextManager());
propagation.setGlobalPropagator(
new CompositePropagator({ propagators: [new DummyPropagation(), new W3CBaggagePropagator()] })
);
Expand Down
2 changes: 1 addition & 1 deletion packages/instrumentation-neo4j/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@opentelemetry/api": "^1.6.0"
},
"dependencies": {
"@opentelemetry/instrumentation": "^0.44.0",
"@opentelemetry/instrumentation": "^0.45.1",
"@opentelemetry/semantic-conventions": "^1.17.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/instrumentation-node-cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"dependencies": {
"@opentelemetry/contrib-test-utils": "^0.34.2",
"@opentelemetry/core": "^1.17.1",
"@opentelemetry/instrumentation": "^0.44.0",
"@opentelemetry/instrumentation": "^0.45.1",
"@opentelemetry/semantic-conventions": "^1.17.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/instrumentation-sequelize/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"dependencies": {
"@opentelemetry/core": "^1.17.1",
"@opentelemetry/instrumentation": "^0.44.0",
"@opentelemetry/instrumentation": "^0.45.1",
"@opentelemetry/semantic-conventions": "^1.17.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/instrumentation-typeorm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"dependencies": {
"@opentelemetry/core": "^1.17.1",
"@opentelemetry/instrumentation": "^0.44.0",
"@opentelemetry/instrumentation": "^0.45.1",
"@opentelemetry/semantic-conventions": "^1.17.1",
"is-promise": "^4.0.0"
},
Expand Down
Loading