Skip to content
Merged
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
@@ -1,7 +1,7 @@
import type { TransactionEvent } from '@sentry/core';
import { afterAll, describe, expect } from 'vitest';
import { isOrchestrionEnabled } from '../../../utils';
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';
import { cleanupChildProcesses, createEsmAndCjsTests, describeWithDockerCompose } from '../../../utils/runner';

// The span origin depends on which instrumentation is active. These blocks drive the SDK's default
// integrations, so when the generic orchestrion run is enabled (via INJECT_ORCHESTRION) the OTel
Expand Down Expand Up @@ -73,7 +73,7 @@ const EXPECTED_MESSAGE_SPAN_CONSUMER = expect.objectContaining({
status: 'ok',
});

describe('amqplib auto-instrumentation', () => {
describeWithDockerCompose('amqplib auto-instrumentation', { workingDirectory: [__dirname] }, () => {
afterAll(async () => {
cleanupChildProcesses();
});
Expand All @@ -93,9 +93,6 @@ describe('amqplib auto-instrumentation', () => {
const receivedTransactions: TransactionEvent[] = [];

await createTestRunner()
.withDockerCompose({
workingDirectory: [__dirname],
})
.expect({
transaction: (transaction: TransactionEvent) => {
receivedTransactions.push(transaction);
Expand Down Expand Up @@ -145,9 +142,6 @@ describe('amqplib auto-instrumentation', () => {
const receivedTransactions: TransactionEvent[] = [];

await createTestRunner()
.withDockerCompose({
workingDirectory: [__dirname],
})
.expect({
transaction: (transaction: TransactionEvent) => {
receivedTransactions.push(transaction);
Expand Down Expand Up @@ -194,9 +188,6 @@ describe('amqplib auto-instrumentation', () => {
{ timeout: 60_000 },
async () => {
await createTestRunner()
.withDockerCompose({
workingDirectory: [__dirname],
})
.expect({
transaction: (transaction: TransactionEvent) => {
expect(transaction.transaction).toBe('root span');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,104 +1,107 @@
import { afterAll, describe, expect } from 'vitest';
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';
import { afterAll, expect } from 'vitest';
import { cleanupChildProcesses, createEsmAndCjsTests, describeWithDockerCompose } from '../../../utils/runner';

describe('ioredis v5.11 diagnostics_channel auto instrumentation', () => {
afterAll(() => {
cleanupChildProcesses();
});
describeWithDockerCompose(
'ioredis v5.11 diagnostics_channel auto instrumentation',
{ workingDirectory: [__dirname] },
() => {
afterAll(() => {
cleanupChildProcesses();
});

const EXPECTED_TRANSACTION = {
transaction: 'Test Span IORedis 5.11 DC',
spans: expect.arrayContaining([
expect.objectContaining({
op: 'db.redis',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.op': 'db.redis',
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.system.name': 'redis',
'db.query.text': 'set dc-test-key ?',
const EXPECTED_TRANSACTION = {
transaction: 'Test Span IORedis 5.11 DC',
spans: expect.arrayContaining([
expect.objectContaining({
op: 'db.redis',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.op': 'db.redis',
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.system.name': 'redis',
'db.query.text': 'set dc-test-key ?',
}),
}),
}),
expect.objectContaining({
description: 'dc-cache:test-key',
op: 'cache.put',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.query.text': 'set dc-cache:test-key ?',
'cache.key': ['dc-cache:test-key'],
'cache.item_size': 2,
expect.objectContaining({
description: 'dc-cache:test-key',
op: 'cache.put',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.query.text': 'set dc-cache:test-key ?',
'cache.key': ['dc-cache:test-key'],
'cache.item_size': 2,
}),
}),
}),
expect.objectContaining({
description: 'dc-cache:test-key-ex',
op: 'cache.put',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.query.text': 'set dc-cache:test-key-ex ? ? ?',
'cache.key': ['dc-cache:test-key-ex'],
'cache.item_size': 2,
expect.objectContaining({
description: 'dc-cache:test-key-ex',
op: 'cache.put',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.query.text': 'set dc-cache:test-key-ex ? ? ?',
'cache.key': ['dc-cache:test-key-ex'],
'cache.item_size': 2,
}),
}),
}),
expect.objectContaining({
op: 'db.redis',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.op': 'db.redis',
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.system.name': 'redis',
'db.query.text': 'get dc-test-key',
expect.objectContaining({
op: 'db.redis',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.op': 'db.redis',
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.system.name': 'redis',
'db.query.text': 'get dc-test-key',
}),
}),
}),
expect.objectContaining({
description: 'dc-cache:test-key',
op: 'cache.get',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.query.text': 'get dc-cache:test-key',
'cache.hit': true,
'cache.key': ['dc-cache:test-key'],
'cache.item_size': 10,
expect.objectContaining({
description: 'dc-cache:test-key',
op: 'cache.get',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.query.text': 'get dc-cache:test-key',
'cache.hit': true,
'cache.key': ['dc-cache:test-key'],
'cache.item_size': 10,
}),
}),
}),
expect.objectContaining({
description: 'dc-cache:unavailable-data',
op: 'cache.get',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.query.text': 'get dc-cache:unavailable-data',
'cache.hit': false,
'cache.key': ['dc-cache:unavailable-data'],
expect.objectContaining({
description: 'dc-cache:unavailable-data',
op: 'cache.get',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.query.text': 'get dc-cache:unavailable-data',
'cache.hit': false,
'cache.key': ['dc-cache:unavailable-data'],
}),
}),
}),
expect.objectContaining({
op: 'db.redis',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.op': 'db.redis',
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.system.name': 'redis',
'db.query.text': 'mget ? ? ?',
expect.objectContaining({
op: 'db.redis',
origin: 'auto.db.redis.diagnostic_channel',
data: expect.objectContaining({
'sentry.op': 'db.redis',
'sentry.origin': 'auto.db.redis.diagnostic_channel',
'db.system.name': 'redis',
'db.query.text': 'mget ? ? ?',
}),
}),
}),
]),
};
]),
};

const EXPECTED_CONNECT = {
transaction: 'redis-connect',
};
const EXPECTED_CONNECT = {
transaction: 'redis-connect',
};

createEsmAndCjsTests(__dirname, 'scenario-ioredis-5-11.mjs', 'instrument.mjs', (createTestRunner, test) => {
test('creates spans for ioredis v5.11 commands via diagnostics_channel', { timeout: 75_000 }, async () => {
await createTestRunner()
.withDockerCompose({ workingDirectory: [__dirname] })
.expect({ transaction: EXPECTED_CONNECT })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
.completed();
createEsmAndCjsTests(__dirname, 'scenario-ioredis-5-11.mjs', 'instrument.mjs', (createTestRunner, test) => {
test('creates spans for ioredis v5.11 commands via diagnostics_channel', { timeout: 75_000 }, async () => {
await createTestRunner()
.expect({ transaction: EXPECTED_CONNECT })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
.completed();
});
});
});
});
},
);
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { TransactionEvent } from '@sentry/core';
import { afterAll, describe, expect } from 'vitest';
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';
import { afterAll, expect } from 'vitest';
import { cleanupChildProcesses, createEsmAndCjsTests, describeWithDockerCompose } from '../../../utils/runner';

describe('kafkajs', () => {
describeWithDockerCompose('kafkajs', { workingDirectory: [__dirname] }, () => {
afterAll(() => {
cleanupChildProcesses();
});
Expand All @@ -14,9 +14,6 @@ describe('kafkajs', () => {
const receivedTransactions: TransactionEvent[] = [];

await createRunner()
.withDockerCompose({
workingDirectory: [__dirname],
})
.expect({
transaction: (transaction: TransactionEvent) => {
receivedTransactions.push(transaction);
Expand Down Expand Up @@ -87,9 +84,6 @@ describe('kafkajs', () => {
createEsmAndCjsTests(__dirname, 'scenario-error.mjs', 'instrument.mjs', (createRunner, test) => {
test('marks the producer span as errored when a send fails', { timeout: 90_000 }, async () => {
await createRunner()
.withDockerCompose({
workingDirectory: [__dirname],
})
.expect({
transaction: (transaction: TransactionEvent) => {
expect(transaction.transaction).toBe('send invalid topic name');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async function run() {

await mysql2Client('User').insert({ name: 'jane', email: 'jane@domain.com' });
await mysql2Client('User').select('*');
await mysql2Client.schema.dropTable('User');
} finally {
await mysql2Client.destroy();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect } from 'vitest';
import { createEsmAndCjsTests } from '../../../../utils/runner';
import { createEsmAndCjsTests, describeWithDockerCompose } from '../../../../utils/runner';

describe('knex auto instrumentation', () => {
describeWithDockerCompose('knex auto instrumentation', { workingDirectory: [__dirname] }, () => {
// Update this if another knex version is installed
const KNEX_VERSION = '2.5.1';

Expand Down Expand Up @@ -62,11 +62,7 @@ describe('knex auto instrumentation', () => {
]),
};

await createRunner()
.withDockerCompose({ workingDirectory: [__dirname] })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
.completed();
await createRunner().expect({ transaction: EXPECTED_TRANSACTION }).start().completed();
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async function run() {
await pgClient('DoesNotExist')
.select('*')
.catch(() => {});
await pgClient.schema.dropTable('User');
} finally {
await pgClient.destroy();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { describe, expect } from 'vitest';
import { createEsmAndCjsTests } from '../../../../utils/runner';
import { createEsmAndCjsTests, describeWithDockerCompose } from '../../../../utils/runner';

describe('knex auto instrumentation', () => {
// Update this if another knex version is installed
const KNEX_VERSION = '2.5.1';

describe('with `pg` client', () => {
describeWithDockerCompose('with `pg` client', { workingDirectory: [__dirname] }, () => {
createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => {
test('should auto-instrument `knex` package', { timeout: 60_000 }, async () => {
const EXPECTED_TRANSACTION = {
Expand Down Expand Up @@ -76,11 +76,7 @@ describe('knex auto instrumentation', () => {
]),
};

await createRunner()
.withDockerCompose({ workingDirectory: [__dirname] })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
.completed();
await createRunner().expect({ transaction: EXPECTED_TRANSACTION }).start().completed();
});
});
});
Expand Down
Loading
Loading