Skip to content

Commit 8b22101

Browse files
committed
fixup! fixup! feat(deno)!: rename orchestrion integrations to match other SDKs
Adding a regression test to prove the bugbot finding.
1 parent 06d377b commit 8b22101

2 files changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Spawned by test.ts via `deno run`, in a fresh process so nothing else has
2+
// installed the AsyncLocalStorage context strategy.
3+
//
4+
// This builds a `DenoClient` DIRECTLY — `new DenoClient(...)` + `client.init()`
5+
// instead of calling `Sentry.init()`, then drives the mysql orchestrion channel
6+
// The mysql subscriber only binds once the ALS context strategy is installed
7+
// (it waits for the tracing-channel binding), so a nested db span here proves
8+
// `DenoClient.init()` installs that strategy on the direct-construction path.
9+
// Without it, the subscriber never binds and no span is produced.
10+
import { createStackParser, nodeStackLineParser } from '@sentry/core';
11+
import { DenoClient, getCurrentScope, getDefaultIntegrations, startSpan } from '@sentry/deno';
12+
import { tracingChannel } from 'node:diagnostics_channel';
13+
14+
let nested = false;
15+
16+
const client = new DenoClient({
17+
dsn: 'https://username@domain/123',
18+
tracesSampleRate: 1,
19+
integrations: getDefaultIntegrations({}),
20+
stackParser: createStackParser(nodeStackLineParser()),
21+
beforeSendTransaction(event) {
22+
const spans = event.spans ?? [];
23+
if (spans.some(s => s.op === 'db' && s.data?.['sentry.origin'] === 'auto.db.orchestrion.mysql')) {
24+
nested = true;
25+
}
26+
return null;
27+
},
28+
transport: () => ({ send: () => Promise.resolve({}), flush: () => Promise.resolve(true) }),
29+
});
30+
31+
client.init();
32+
getCurrentScope().setClient(client);
33+
34+
const channel = tracingChannel('orchestrion:mysql:query');
35+
const ctx = {
36+
arguments: ['SELECT 1 AS solution'],
37+
self: { config: { host: '127.0.0.1', port: 3306, database: 'mydb', user: 'root' } },
38+
};
39+
40+
startSpan({ name: 'parent', op: 'test' }, () => {
41+
channel.start.runStores(ctx, () => {
42+
channel.end.publish(ctx);
43+
});
44+
channel.asyncStart.runStores(ctx, () => {
45+
channel.asyncEnd.publish(ctx);
46+
});
47+
});
48+
49+
await client.flush(2000);
50+
51+
// eslint-disable-next-line no-console
52+
console.log(`SCENARIO nested=${nested}`);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// <reference lib="deno.ns" />
2+
3+
import { assert } from 'https://deno.land/std@0.212.0/assert/assert.ts';
4+
import { assertEquals } from 'https://deno.land/std@0.212.0/assert/assert_equals.ts';
5+
6+
// A directly-constructed `DenoClient` (no `Sentry.init()`) is a supported path.
7+
// The SDK's own tests use it. It must still install the AsyncLocalStorage
8+
// context strategy, which the channel integrations depend on. We run it in a
9+
// fresh process so no prior `init()` has installed the strategy already, then
10+
// assert a nested mysql span appears (see scenario.mjs for why that proves the
11+
// strategy was installed by `client.init()`).
12+
Deno.test('DenoClient.init installs the AsyncLocalStorage strategy on the direct-construction path', async () => {
13+
const scenario = new URL('./scenario.mjs', import.meta.url);
14+
15+
// The package root — where `node_modules` (and thus `@sentry/deno`) resolves
16+
// for the spawned `deno run`.
17+
const cwd = new URL('../../', import.meta.url);
18+
19+
const command = new Deno.Command('deno', {
20+
args: ['run', '--allow-all', scenario.pathname],
21+
cwd: cwd.pathname,
22+
stdout: 'piped',
23+
stderr: 'piped',
24+
});
25+
26+
const { code, stdout, stderr } = await command.output();
27+
const out = new TextDecoder().decode(stdout);
28+
const err = new TextDecoder().decode(stderr);
29+
30+
assertEquals(code, 0, `scenario exited ${code}\nstdout:\n${out}\nstderr:\n${err}`);
31+
32+
const line = out.split('\n').find(l => l.startsWith('SCENARIO')) ?? '';
33+
assert(line, `no SCENARIO line in output:\n${out}\nstderr:\n${err}`);
34+
assert(
35+
line.includes('nested=true'),
36+
`expected a nested mysql span via the direct client path (ACS must be installed by client.init), got: ${line}`,
37+
);
38+
});

0 commit comments

Comments
 (0)