Skip to content

Commit 0c82861

Browse files
committed
ref: remove uneeded guards
1 parent e96119e commit 0c82861

2 files changed

Lines changed: 0 additions & 21 deletions

File tree

packages/server-utils/src/mysql2/mysql2-dc-subscriber.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ export interface MySQL2ConnectData {
7676
*/
7777
export type MySQL2TracingChannelFactory = <T extends object>(name: string) => TracingChannel<T, T>;
7878

79-
let subscribed = false;
80-
8179
/**
8280
* Subscribe Sentry span handlers to mysql2's diagnostics-channel events
8381
* (`mysql2:query`, `:execute`, `:connect`, `:pool:connect`), published by
@@ -86,19 +84,12 @@ let subscribed = false;
8684
* On older mysql2 versions the channels are never published to, so the
8785
* subscribers are inert — there is no double-instrumentation against the
8886
* vendored OTel patcher, which is gated to `< 3.20.0`.
89-
*
90-
* Idempotent: subsequent calls are a no-op.
9187
*/
9288
export function subscribeMysql2DiagnosticChannels(tracingChannel: MySQL2TracingChannelFactory): void {
93-
if (subscribed) {
94-
return;
95-
}
96-
9789
setupQueryChannel(tracingChannel, MYSQL2_DC_CHANNEL_QUERY);
9890
setupQueryChannel(tracingChannel, MYSQL2_DC_CHANNEL_EXECUTE);
9991
setupConnectChannel(tracingChannel, MYSQL2_DC_CHANNEL_CONNECT, 'mysql2.connect');
10092
setupConnectChannel(tracingChannel, MYSQL2_DC_CHANNEL_POOL_CONNECT, 'mysql2.pool.connect');
101-
subscribed = true;
10293
}
10394

10495
function setupQueryChannel(tracingChannel: MySQL2TracingChannelFactory, channelName: string): void {

packages/server-utils/test/mysql2/mysql2-dc-subscriber.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,4 @@ describe('subscribeMysql2DiagnosticChannels', () => {
287287
expect(json.data['server.port']).toBeUndefined();
288288
});
289289
});
290-
291-
describe('idempotency', () => {
292-
it('does not throw or double-subscribe on a second call', async () => {
293-
subscribeMysql2DiagnosticChannels(factory);
294-
295-
const { span } = await traceOperation(MYSQL2_DC_CHANNEL_QUERY, { query: 'SELECT 1' }, { result: [] });
296-
297-
// a single subscription means a single span, ended exactly once
298-
expect(span).toBeDefined();
299-
expect(spanToJSON(span!).timestamp).toBeDefined();
300-
});
301-
});
302290
});

0 commit comments

Comments
 (0)