Skip to content

Commit ff87af2

Browse files
authored
Merge branch 'develop' into cg-e2e-test-selectively
2 parents d1dfa68 + d059b06 commit ff87af2

File tree

6 files changed

+53
-94
lines changed

6 files changed

+53
-94
lines changed

MIGRATION.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ These docs walk through how to migrate our JavaScript SDKs through different maj
66
- Upgrading from [SDK 6.x to 7.x](./docs/migration/v6-to-v7.md)
77
- Upgrading from [SDK 7.x to 8.x](./docs/migration/v7-to-v8.md)
88
- Upgrading from [SDK 8.x to 9.x](./docs/migration/v8-to-v9.md)
9-
<<<<<<< HEAD
10-
- # Upgrading from [SDK 9.x to 10.x](#upgrading-from-9x-to-10x)
11-
- Upgrading from [SDK 9.x to 10.x](#upgrading-from-8x-to-9x)
12-
> > > > > > > f726d5ab5 (chore: Add migration guide for v10 and move v8->v9 guide to docs)
9+
- Upgrading from [SDK 9.x to 10.x](#upgrading-from-9x-to-10x)
1310

1411
# Upgrading from 9.x to 10.x
1512

@@ -41,6 +38,7 @@ Updates and fixes for version 9 will be published as `SentryNodeServerlessSDKv9`
4138

4239
- `BaseClient` was removed, use `Client` as a direct replacement.
4340
- `hasTracingEnabled` was removed, use `hasSpansEnabled` as a direct replacement.
41+
- `logger` and type `Logger` were removed, use `debug` and type `SentryDebugLogger` instead.
4442

4543
## No Version Support Timeline
4644

dev-packages/e2e-tests/test-applications/nuxt-3/server/plugins/customNitroErrorHandler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Context, GLOBAL_OBJ, flush, logger, vercelWaitUntil } from '@sentry/core';
1+
import { Context, GLOBAL_OBJ, flush, debug, vercelWaitUntil } from '@sentry/core';
22
import * as SentryNode from '@sentry/node';
33
import { H3Error } from 'h3';
44
import type { CapturedErrorContext } from 'nitropack';
@@ -74,10 +74,10 @@ async function flushWithTimeout(): Promise<void> {
7474
const isDebug = sentryClient ? sentryClient.getOptions().debug : false;
7575

7676
try {
77-
isDebug && logger.log('Flushing events...');
77+
isDebug && debug.log('Flushing events...');
7878
await flush(2000);
79-
isDebug && logger.log('Done flushing events');
79+
isDebug && debug.log('Done flushing events');
8080
} catch (e) {
81-
isDebug && logger.log('Error while flushing events:\n', e);
81+
isDebug && debug.log('Error while flushing events:\n', e);
8282
}
8383
}

packages/core/src/carrier.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { AsyncContextStrategy } from './asyncContext/types';
33
import type { Client } from './client';
44
import type { Scope } from './scope';
55
import type { SerializedLog } from './types-hoist/log';
6-
import type { Logger } from './utils/debug-logger';
76
import { SDK_VERSION } from './utils/version';
87
import { GLOBAL_OBJ } from './utils/worldwide';
98

@@ -26,9 +25,6 @@ export interface SentryCarrier {
2625
globalScope?: Scope;
2726
defaultIsolationScope?: Scope;
2827
defaultCurrentScope?: Scope;
29-
/** @deprecated Logger is no longer set. Instead, we keep enabled state in loggerSettings. */
30-
// eslint-disable-next-line deprecation/deprecation
31-
logger?: Logger;
3228
loggerSettings?: { enabled: boolean };
3329
/**
3430
* A map of Sentry clients to their log buffers.

packages/core/src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,8 @@ export {
161161
isVueViewModel,
162162
} from './utils/is';
163163
export { isBrowser } from './utils/isBrowser';
164-
// eslint-disable-next-line deprecation/deprecation
165-
export { CONSOLE_LEVELS, consoleSandbox, debug, logger, originalConsoleMethods } from './utils/debug-logger';
166-
// eslint-disable-next-line deprecation/deprecation
167-
export type { Logger, SentryDebugLogger } from './utils/debug-logger';
164+
export { CONSOLE_LEVELS, consoleSandbox, debug, originalConsoleMethods } from './utils/debug-logger';
165+
export type { SentryDebugLogger } from './utils/debug-logger';
168166
export {
169167
addContextToFrame,
170168
addExceptionMechanism,

packages/core/src/utils/debug-logger.ts

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,6 @@ import { DEBUG_BUILD } from '../debug-build';
33
import type { ConsoleLevel } from '../types-hoist/instrument';
44
import { GLOBAL_OBJ } from './worldwide';
55

6-
/**
7-
* A Sentry Logger instance.
8-
*
9-
* @deprecated Use {@link debug} instead with the {@link SentryDebugLogger} type.
10-
*/
11-
export interface Logger {
12-
disable(): void;
13-
enable(): void;
14-
isEnabled(): boolean;
15-
log(...args: Parameters<typeof console.log>): void;
16-
info(...args: Parameters<typeof console.info>): void;
17-
warn(...args: Parameters<typeof console.warn>): void;
18-
error(...args: Parameters<typeof console.error>): void;
19-
debug(...args: Parameters<typeof console.debug>): void;
20-
assert(...args: Parameters<typeof console.assert>): void;
21-
trace(...args: Parameters<typeof console.trace>): void;
22-
}
23-
246
export interface SentryDebugLogger {
257
disable(): void;
268
enable(): void;
@@ -115,18 +97,6 @@ function error(...args: Parameters<typeof console.error>): void {
11597
_maybeLog('error', ...args);
11698
}
11799

118-
function _debug(...args: Parameters<typeof console.debug>): void {
119-
_maybeLog('debug', ...args);
120-
}
121-
122-
function assert(...args: Parameters<typeof console.assert>): void {
123-
_maybeLog('assert', ...args);
124-
}
125-
126-
function trace(...args: Parameters<typeof console.trace>): void {
127-
_maybeLog('trace', ...args);
128-
}
129-
130100
function _maybeLog(level: ConsoleLevel, ...args: Parameters<(typeof console)[typeof level]>): void {
131101
if (!DEBUG_BUILD) {
132102
return;
@@ -147,36 +117,6 @@ function _getLoggerSettings(): { enabled: boolean } {
147117
return getGlobalSingleton('loggerSettings', () => ({ enabled: false }));
148118
}
149119

150-
/**
151-
* This is a logger singleton which either logs things or no-ops if logging is not enabled.
152-
* The logger is a singleton on the carrier, to ensure that a consistent logger is used throughout the SDK.
153-
*
154-
* @deprecated Use {@link debug} instead.
155-
*/
156-
export const logger = {
157-
/** Enable logging. */
158-
enable,
159-
/** Disable logging. */
160-
disable,
161-
/** Check if logging is enabled. */
162-
isEnabled,
163-
/** Log a message. */
164-
log,
165-
/** Log level info */
166-
info,
167-
/** Log a warning. */
168-
warn,
169-
/** Log an error. */
170-
error,
171-
/** Log a debug message. */
172-
debug: _debug,
173-
/** Log an assertion. */
174-
assert,
175-
/** Log a trace. */
176-
trace,
177-
// eslint-disable-next-line deprecation/deprecation
178-
} satisfies Logger;
179-
180120
/**
181121
* This is a logger singleton which either logs things or no-ops if logging is not enabled.
182122
*/

packages/core/test/lib/tracing/trace.test.ts

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -660,30 +660,57 @@ describe('startSpan', () => {
660660
});
661661
});
662662

663-
it('samples with a tracesSampler', () => {
664-
const tracesSampler = vi.fn(() => {
663+
describe('uses tracesSampler if defined', () => {
664+
const tracesSampler = vi.fn<() => boolean | number>(() => {
665665
return true;
666666
});
667667

668-
const options = getDefaultTestClientOptions({ tracesSampler });
669-
client = new TestClient(options);
670-
setCurrentClient(client);
671-
client.init();
668+
it.each([true, 1])('returns a positive sampling decision if tracesSampler returns %s', tracesSamplerResult => {
669+
tracesSampler.mockReturnValueOnce(tracesSamplerResult);
672670

673-
startSpan({ name: 'outer', attributes: { test1: 'aa', test2: 'aa', test3: 'bb' } }, outerSpan => {
674-
expect(outerSpan).toBeDefined();
671+
const options = getDefaultTestClientOptions({ tracesSampler });
672+
client = new TestClient(options);
673+
setCurrentClient(client);
674+
client.init();
675+
676+
startSpan({ name: 'outer', attributes: { test1: 'aa', test2: 'aa', test3: 'bb' } }, outerSpan => {
677+
expect(outerSpan).toBeDefined();
678+
expect(spanIsSampled(outerSpan)).toBe(true);
679+
});
680+
681+
expect(tracesSampler).toBeCalledTimes(1);
682+
expect(tracesSampler).toHaveBeenLastCalledWith({
683+
parentSampled: undefined,
684+
name: 'outer',
685+
attributes: {
686+
test1: 'aa',
687+
test2: 'aa',
688+
test3: 'bb',
689+
},
690+
inheritOrSampleWith: expect.any(Function),
691+
});
675692
});
676693

677-
expect(tracesSampler).toBeCalledTimes(1);
678-
expect(tracesSampler).toHaveBeenLastCalledWith({
679-
parentSampled: undefined,
680-
name: 'outer',
681-
attributes: {
682-
test1: 'aa',
683-
test2: 'aa',
684-
test3: 'bb',
685-
},
686-
inheritOrSampleWith: expect.any(Function),
694+
it.each([false, 0])('returns a negative sampling decision if tracesSampler returns %s', tracesSamplerResult => {
695+
tracesSampler.mockReturnValueOnce(tracesSamplerResult);
696+
697+
const options = getDefaultTestClientOptions({ tracesSampler });
698+
client = new TestClient(options);
699+
setCurrentClient(client);
700+
client.init();
701+
702+
startSpan({ name: 'outer' }, outerSpan => {
703+
expect(outerSpan).toBeDefined();
704+
expect(spanIsSampled(outerSpan)).toBe(false);
705+
});
706+
707+
expect(tracesSampler).toBeCalledTimes(1);
708+
expect(tracesSampler).toHaveBeenLastCalledWith({
709+
parentSampled: undefined,
710+
attributes: {},
711+
name: 'outer',
712+
inheritOrSampleWith: expect.any(Function),
713+
});
687714
});
688715
});
689716

0 commit comments

Comments
 (0)