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 @@ -23,7 +23,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
{
severityText: 'trace',
body: { stringValue: 'console.trace 123 false' },
attributes: [],
attributes: [
{
key: 'sentry.origin',
value: {
stringValue: 'auto.console.logging',
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 1,
Expand All @@ -37,7 +44,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
{
severityText: 'debug',
body: { stringValue: 'console.debug 123 false' },
attributes: [],
attributes: [
{
key: 'sentry.origin',
value: {
stringValue: 'auto.console.logging',
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 5,
Expand All @@ -51,7 +65,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
{
severityText: 'info',
body: { stringValue: 'console.log 123 false' },
attributes: [],
attributes: [
{
key: 'sentry.origin',
value: {
stringValue: 'auto.console.logging',
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 10,
Expand All @@ -65,7 +86,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
{
severityText: 'info',
body: { stringValue: 'console.info 123 false' },
attributes: [],
attributes: [
{
key: 'sentry.origin',
value: {
stringValue: 'auto.console.logging',
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 9,
Expand All @@ -79,7 +107,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
{
severityText: 'warn',
body: { stringValue: 'console.warn 123 false' },
attributes: [],
attributes: [
{
key: 'sentry.origin',
value: {
stringValue: 'auto.console.logging',
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 13,
Expand All @@ -93,7 +128,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
{
severityText: 'error',
body: { stringValue: 'console.error 123 false' },
attributes: [],
attributes: [
{
key: 'sentry.origin',
value: {
stringValue: 'auto.console.logging',
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 17,
Expand All @@ -107,7 +149,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
{
severityText: 'error',
body: { stringValue: 'Assertion failed: console.assert 123 false' },
attributes: [],
attributes: [
{
key: 'sentry.origin',
value: {
stringValue: 'auto.console.logging',
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 17,
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/logs/console-integration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getClient } from '../currentScopes';
import { DEBUG_BUILD } from '../debug-build';
import { defineIntegration } from '../integration';
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';
import type { ConsoleLevel, IntegrationFn } from '../types-hoist';
import { CONSOLE_LEVELS, GLOBAL_OBJ, addConsoleInstrumentationHandler, logger, safeJoin } from '../utils-hoist';
import { _INTERNAL_captureLog } from './exports';
Expand All @@ -17,6 +18,10 @@ type GlobalObjectWithUtil = typeof GLOBAL_OBJ & {

const INTEGRATION_NAME = 'ConsoleLogs';

const DEFAULT_ATTRIBUTES = {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.console.logging',
};

const _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {}) => {
const levels = options.levels || CONSOLE_LEVELS;

Expand All @@ -38,7 +43,7 @@ const _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {
const followingArgs = args.slice(1);
const message =
followingArgs.length > 0 ? `Assertion failed: ${formatConsoleArgs(followingArgs)}` : 'Assertion failed';
_INTERNAL_captureLog({ level: 'error', message });
_INTERNAL_captureLog({ level: 'error', message, attributes: DEFAULT_ATTRIBUTES });
}
return;
}
Expand All @@ -48,6 +53,7 @@ const _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {
level: isLevelLog ? 'info' : level,
message: formatConsoleArgs(args),
severityNumber: isLevelLog ? 10 : undefined,
attributes: DEFAULT_ATTRIBUTES,
});
});
},
Expand Down
Loading