Skip to content

Commit b6634c6

Browse files
committed
ref(react-router): Use debug instead of logger
1 parent fbd0a44 commit b6634c6

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

packages/react-router/src/server/instrumentation/reactRouter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
22
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
33
import { SEMATTRS_HTTP_TARGET } from '@opentelemetry/semantic-conventions';
44
import {
5+
debug,
56
getActiveSpan,
67
getRootSpan,
7-
logger,
88
SDK_VERSION,
99
SEMANTIC_ATTRIBUTE_SENTRY_OP,
1010
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
@@ -80,7 +80,7 @@ export class ReactRouterInstrumentation extends InstrumentationBase<Instrumentat
8080
const rootSpan = activeSpan && getRootSpan(activeSpan);
8181

8282
if (!rootSpan) {
83-
DEBUG_BUILD && logger.debug('No active root span found, skipping tracing for data request');
83+
DEBUG_BUILD && debug.log('No active root span found, skipping tracing for data request');
8484
return originalRequestHandler(request, initialContext);
8585
}
8686

packages/react-router/src/server/integration/lowQualityTransactionsFilterIntegration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Client, type Event, type EventHint, defineIntegration, logger } from '@sentry/core';
1+
import { type Client, type Event, type EventHint, debug, defineIntegration } from '@sentry/core';
22
import type { NodeOptions } from '@sentry/node';
33

44
/**
@@ -23,7 +23,7 @@ function _lowQualityTransactionsFilterIntegration(options: NodeOptions): {
2323
const transaction = event.transaction;
2424

2525
if (matchedRegexes.some(regex => transaction.match(regex))) {
26-
options.debug && logger.log('[ReactRouter] Filtered node_modules transaction:', event.transaction);
26+
options.debug && debug.log('[ReactRouter] Filtered node_modules transaction:', event.transaction);
2727
return null;
2828
}
2929

packages/react-router/src/server/sdk.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Integration } from '@sentry/core';
2-
import { applySdkMetadata, logger, setTag } from '@sentry/core';
2+
import { applySdkMetadata, debug, setTag } from '@sentry/core';
33
import type { NodeClient, NodeOptions } from '@sentry/node';
44
import { getDefaultIntegrations as getNodeDefaultIntegrations, init as initNodeSdk } from '@sentry/node';
55
import { DEBUG_BUILD } from '../common/debug-build';
@@ -27,15 +27,15 @@ export function init(options: NodeOptions): NodeClient | undefined {
2727
defaultIntegrations: getDefaultReactRouterServerIntegrations(options),
2828
};
2929

30-
DEBUG_BUILD && logger.log('Initializing SDK...');
30+
DEBUG_BUILD && debug.log('Initializing SDK...');
3131

3232
applySdkMetadata(opts, 'react-router', ['react-router', 'node']);
3333

3434
const client = initNodeSdk(opts);
3535

3636
setTag('runtime', 'node');
3737

38-
DEBUG_BUILD && logger.log('SDK successfully initialized');
38+
DEBUG_BUILD && debug.log('SDK successfully initialized');
3939

4040
return client;
4141
}

packages/react-router/test/server/instrumentation/reactRouterServer.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ vi.mock('@sentry/core', async () => {
1010
getRootSpan: vi.fn(),
1111
spanToJSON: vi.fn(),
1212
updateSpanName: vi.fn(),
13-
logger: {
14-
debug: vi.fn(),
13+
debug: {
14+
log: vi.fn(),
1515
},
1616
SDK_VERSION: '1.0.0',
1717
SEMANTIC_ATTRIBUTE_SENTRY_OP: 'sentry.op',
@@ -82,9 +82,7 @@ describe('ReactRouterInstrumentation', () => {
8282
const req = createRequest('https://test.com/data');
8383
await wrappedHandler(req);
8484

85-
expect(SentryCore.logger.debug).toHaveBeenCalledWith(
86-
'No active root span found, skipping tracing for data request',
87-
);
85+
expect(SentryCore.debug.log).toHaveBeenCalledWith('No active root span found, skipping tracing for data request');
8886
expect(originalHandler).toHaveBeenCalledWith(req, undefined);
8987
});
9088

packages/react-router/test/server/lowQualityTransactionsFilterIntegration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as SentryNode from '@sentry/node';
44
import { afterEach, describe, expect, it, vi } from 'vitest';
55
import { lowQualityTransactionsFilterIntegration } from '../../src/server/integration/lowQualityTransactionsFilterIntegration';
66

7-
const loggerLog = vi.spyOn(SentryCore.logger, 'log').mockImplementation(() => {});
7+
const debugLoggerLogSpy = vi.spyOn(SentryCore.debug, 'log').mockImplementation(() => {});
88

99
describe('Low Quality Transactions Filter Integration', () => {
1010
afterEach(() => {
@@ -30,7 +30,7 @@ describe('Low Quality Transactions Filter Integration', () => {
3030

3131
expect(result).toBeNull();
3232

33-
expect(loggerLog).toHaveBeenCalledWith('[ReactRouter] Filtered node_modules transaction:', transaction);
33+
expect(debugLoggerLogSpy).toHaveBeenCalledWith('[ReactRouter] Filtered node_modules transaction:', transaction);
3434
});
3535
});
3636

0 commit comments

Comments
 (0)