Skip to content

Commit dd2b279

Browse files
authored
1 parent 6a8a2c3 commit dd2b279

File tree

2 files changed

+63
-8
lines changed

2 files changed

+63
-8
lines changed

dev-packages/browser-integration-tests/suites/public-api/logger/integration/test.ts

+56-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
2323
{
2424
severityText: 'trace',
2525
body: { stringValue: 'console.trace 123 false' },
26-
attributes: [],
26+
attributes: [
27+
{
28+
key: 'sentry.origin',
29+
value: {
30+
stringValue: 'auto.console.logging',
31+
},
32+
},
33+
],
2734
timeUnixNano: expect.any(String),
2835
traceId: expect.any(String),
2936
severityNumber: 1,
@@ -37,7 +44,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
3744
{
3845
severityText: 'debug',
3946
body: { stringValue: 'console.debug 123 false' },
40-
attributes: [],
47+
attributes: [
48+
{
49+
key: 'sentry.origin',
50+
value: {
51+
stringValue: 'auto.console.logging',
52+
},
53+
},
54+
],
4155
timeUnixNano: expect.any(String),
4256
traceId: expect.any(String),
4357
severityNumber: 5,
@@ -51,7 +65,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
5165
{
5266
severityText: 'info',
5367
body: { stringValue: 'console.log 123 false' },
54-
attributes: [],
68+
attributes: [
69+
{
70+
key: 'sentry.origin',
71+
value: {
72+
stringValue: 'auto.console.logging',
73+
},
74+
},
75+
],
5576
timeUnixNano: expect.any(String),
5677
traceId: expect.any(String),
5778
severityNumber: 10,
@@ -65,7 +86,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
6586
{
6687
severityText: 'info',
6788
body: { stringValue: 'console.info 123 false' },
68-
attributes: [],
89+
attributes: [
90+
{
91+
key: 'sentry.origin',
92+
value: {
93+
stringValue: 'auto.console.logging',
94+
},
95+
},
96+
],
6997
timeUnixNano: expect.any(String),
7098
traceId: expect.any(String),
7199
severityNumber: 9,
@@ -79,7 +107,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
79107
{
80108
severityText: 'warn',
81109
body: { stringValue: 'console.warn 123 false' },
82-
attributes: [],
110+
attributes: [
111+
{
112+
key: 'sentry.origin',
113+
value: {
114+
stringValue: 'auto.console.logging',
115+
},
116+
},
117+
],
83118
timeUnixNano: expect.any(String),
84119
traceId: expect.any(String),
85120
severityNumber: 13,
@@ -93,7 +128,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
93128
{
94129
severityText: 'error',
95130
body: { stringValue: 'console.error 123 false' },
96-
attributes: [],
131+
attributes: [
132+
{
133+
key: 'sentry.origin',
134+
value: {
135+
stringValue: 'auto.console.logging',
136+
},
137+
},
138+
],
97139
timeUnixNano: expect.any(String),
98140
traceId: expect.any(String),
99141
severityNumber: 17,
@@ -107,7 +149,14 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
107149
{
108150
severityText: 'error',
109151
body: { stringValue: 'Assertion failed: console.assert 123 false' },
110-
attributes: [],
152+
attributes: [
153+
{
154+
key: 'sentry.origin',
155+
value: {
156+
stringValue: 'auto.console.logging',
157+
},
158+
},
159+
],
111160
timeUnixNano: expect.any(String),
112161
traceId: expect.any(String),
113162
severityNumber: 17,

packages/core/src/logs/console-integration.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { getClient } from '../currentScopes';
22
import { DEBUG_BUILD } from '../debug-build';
33
import { defineIntegration } from '../integration';
4+
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';
45
import type { ConsoleLevel, IntegrationFn } from '../types-hoist';
56
import { CONSOLE_LEVELS, GLOBAL_OBJ, addConsoleInstrumentationHandler, logger, safeJoin } from '../utils-hoist';
67
import { _INTERNAL_captureLog } from './exports';
@@ -17,6 +18,10 @@ type GlobalObjectWithUtil = typeof GLOBAL_OBJ & {
1718

1819
const INTEGRATION_NAME = 'ConsoleLogs';
1920

21+
const DEFAULT_ATTRIBUTES = {
22+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.console.logging',
23+
};
24+
2025
const _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {}) => {
2126
const levels = options.levels || CONSOLE_LEVELS;
2227

@@ -38,7 +43,7 @@ const _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {
3843
const followingArgs = args.slice(1);
3944
const message =
4045
followingArgs.length > 0 ? `Assertion failed: ${formatConsoleArgs(followingArgs)}` : 'Assertion failed';
41-
_INTERNAL_captureLog({ level: 'error', message });
46+
_INTERNAL_captureLog({ level: 'error', message, attributes: DEFAULT_ATTRIBUTES });
4247
}
4348
return;
4449
}
@@ -48,6 +53,7 @@ const _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {
4853
level: isLevelLog ? 'info' : level,
4954
message: formatConsoleArgs(args),
5055
severityNumber: isLevelLog ? 10 : undefined,
56+
attributes: DEFAULT_ATTRIBUTES,
5157
});
5258
});
5359
},

0 commit comments

Comments
 (0)