Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix tests, adjust jsdoc
  • Loading branch information
Lms24 committed Dec 18, 2025
commit 64b584881ef640ed1bb66016a9c3e354637d573c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
'sentry.message.template': { value: 'Mixed: {} {} {} {}', type: 'string' },
'sentry.message.parameter.0': { value: 'prefix', type: 'string' },
'sentry.message.parameter.1': { value: '{"obj":true}', type: 'string' },
'sentry.message.parameter.2': { value: [4, 5, 6], type: 'integer[]' },
'sentry.message.parameter.2': { value: '[4,5,6]', type: 'string' },
'sentry.message.parameter.3': { value: 'suffix', type: 'string' },
},
},
Expand Down Expand Up @@ -236,7 +236,7 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
'sentry.message.template': { value: 'hello {} {} {}', type: 'string' },
'sentry.message.parameter.0': { value: true, type: 'boolean' },
'sentry.message.parameter.1': { value: 'null', type: 'string' },
'sentry.message.parameter.2': { value: 'undefined', type: 'string' },
'sentry.message.parameter.2': { value: '', type: 'string' },
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Sentry.logger.info('log_before_any_scope', { log_attr: 'log_attr_1' });

Sentry.getGlobalScope().setAttributes({ global_scope_attr: true });

// this attribute will not be sent for now
Sentry.getGlobalScope().setAttribute('array_attr', [1, 2, 3]);

// global scope, log attribute
Sentry.logger.info('log_after_global_scope', { log_attr: 'log_attr_2' });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ async function run(): Promise<void> {

Sentry.getGlobalScope().setAttribute('global_scope_attr', true);

// this attribute will not be sent for now
Sentry.getGlobalScope().setAttributes({ array_attr: [1, 2, 3] });

// global scope, log attribute
Sentry.logger.info('log_after_global_scope', { log_attr: 'log_attr_2' });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ const commonAttributes: SerializedLog['attributes'] = {
},
};

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

test('should capture all metric types', async () => {
test('captures logs with scope and log attributes', async () => {
const runner = createRunner(__dirname, 'scenario.ts')
.expect({
log: {
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ export function isAttributeObject(maybeObj: unknown): maybeObj is AttributeObjec
}

export function attributeValueToTypedAttributeValue(rawValue: unknown, useFallback?: true): TypedAttributeValue;

/**
* Converts an attribute value to a typed attribute value.
*
* Does not allow mixed arrays. In case of a mixed array, the value is stringified and the type is 'string'.
* All values besides the supported attribute types (see {@link AttributeTypeMap}) are stringified to a string attribute value.
* For now, we intentionally only support primitive values and attribute objects with primitive values.
* If @param useFallback is true, we stringify non-primitive values to a string attribute value. Otherwise
* we return `undefined` for unsupported values.
*
* @param value - The value of the passed attribute.
* @param useFallback - If true, unsupported values will be stringified to a string attribute value.
Expand Down