Skip to content

feat(core): Add sdk name and version to logs #16005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025
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 @@ -30,6 +30,18 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
stringValue: 'auto.console.logging',
},
},
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
Expand All @@ -51,6 +63,18 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
stringValue: 'auto.console.logging',
},
},
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
Expand All @@ -72,6 +96,18 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
stringValue: 'auto.console.logging',
},
},
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
Expand All @@ -93,6 +129,18 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
stringValue: 'auto.console.logging',
},
},
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
Expand All @@ -114,6 +162,18 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
stringValue: 'auto.console.logging',
},
},
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
Expand All @@ -135,6 +195,18 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
stringValue: 'auto.console.logging',
},
},
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
Expand All @@ -156,6 +228,18 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
stringValue: 'auto.console.logging',
},
},
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@ sentryTest('should capture all logging methods', async ({ getLocalTestUrl, page
{
severityText: 'trace',
body: { stringValue: 'test trace' },
attributes: [],
attributes: [
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 1,
Expand All @@ -37,7 +50,20 @@ sentryTest('should capture all logging methods', async ({ getLocalTestUrl, page
{
severityText: 'debug',
body: { stringValue: 'test debug' },
attributes: [],
attributes: [
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 5,
Expand All @@ -51,7 +77,20 @@ sentryTest('should capture all logging methods', async ({ getLocalTestUrl, page
{
severityText: 'info',
body: { stringValue: 'test info' },
attributes: [],
attributes: [
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 9,
Expand All @@ -65,7 +104,20 @@ sentryTest('should capture all logging methods', async ({ getLocalTestUrl, page
{
severityText: 'warn',
body: { stringValue: 'test warn' },
attributes: [],
attributes: [
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 13,
Expand All @@ -79,7 +131,20 @@ sentryTest('should capture all logging methods', async ({ getLocalTestUrl, page
{
severityText: 'error',
body: { stringValue: 'test error' },
attributes: [],
attributes: [
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 17,
Expand All @@ -93,7 +158,20 @@ sentryTest('should capture all logging methods', async ({ getLocalTestUrl, page
{
severityText: 'fatal',
body: { stringValue: 'test fatal' },
attributes: [],
attributes: [
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
],
timeUnixNano: expect.any(String),
traceId: expect.any(String),
severityNumber: 21,
Expand All @@ -108,6 +186,18 @@ sentryTest('should capture all logging methods', async ({ getLocalTestUrl, page
severityText: 'trace',
body: { stringValue: 'test trace stringArg false 123' },
attributes: [
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
{
key: 'sentry.message.template',
value: {
Expand Down Expand Up @@ -153,6 +243,18 @@ sentryTest('should capture all logging methods', async ({ getLocalTestUrl, page
severityText: 'debug',
body: { stringValue: 'test debug stringArg false 123' },
attributes: [
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
{
key: 'sentry.message.template',
value: {
Expand Down Expand Up @@ -198,6 +300,18 @@ sentryTest('should capture all logging methods', async ({ getLocalTestUrl, page
severityText: 'info',
body: { stringValue: 'test info stringArg false 123' },
attributes: [
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
{
key: 'sentry.message.template',
value: {
Expand Down Expand Up @@ -243,6 +357,18 @@ sentryTest('should capture all logging methods', async ({ getLocalTestUrl, page
severityText: 'warn',
body: { stringValue: 'test warn stringArg false 123' },
attributes: [
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
{
key: 'sentry.message.template',
value: {
Expand Down Expand Up @@ -288,6 +414,18 @@ sentryTest('should capture all logging methods', async ({ getLocalTestUrl, page
severityText: 'error',
body: { stringValue: 'test error stringArg false 123' },
attributes: [
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
{
key: 'sentry.message.template',
value: {
Expand Down Expand Up @@ -333,6 +471,18 @@ sentryTest('should capture all logging methods', async ({ getLocalTestUrl, page
severityText: 'fatal',
body: { stringValue: 'test fatal stringArg false 123' },
attributes: [
{
key: 'sentry.sdk.name',
value: {
stringValue: 'sentry.javascript.browser',
},
},
{
key: 'sentry.sdk.version',
value: {
stringValue: expect.any(String),
},
},
{
key: 'sentry.message.template',
value: {
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/logs/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ export function _INTERNAL_captureLog(
logAttributes['sentry.environment'] = environment;
}

const { sdk } = client.getSdkMetadata() ?? {};
if (sdk) {
logAttributes['sentry.sdk.name'] = sdk.name;
logAttributes['sentry.sdk.version'] = sdk.version;
}

if (isParameterizedString(message)) {
const { __sentry_template_string__, __sentry_template_values__ = [] } = message;
logAttributes['sentry.message.template'] = __sentry_template_string__;
Expand Down
Loading
Loading