Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@ test('Instruments ioredis automatically', async ({ baseURL }) => {

expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'set test-key [1 other arguments]',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'set test-key [1 other arguments]',
'db.system.name': 'redis',
'db.operation.name': 'set',
'db.query.text': 'set test-key [1 other arguments]',
}),
}),
);
expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'get test-key',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'get test-key',
'db.system.name': 'redis',
'db.operation.name': 'get',
'db.query.text': 'get test-key',
}),
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,27 @@ test.describe('orchestrion DB instrumentation', () => {

expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'set test-key [1 other arguments]',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'set test-key [1 other arguments]',
'db.system.name': 'redis',
'db.operation.name': 'set',
'db.query.text': 'set test-key [1 other arguments]',
}),
}),
);
expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'get test-key',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'get test-key',
'db.system.name': 'redis',
'db.operation.name': 'get',
'db.query.text': 'get test-key',
}),
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,28 @@ test('Instruments DB calls made during server-side rendering of a page', async (
);
expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'set page-key [1 other arguments]',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'set page-key [1 other arguments]',
'db.system.name': 'redis',
'db.operation.name': 'set',
'db.query.text': 'set page-key [1 other arguments]',
}),
}),
);
expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'get page-key',
status: 'ok',
data: expect.objectContaining({
'db.system.name': 'redis',
'db.operation.name': 'get',
'db.query.text': 'get page-key',
}),
}),
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,27 @@ test('Instruments ioredis automatically via orchestrion', async ({ baseURL }) =>

expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'set test-key [1 other arguments]',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'set test-key [1 other arguments]',
'db.system.name': 'redis',
'db.operation.name': 'set',
'db.query.text': 'set test-key [1 other arguments]',
}),
}),
);
expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'get test-key',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'get test-key',
'db.system.name': 'redis',
'db.operation.name': 'get',
'db.query.text': 'get test-key',
}),
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,27 @@ test('Instruments ioredis automatically', async ({ baseURL }) => {

expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'set test-key [1 other arguments]',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'set test-key [1 other arguments]',
'db.system.name': 'redis',
'db.operation.name': 'set',
'db.query.text': 'set test-key [1 other arguments]',
}),
}),
);
expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'get test-key',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'get test-key',
'db.system.name': 'redis',
'db.operation.name': 'get',
'db.query.text': 'get test-key',
}),
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,27 @@ test.describe('server - orchestrion build-time db instrumentation', () => {

expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'set test-key [1 other arguments]',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'set test-key [1 other arguments]',
'db.system.name': 'redis',
'db.operation.name': 'set',
'db.query.text': 'set test-key [1 other arguments]',
}),
}),
);
expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'get test-key',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'get test-key',
'db.system.name': 'redis',
'db.operation.name': 'get',
'db.query.text': 'get test-key',
}),
}),
);
Expand All @@ -59,7 +61,7 @@ test.describe('server - orchestrion build-time db instrumentation', () => {
// Every db span nests under the native instrumentation-API http.server transaction.
const rootSpanId = transactionEvent.contexts?.trace?.span_id;
const spanIds = new Set([rootSpanId, ...spans.map(span => span.span_id)]);
const dbSpans = spans.filter(span => span.op === 'db');
const dbSpans = spans.filter(span => span.origin === 'auto.db.redis');
expect(dbSpans.every(span => typeof span.parent_span_id === 'string' && spanIds.has(span.parent_span_id))).toBe(
true,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,27 @@ test('Instruments ioredis automatically via build-time orchestrion', async ({ ba

expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'set test-key [1 other arguments]',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'set test-key [1 other arguments]',
'db.system.name': 'redis',
'db.operation.name': 'set',
'db.query.text': 'set test-key [1 other arguments]',
}),
}),
);
expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'get test-key',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'get test-key',
'db.system.name': 'redis',
'db.operation.name': 'get',
'db.query.text': 'get test-key',
}),
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@ test('Instruments ioredis automatically', async ({ baseURL }) => {

expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'set test-key [1 other arguments]',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'set test-key [1 other arguments]',
'db.system.name': 'redis',
'db.operation.name': 'set',
'db.query.text': 'set test-key [1 other arguments]',
}),
}),
);
expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'get test-key',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'get test-key',
'db.system.name': 'redis',
'db.operation.name': 'get',
'db.query.text': 'get test-key',
}),
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,27 @@ test('Instruments ioredis automatically', async ({ baseURL }) => {

expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'set test-key [1 other arguments]',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'set test-key [1 other arguments]',
'db.system.name': 'redis',
'db.operation.name': 'set',
'db.query.text': 'set test-key [1 other arguments]',
}),
}),
);
expect(spans).toContainEqual(
expect.objectContaining({
op: 'db',
op: 'db.query',
origin: 'auto.db.redis',
description: 'get test-key',
status: 'ok',
data: expect.objectContaining({
'db.system': 'redis',
'db.statement': 'get test-key',
'db.system.name': 'redis',
'db.operation.name': 'get',
'db.query.text': 'get test-key',
}),
}),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import type { TransactionEvent } from '@sentry/core';
import { afterAll, describe, expect } from 'vitest';
import { isOrchestrionEnabled } from '../../../utils';
import { cleanupChildProcesses, createEsmAndCjsTests, describeWithDockerCompose } from '../../../utils/runner';

// Each scenario uses its own queue name to keep them isolated on the shared broker, so the
// expected producer span is parameterized by the routing key (queue name) it publishes to.
// The scenarios all publish via `sendToQueue`, which delegates to `publish('', queue, ...)` — i.e. the
// default (empty) exchange with the queue name as the routing key.
const orchestrionMessagingAttributes = isOrchestrionEnabled() ? { 'messaging.operation.name': 'send' } : {};

const expectedProducerSpan = (routingKey: string) =>
expect.objectContaining({
op: 'queue.publish',
data: expect.objectContaining({
'messaging.system': 'rabbitmq',
// Legacy messaging attributes emitted by both the OTel and orchestrion integrations.
'messaging.destination': '',
'messaging.destination_kind': 'topic',
'messaging.rabbitmq.routing_key': routingKey,
'messaging.url': 'amqp://sentry:***@localhost:5672/',
'messaging.protocol': 'AMQP',
'messaging.protocol_version': '0.9.1',
'net.peer.name': 'localhost',
'net.peer.port': 5672,
...orchestrionMessagingAttributes,
'messaging.operation.type': 'send',
'messaging.destination.name': '',
'messaging.rabbitmq.destination.routing_key': routingKey,
Expand All @@ -35,18 +30,16 @@ const expectedProducerSpan = (routingKey: string) =>
status: 'ok',
});

const consumerMessagingAttributes = isOrchestrionEnabled() ? { 'messaging.operation.name': 'process' } : {};

const EXPECTED_MESSAGE_SPAN_CONSUMER = expect.objectContaining({
op: 'queue.process',
data: expect.objectContaining({
'messaging.system': 'rabbitmq',
// Legacy messaging attributes emitted by both the OTel and orchestrion integrations. The consumer
// reads the default exchange ('') off the delivered message and the queue name as the routing key.
'messaging.destination': '',
'messaging.destination_kind': 'topic',
'messaging.rabbitmq.routing_key': 'queue1',
'messaging.operation': 'process',
// The consumer reads the default exchange ('') off the delivered message and the queue name as the routing key.
'messaging.destination.name': '',
'messaging.rabbitmq.destination.routing_key': 'queue1',
...consumerMessagingAttributes,
'messaging.operation.type': 'process',
'sentry.kind': 'consumer',
'sentry.op': 'queue.process',
Expand Down
Loading
Loading