Skip to content

Commit eca9fd6

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

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
@@ -1,9 +1,9 @@
11
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
22
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
33
import {
4+
debug,
45
getActiveSpan,
56
getRootSpan,
6-
logger,
77
SDK_VERSION,
88
SEMANTIC_ATTRIBUTE_SENTRY_OP,
99
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
@@ -77,7 +77,7 @@ export class ReactRouterInstrumentation extends InstrumentationBase<Instrumentat
7777
const rootSpan = activeSpan && getRootSpan(activeSpan);
7878

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

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,6 +1,6 @@
11
import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
22
import type { EventProcessor, Integration } from '@sentry/core';
3-
import { applySdkMetadata, getGlobalScope, logger, setTag } from '@sentry/core';
3+
import { applySdkMetadata, debug, getGlobalScope, setTag } from '@sentry/core';
44
import type { NodeClient, NodeOptions } from '@sentry/node';
55
import { getDefaultIntegrations as getNodeDefaultIntegrations, init as initNodeSdk, NODE_VERSION } from '@sentry/node';
66
import { DEBUG_BUILD } from '../common/debug-build';
@@ -34,7 +34,7 @@ export function init(options: NodeOptions): NodeClient | undefined {
3434
defaultIntegrations: getDefaultReactRouterServerIntegrations(options),
3535
};
3636

37-
DEBUG_BUILD && logger.log('Initializing SDK...');
37+
DEBUG_BUILD && debug.log('Initializing SDK...');
3838

3939
applySdkMetadata(opts, 'react-router', ['react-router', 'node']);
4040

@@ -67,7 +67,7 @@ export function init(options: NodeOptions): NodeClient | undefined {
6767
),
6868
);
6969

70-
DEBUG_BUILD && logger.log('SDK successfully initialized');
70+
DEBUG_BUILD && debug.log('SDK successfully initialized');
7171

7272
return client;
7373
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ vi.mock('@sentry/core', async () => {
88
return {
99
getActiveSpan: vi.fn(),
1010
getRootSpan: vi.fn(),
11-
logger: {
12-
debug: vi.fn(),
11+
debug: {
12+
log: vi.fn(),
1313
},
1414
SDK_VERSION: '1.0.0',
1515
SEMANTIC_ATTRIBUTE_SENTRY_OP: 'sentry.op',
@@ -80,9 +80,7 @@ describe('ReactRouterInstrumentation', () => {
8080
const req = createRequest('https://test.com/data');
8181
await wrappedHandler(req);
8282

83-
expect(SentryCore.logger.debug).toHaveBeenCalledWith(
84-
'No active root span found, skipping tracing for data request',
85-
);
83+
expect(SentryCore.debug.log).toHaveBeenCalledWith('No active root span found, skipping tracing for data request');
8684
expect(originalHandler).toHaveBeenCalledWith(req, undefined);
8785
});
8886

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)