Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ window.Sentry = Sentry;
Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
// purposefully testing against the experimental flag here
_experiments: {
enableLogs: true,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Sentry.init({
traceLifecycle: 'stream',
tracesSampleRate: 1,
dataCollection: { userInfo: true },
enableLogs: true,
});

const port = 3030;
Expand Down
1 change: 0 additions & 1 deletion dev-packages/e2e-tests/test-applications/deno/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Sentry.init({
tunnel: 'http://localhost:3031/',
tracesSampleRate: 1,
dataCollection: { userInfo: true },
enableLogs: true,
});

const port = 3030;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const AppLayer = Layer.mergeAll(
release: 'e2e-test',
environment: 'qa',
tunnel: 'http://localhost:3031',
enableLogs: true,
}),
Layer.setTracer(Sentry.SentryEffectTracer),
Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const SentryLive = Layer.mergeAll(
debug: !!process.env.DEBUG,
tunnel: 'http://localhost:3031/',
tracesSampleRate: 1,
enableLogs: true,
}),
Layer.setTracer(Sentry.SentryEffectTracer),
Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const AppLayer = Layer.mergeAll(
release: 'e2e-test',
environment: 'qa',
tunnel: 'http://localhost:3031',
enableLogs: true,
}),
Logger.layer([Sentry.SentryEffectLogger]),
Layer.succeed(Tracer.Tracer, Sentry.SentryEffectTracer),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const SentryLive = Layer.mergeAll(
debug: !!process.env.DEBUG,
tunnel: 'http://localhost:3031/',
tracesSampleRate: 1,
enableLogs: true,
}),
Logger.layer([Sentry.SentryEffectLogger]),
Layer.succeed(Tracer.Tracer, Sentry.SentryEffectTracer),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Sentry.init({
debug: !!process.env.DEBUG,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
enableLogs: true,
traceLifecycle: 'stream',
integrations: [
Sentry.spanStreamingIntegration(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Sentry.init({
debug: !!process.env.DEBUG,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
enableLogs: true,
integrations: [Sentry.nodeRuntimeMetricsIntegration({ collectionIntervalMs: 1_000 })],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Sentry.init({
debug: !!process.env.DEBUG,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
enableLogs: true,
integrations: [
Sentry.nativeNodeFetchIntegration({
headersToSpanAttributes: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Sentry.init({
// Tracing is completely disabled
// Custom OTEL setup
skipOpenTelemetrySetup: true,
enableLogs: true,
});

// Create and configure NodeTracerProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ Sentry.init({
debug: !!process.env.DEBUG,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
enableLogs: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0.0',
environment: 'test',
enableLogs: true,
transport: loggingTransport,
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ Sentry.init({
dsn: process.env.SENTRY_DSN,
release: '1.0',
tracesSampleRate: 1.0,
enableLogs: true,
integrations: [Sentry.pinoIntegration({ autoInstrument: false })],
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ Sentry.init({
dsn: process.env.SENTRY_DSN,
release: '1.0',
tracesSampleRate: 1.0,
enableLogs: true,
integrations: [Sentry.pinoIntegration({ error: { levels: ['error', 'fatal'] } })],
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0.0',
environment: 'test',
enableLogs: true,
transport: loggingTransport,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

const client = new Sentry.NodeClient({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
enableLogs: false,
transport: loggingTransport,
stackParser: Sentry.defaultStackParser,
integrations: [],
});

const scope = new Sentry.Scope();
scope.setClient(client);
client.init();

async function run(): Promise<void> {
Sentry.logger.info('this log should not be captured', {}, { scope });

// Flush the log buffer before the sentinel is captured. If the disable path is
// broken, the leaked log envelope is sent here and arrives before the error,
// failing the ordered `event` expectation. If logs are correctly disabled,
// the buffer is empty and only the sentinel error is delivered.
await client.flush();

scope.captureException(new Error('sentinel_error'));

await client.flush();
}

// eslint-disable-next-line @typescript-eslint/no-floating-promises
void run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { afterAll, describe, test } from 'vitest';
import { cleanupChildProcesses, createRunner } from '../../../utils/runner';

describe('logs disabled', () => {
afterAll(() => {
cleanupChildProcesses();
});

// With `enableLogs: false` the log is dropped at capture time, so it never reaches
// the transport. The sentinel error is the only envelope we expect — if a log
// envelope were emitted, it would arrive before the error and fail the assertion.
test('does not capture logs when enableLogs is disabled', async () => {
const runner = createRunner(__dirname, 'subject.ts')
.expect({
event: {
exception: {
values: [
{
type: 'Error',
value: 'sentinel_error',
},
],
},
},
})
.start();

await runner.completed();
});
Comment thread
cursor[bot] marked this conversation as resolved.
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const client = new Sentry.NodeClient({
transport: loggingTransport,
stackParser: Sentry.defaultStackParser,
integrations: [],
enableLogs: true,
dataCollection: { userInfo: true },
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0.0',
environment: 'test',
enableLogs: true,
transport: loggingTransport,
debug: true,
});
4 changes: 2 additions & 2 deletions packages/core/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
}

// Backfill enableLogs option from _experiments.enableLogs
// TODO(v11): Remove or change default value
// todo(v11): Remove the experimental flag
// eslint-disable-next-line typescript/no-deprecated
this._options.enableLogs = this._options.enableLogs ?? this._options._experiments?.enableLogs;
this._options.enableLogs = this._options.enableLogs ?? this._options._experiments?.enableLogs ?? true;

// Setup log flushing with weight and timeout tracking
if (this._options.enableLogs) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/integrations/consola.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export interface ConsolaLogObject {
const DEFAULT_CAPTURED_LEVELS: Array<LogSeverityLevel> = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];

/**
* Creates a new Sentry reporter for Consola that forwards logs to Sentry. Requires the `enableLogs` option to be enabled.
* Creates a new Sentry reporter for Consola that forwards logs to Sentry.
*
* **Note: This integration supports Consola v3.x only.** The reporter interface and log object structure
* may differ in other versions of Consola.
Expand All @@ -205,7 +205,7 @@ const DEFAULT_CAPTURED_LEVELS: Array<LogSeverityLevel> = ['trace', 'debug', 'inf
* import { consola } from 'consola';
*
* Sentry.init({
* enableLogs: true,
* dsn: '__DSN__',
* });
*
* const sentryReporter = Sentry.createConsolaReporter({
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/logs/console-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {
}) satisfies IntegrationFn;

/**
* Captures calls to the `console` API as logs in Sentry. Requires the `enableLogs` option to be enabled.
* Captures calls to the `console` API as logs in Sentry.
*
* @experimental This feature is experimental and may be changed or removed in future versions.
*
Expand All @@ -109,7 +109,6 @@ const _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {
* import * as Sentry from '@sentry/browser';
*
* Sentry.init({
* enableLogs: true,
* integrations: [Sentry.consoleLoggingIntegration({ levels: ['error', 'warn'] })],
* });
* ```
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/logs/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function _INTERNAL_captureLog(
return;
}

const { release, environment, enableLogs = false, beforeSendLog } = client.getOptions();
const { release, environment, enableLogs = true, beforeSendLog } = client.getOptions();
if (!enableLogs) {
DEBUG_BUILD && debug.warn('logging option not enabled, log will not be captured.');
return;
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/logs/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface CaptureLogMetadata {
}

/**
* @summary Capture a log with the `trace` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `trace` level.
*
* @param message - The message to log.
* @param attributes - Arbitrary structured data that stores information about the log - e.g., { userId: 100, route: '/dashboard' }.
Expand Down Expand Up @@ -64,7 +64,7 @@ export function trace(
}

/**
* @summary Capture a log with the `debug` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `debug` level.
*
* @param message - The message to log.
* @param attributes - Arbitrary structured data that stores information about the log - e.g., { component: 'Header', state: 'loading' }.
Expand Down Expand Up @@ -99,7 +99,7 @@ export function debug(
}

/**
* @summary Capture a log with the `info` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `info` level.
*
* @param message - The message to log.
* @param attributes - Arbitrary structured data that stores information about the log - e.g., { feature: 'checkout', status: 'completed' }.
Expand Down Expand Up @@ -134,7 +134,7 @@ export function info(
}

/**
* @summary Capture a log with the `warn` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `warn` level.
*
* @param message - The message to log.
* @param attributes - Arbitrary structured data that stores information about the log - e.g., { browser: 'Chrome', version: '91.0' }.
Expand Down Expand Up @@ -170,7 +170,7 @@ export function warn(
}

/**
* @summary Capture a log with the `error` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `error` level.
*
* @param message - The message to log.
* @param attributes - Arbitrary structured data that stores information about the log - e.g., { error: 'NetworkError', url: '/api/data' }.
Expand Down Expand Up @@ -207,7 +207,7 @@ export function error(
}

/**
* @summary Capture a log with the `fatal` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `fatal` level.
*
* @param message - The message to log.
* @param attributes - Arbitrary structured data that stores information about the log - e.g., { appState: 'corrupted', sessionId: 'abc-123' }.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
/**
* If logs support should be enabled.
*
* @default false
* @default true
*/
enableLogs?: boolean;

Expand Down
Loading
Loading