Skip to content

Commit 4d9763a

Browse files
committed
fix test
1 parent 84c7991 commit 4d9763a

File tree

13 files changed

+124
-53
lines changed

13 files changed

+124
-53
lines changed

dev-packages/browser-integration-tests/suites/public-api/startTransaction/circular_data/subject.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ const chicken = {};
22
const egg = { contains: chicken };
33
chicken.lays = egg;
44

5-
const circularObject = chicken;
6-
7-
const transaction = Sentry.startTransaction({ name: 'circular_object_test_transaction', data: circularObject });
8-
const span = transaction.startChild({ op: 'circular_object_test_span', data: circularObject });
5+
const transaction = Sentry.startTransaction({ name: 'circular_object_test_transaction', data: { chicken } });
6+
const span = transaction.startChild({ op: 'circular_object_test_span', data: { chicken } });
97

108
span.end();
119
transaction.end();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ sentryTest('should be able to handle circular data', async ({ getLocalTestPath,
1717

1818
expect(eventData.contexts).toMatchObject({
1919
trace: {
20-
data: { lays: { contains: '[Circular ~]' } },
20+
data: { chicken: { lays: { contains: '[Circular ~]' } } },
2121
},
2222
});
2323

2424
expect(eventData?.spans?.[0]).toMatchObject({
25-
data: { lays: { contains: '[Circular ~]' } },
25+
data: { chicken: { lays: { contains: '[Circular ~]' } } },
2626
op: 'circular_object_test_span',
2727
});
2828

packages/angular/src/tracing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function routingInstrumentation(
4040
name: WINDOW.location.pathname,
4141
op: 'pageload',
4242
origin: 'auto.pageload.angular',
43-
data: {
43+
attributes: {
4444
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
4545
},
4646
});
@@ -83,7 +83,7 @@ export class TraceService implements OnDestroy {
8383
name: strippedUrl,
8484
op: 'navigation',
8585
origin: 'auto.navigation.angular',
86-
data: {
86+
attributes: {
8787
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
8888
},
8989
});

packages/angular/test/tracing.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const defaultStartTransaction = (ctx: any) => {
1717
data: {
1818
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',
1919
...ctx.data,
20+
...ctx.attributes,
2021
},
2122
}),
2223
};
@@ -52,7 +53,7 @@ describe('Angular Tracing', () => {
5253
name: '/',
5354
op: 'pageload',
5455
origin: 'auto.pageload.angular',
55-
data: { [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url' },
56+
attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url' },
5657
});
5758
});
5859
});
@@ -146,7 +147,7 @@ describe('Angular Tracing', () => {
146147
name: url,
147148
op: 'pageload',
148149
origin: 'auto.pageload.angular',
149-
data: { [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url' },
150+
attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url' },
150151
});
151152

152153
expect(transaction.updateName).toHaveBeenCalledTimes(0);
@@ -337,7 +338,7 @@ describe('Angular Tracing', () => {
337338
name: url,
338339
op: 'navigation',
339340
origin: 'auto.navigation.angular',
340-
data: { [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url' },
341+
attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url' },
341342
});
342343
expect(transaction.updateName).toHaveBeenCalledWith(result);
343344
expect(transaction.setAttribute).toHaveBeenCalledWith(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');

packages/nextjs/test/config/withSentry.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as SentryCore from '@sentry/core';
2-
import { addTracingExtensions } from '@sentry/core';
2+
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, addTracingExtensions } from '@sentry/core';
33
import type { NextApiRequest, NextApiResponse } from 'next';
44

55
import type { AugmentedNextApiResponse, NextApiHandler } from '../../src/common/types';
@@ -45,8 +45,10 @@ describe('withSentry', () => {
4545
name: 'GET http://dogs.are.great',
4646
op: 'http.server',
4747
origin: 'auto.http.nextjs',
48+
attributes: {
49+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
50+
},
4851
metadata: {
49-
source: 'route',
5052
request: expect.objectContaining({ url: 'http://dogs.are.great' }),
5153
},
5254
},

packages/nextjs/test/edge/edgeWrapperUtils.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as coreSdk from '@sentry/core';
2+
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
23

34
import { withEdgeWrapping } from '../../src/common/utils/edgeWrapperUtils';
45

@@ -81,7 +82,12 @@ describe('withEdgeWrapping', () => {
8182
expect(startSpanSpy).toHaveBeenCalledTimes(1);
8283
expect(startSpanSpy).toHaveBeenCalledWith(
8384
expect.objectContaining({
84-
metadata: { request: { headers: {} }, source: 'route' },
85+
metadata: {
86+
request: { headers: {} },
87+
},
88+
attributes: {
89+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
90+
},
8591
name: 'some label',
8692
op: 'some op',
8793
origin: 'auto.function.nextjs.withEdgeWrapping',

packages/nextjs/test/edge/withSentryAPI.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as coreSdk from '@sentry/core';
2+
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
23

34
import { wrapApiHandlerWithSentry } from '../../src/edge';
45

@@ -52,7 +53,12 @@ describe('wrapApiHandlerWithSentry', () => {
5253
expect(startSpanSpy).toHaveBeenCalledTimes(1);
5354
expect(startSpanSpy).toHaveBeenCalledWith(
5455
expect.objectContaining({
55-
metadata: { request: { headers: {}, method: 'POST', url: 'https://sentry.io/' }, source: 'route' },
56+
metadata: {
57+
request: { headers: {}, method: 'POST', url: 'https://sentry.io/' },
58+
},
59+
attributes: {
60+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
61+
},
5662
name: 'POST /user/[userId]/post/[postId]',
5763
op: 'http.server',
5864
origin: 'auto.function.nextjs.withEdgeWrapping',
@@ -71,7 +77,10 @@ describe('wrapApiHandlerWithSentry', () => {
7177
expect(startSpanSpy).toHaveBeenCalledTimes(1);
7278
expect(startSpanSpy).toHaveBeenCalledWith(
7379
expect.objectContaining({
74-
metadata: { source: 'route' },
80+
metadata: {},
81+
attributes: {
82+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
83+
},
7584
name: 'handler (/user/[userId]/post/[postId])',
7685
op: 'http.server',
7786
origin: 'auto.function.nextjs.withEdgeWrapping',

packages/serverless/src/gcpfunction/cloud_events.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { handleCallbackErrors } from '@sentry/core';
1+
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, handleCallbackErrors } from '@sentry/core';
22
import { captureException, flush, getCurrentScope, startSpanManual } from '@sentry/node';
33
import { logger } from '@sentry/utils';
44

@@ -36,7 +36,7 @@ function _wrapCloudEventFunction(
3636
name: context.type || '<unknown>',
3737
op: 'function.gcp.cloud_event',
3838
origin: 'auto.function.serverless.gcp_cloud_event',
39-
metadata: { source: 'component' },
39+
attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component' },
4040
},
4141
span => {
4242
const scope = getCurrentScope();

packages/serverless/src/gcpfunction/events.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { handleCallbackErrors } from '@sentry/core';
1+
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, handleCallbackErrors } from '@sentry/core';
22
import { captureException, flush, getCurrentScope, startSpanManual } from '@sentry/node';
33
import { logger } from '@sentry/utils';
44

@@ -39,7 +39,7 @@ function _wrapEventFunction<F extends EventFunction | EventFunctionWithCallback>
3939
name: context.eventType,
4040
op: 'function.gcp.event',
4141
origin: 'auto.function.serverless.gcp_event',
42-
metadata: { source: 'component' },
42+
attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component' },
4343
},
4444
span => {
4545
const scope = getCurrentScope();

packages/serverless/test/awslambda.test.ts

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// NOTE: I have no idea how to fix this right now, and don't want to waste more time, as it builds just fine — Kamil
2+
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
23
import * as SentryNode from '@sentry/node';
34
import type { Event } from '@sentry/types';
45
import type { Callback, Handler } from 'aws-lambda';
@@ -206,7 +207,10 @@ describe('AWSLambda', () => {
206207
name: 'functionName',
207208
op: 'function.aws.lambda',
208209
origin: 'auto.function.serverless',
209-
metadata: { source: 'component' },
210+
attributes: {
211+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component',
212+
},
213+
metadata: {},
210214
};
211215

212216
expect(rv).toStrictEqual(42);
@@ -233,7 +237,10 @@ describe('AWSLambda', () => {
233237
name: 'functionName',
234238
op: 'function.aws.lambda',
235239
origin: 'auto.function.serverless',
236-
metadata: { source: 'component' },
240+
attributes: {
241+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component',
242+
},
243+
metadata: {},
237244
};
238245

239246
expect(SentryNode.startSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
@@ -274,11 +281,13 @@ describe('AWSLambda', () => {
274281
origin: 'auto.function.serverless',
275282
name: 'functionName',
276283
traceId: '12312012123120121231201212312012',
284+
attributes: {
285+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component',
286+
},
277287
metadata: {
278288
dynamicSamplingContext: {
279289
release: '2.12.1',
280290
},
281-
source: 'component',
282291
},
283292
}),
284293
expect.any(Function),
@@ -311,7 +320,10 @@ describe('AWSLambda', () => {
311320
traceId: '12312012123120121231201212312012',
312321
parentSpanId: '1121201211212012',
313322
parentSampled: false,
314-
metadata: { dynamicSamplingContext: {}, source: 'component' },
323+
attributes: {
324+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component',
325+
},
326+
metadata: { dynamicSamplingContext: {} },
315327
};
316328

317329
expect(SentryNode.startSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
@@ -338,7 +350,10 @@ describe('AWSLambda', () => {
338350
name: 'functionName',
339351
op: 'function.aws.lambda',
340352
origin: 'auto.function.serverless',
341-
metadata: { source: 'component' },
353+
attributes: {
354+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component',
355+
},
356+
metadata: {},
342357
};
343358

344359
expect(rv).toStrictEqual(42);
@@ -376,7 +391,10 @@ describe('AWSLambda', () => {
376391
name: 'functionName',
377392
op: 'function.aws.lambda',
378393
origin: 'auto.function.serverless',
379-
metadata: { source: 'component' },
394+
attributes: {
395+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component',
396+
},
397+
metadata: {},
380398
};
381399

382400
expect(SentryNode.startSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
@@ -418,7 +436,10 @@ describe('AWSLambda', () => {
418436
name: 'functionName',
419437
op: 'function.aws.lambda',
420438
origin: 'auto.function.serverless',
421-
metadata: { source: 'component' },
439+
attributes: {
440+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component',
441+
},
442+
metadata: {},
422443
};
423444

424445
expect(rv).toStrictEqual(42);
@@ -456,7 +477,10 @@ describe('AWSLambda', () => {
456477
name: 'functionName',
457478
op: 'function.aws.lambda',
458479
origin: 'auto.function.serverless',
459-
metadata: { source: 'component' },
480+
attributes: {
481+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component',
482+
},
483+
metadata: {},
460484
};
461485

462486
expect(SentryNode.startSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));

0 commit comments

Comments
 (0)