Skip to content

Commit

Permalink
adding origin
Browse files Browse the repository at this point in the history
  • Loading branch information
obecny committed Sep 18, 2024
1 parent 3c20530 commit 22acec2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cleanupChildProcesses, createRunner } from '../../../utils/runner';

// jest.setTimeout(600_000); //helpful when debugging
// jest.setTimeout(600_000); // helpful when debugging

const EXPECTED_MESSAGE_SPAN_PRODUCER = expect.objectContaining({
op: 'message',
Expand All @@ -18,6 +18,7 @@ const EXPECTED_MESSAGE_SPAN_CONSUMER = expect.objectContaining({
'messaging.system': 'rabbitmq',
'otel.kind': 'CONSUMER',
'sentry.op': 'message',
'sentry.origin': 'auto.amqplib.otel.consumer',
}),
status: 'ok',
});
Expand Down
20 changes: 18 additions & 2 deletions packages/node/src/integrations/tracing/amqplib.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
import { AmqplibInstrumentation } from '@opentelemetry/instrumentation-amqplib';
import type { Span } from '@opentelemetry/api';
import { AmqplibInstrumentation, type AmqplibInstrumentationConfig } from '@opentelemetry/instrumentation-amqplib';
import { defineIntegration } from '@sentry/core';
import type { IntegrationFn } from '@sentry/types';
import { generateInstrumentOnce } from '../../otel/instrument';
import { addOriginToSpan } from '../../utils/addOriginToSpan';

const INTEGRATION_NAME = 'Amqplib';

export const instrumentAmqplib = generateInstrumentOnce(INTEGRATION_NAME, () => new AmqplibInstrumentation());
const config: AmqplibInstrumentationConfig = {
consumeEndHook: (span: Span) => {
addOriginToSpan(span, 'auto.amqplib.otel.consumer');
},
publishConfirmHook: (span: Span) => {
addOriginToSpan(span, 'auto.amqplib.otel.publisher');
}
};

export const instrumentAmqplib = generateInstrumentOnce(
INTEGRATION_NAME,
() =>
new AmqplibInstrumentation(config),
);

const _amqplibIntegration = (() => {
return {
Expand Down

0 comments on commit 22acec2

Please sign in to comment.