Skip to content

Commit 6272f7c

Browse files
authored
Merge pull request #8896 from getsentry/prepare-release/7.66.0
meta(changelog): Update changelog for 7.66.0
2 parents 79965a6 + cf95612 commit 6272f7c

File tree

106 files changed

+651
-313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+651
-313
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
## 7.66.0
8+
9+
- fix: Defer tracing decision to downstream SDKs when using SDK without performance (#8839)
10+
- fix(nextjs): Fix `package.json` exports (#8895)
11+
- fix(sveltekit): Ensure target file exists before applying auto instrumentation (#8881)
12+
- ref: Use consistent console instrumentation (#8879)
13+
- ref(browser): Refactor sentry breadcrumb to use hook (#8892)
14+
- ref(tracing): Add `origin` to spans (#8765)
15+
716
## 7.65.0
817

918
- build: Remove build-specific polyfills (#8809)

packages/angular/src/tracing.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export function routingInstrumentation(
3939
customStartTransaction({
4040
name: WINDOW.location.pathname,
4141
op: 'pageload',
42+
origin: 'auto.pageload.angular',
4243
metadata: { source: 'url' },
4344
});
4445
}
@@ -84,6 +85,7 @@ export class TraceService implements OnDestroy {
8485
activeTransaction = stashedStartTransaction({
8586
name: strippedUrl,
8687
op: 'navigation',
88+
origin: 'auto.navigation.angular',
8789
metadata: { source: 'url' },
8890
});
8991
}
@@ -95,6 +97,7 @@ export class TraceService implements OnDestroy {
9597
this._routingSpan = activeTransaction.startChild({
9698
description: `${navigationEvent.url}`,
9799
op: ANGULAR_ROUTING_OP,
100+
origin: 'auto.ui.angular',
98101
tags: {
99102
'routing.instrumentation': '@sentry/angular',
100103
url: strippedUrl,
@@ -192,6 +195,7 @@ export class TraceDirective implements OnInit, AfterViewInit {
192195
this._tracingSpan = activeTransaction.startChild({
193196
description: `<${this.componentName}>`,
194197
op: ANGULAR_INIT_OP,
198+
origin: 'auto.ui.angular.trace_directive',
195199
});
196200
}
197201
}
@@ -233,6 +237,7 @@ export function TraceClassDecorator(): ClassDecorator {
233237
tracingSpan = activeTransaction.startChild({
234238
description: `<${target.name}>`,
235239
op: ANGULAR_INIT_OP,
240+
origin: 'auto.ui.angular.trace_class_decorator',
236241
});
237242
}
238243
if (originalOnInit) {
@@ -270,6 +275,7 @@ export function TraceMethodDecorator(): MethodDecorator {
270275
description: `<${target.constructor.name}>`,
271276
endTimestamp: now,
272277
op: `${ANGULAR_OP}.${String(propertyKey)}`,
278+
origin: 'auto.ui.angular.trace_method_decorator',
273279
startTimestamp: now,
274280
});
275281
}

packages/angular/test/tracing.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('Angular Tracing', () => {
4848
expect(startTransaction).toHaveBeenCalledWith({
4949
name: '/',
5050
op: 'pageload',
51+
origin: 'auto.pageload.angular',
5152
metadata: { source: 'url' },
5253
});
5354
});
@@ -137,6 +138,7 @@ describe('Angular Tracing', () => {
137138
expect(customStartTransaction).toHaveBeenCalledWith({
138139
name: url,
139140
op: 'pageload',
141+
origin: 'auto.pageload.angular',
140142
metadata: { source: 'url' },
141143
});
142144

@@ -327,6 +329,7 @@ describe('Angular Tracing', () => {
327329
expect(customStartTransaction).toHaveBeenCalledWith({
328330
name: url,
329331
op: 'navigation',
332+
origin: 'auto.navigation.angular',
330333
metadata: { source: 'url' },
331334
});
332335
expect(transaction.setName).toHaveBeenCalledWith(result, 'route');
@@ -358,6 +361,7 @@ describe('Angular Tracing', () => {
358361

359362
expect(transaction.startChild).toHaveBeenCalledWith({
360363
op: 'ui.angular.init',
364+
origin: 'auto.ui.angular.trace_directive',
361365
description: '<unknown>',
362366
});
363367

@@ -384,6 +388,7 @@ describe('Angular Tracing', () => {
384388

385389
expect(transaction.startChild).toHaveBeenCalledWith({
386390
op: 'ui.angular.init',
391+
origin: 'auto.ui.angular.trace_directive',
387392
description: '<test-component>',
388393
});
389394

@@ -458,6 +463,7 @@ describe('Angular Tracing', () => {
458463
expect(transaction.startChild).toHaveBeenCalledWith({
459464
description: '<DecoratedComponent>',
460465
op: 'ui.angular.init',
466+
origin: 'auto.ui.angular.trace_class_decorator',
461467
});
462468

463469
expect(origNgOnInitMock).toHaveBeenCalledTimes(1);
@@ -511,13 +517,15 @@ describe('Angular Tracing', () => {
511517
expect(transaction.startChild.mock.calls[0][0]).toEqual({
512518
description: '<DecoratedComponent>',
513519
op: 'ui.angular.ngOnInit',
520+
origin: 'auto.ui.angular.trace_method_decorator',
514521
startTimestamp: expect.any(Number),
515522
endTimestamp: expect.any(Number),
516523
});
517524

518525
expect(transaction.startChild.mock.calls[1][0]).toEqual({
519526
description: '<DecoratedComponent>',
520527
op: 'ui.angular.ngAfterViewInit',
528+
origin: 'auto.ui.angular.trace_method_decorator',
521529
startTimestamp: expect.any(Number),
522530
endTimestamp: expect.any(Number),
523531
});

packages/browser/src/client.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import { createClientReportEnvelope, dsnToString, getSDKSource, logger } from '@
1515

1616
import { eventFromException, eventFromMessage } from './eventbuilder';
1717
import { WINDOW } from './helpers';
18-
import type { Breadcrumbs } from './integrations';
19-
import { BREADCRUMB_INTEGRATION_ID } from './integrations/breadcrumbs';
2018
import type { BrowserTransportOptions } from './transports/types';
2119
import { createUserFeedbackEnvelope } from './userfeedback';
2220

@@ -91,26 +89,6 @@ export class BrowserClient extends BaseClient<BrowserClientOptions> {
9189
return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace);
9290
}
9391

94-
/**
95-
* @inheritDoc
96-
*/
97-
public sendEvent(event: Event, hint?: EventHint): void {
98-
// We only want to add the sentry event breadcrumb when the user has the breadcrumb integration installed and
99-
// activated its `sentry` option.
100-
// We also do not want to use the `Breadcrumbs` class here directly, because we do not want it to be included in
101-
// bundles, if it is not used by the SDK.
102-
// This all sadly is a bit ugly, but we currently don't have a "pre-send" hook on the integrations so we do it this
103-
// way for now.
104-
const breadcrumbIntegration = this.getIntegrationById(BREADCRUMB_INTEGRATION_ID) as Breadcrumbs | undefined;
105-
// We check for definedness of `addSentryBreadcrumb` in case users provided their own integration with id
106-
// "Breadcrumbs" that does not have this function.
107-
if (breadcrumbIntegration && breadcrumbIntegration.addSentryBreadcrumb) {
108-
breadcrumbIntegration.addSentryBreadcrumb(event);
109-
}
110-
111-
super.sendEvent(event, hint);
112-
}
113-
11492
/**
11593
* Sends user feedback to Sentry.
11694
*/

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ interface BreadcrumbsOptions {
4141
/** maxStringLength gets capped to prevent 100 breadcrumbs exceeding 1MB event payload size */
4242
const MAX_ALLOWED_STRING_LENGTH = 1024;
4343

44-
export const BREADCRUMB_INTEGRATION_ID = 'Breadcrumbs';
45-
4644
/**
4745
* Default Breadcrumbs instrumentations
4846
* TODO: Deprecated - with v6, this will be renamed to `Instrument`
@@ -51,7 +49,7 @@ export class Breadcrumbs implements Integration {
5149
/**
5250
* @inheritDoc
5351
*/
54-
public static id: string = BREADCRUMB_INTEGRATION_ID;
52+
public static id: string = 'Breadcrumbs';
5553

5654
/**
5755
* @inheritDoc
@@ -104,28 +102,30 @@ export class Breadcrumbs implements Integration {
104102
if (this.options.history) {
105103
addInstrumentationHandler('history', _historyBreadcrumb);
106104
}
107-
}
108-
109-
/**
110-
* Adds a breadcrumb for Sentry events or transactions if this option is enabled.
111-
*/
112-
public addSentryBreadcrumb(event: SentryEvent): void {
113105
if (this.options.sentry) {
114-
getCurrentHub().addBreadcrumb(
115-
{
116-
category: `sentry.${event.type === 'transaction' ? 'transaction' : 'event'}`,
117-
event_id: event.event_id,
118-
level: event.level,
119-
message: getEventDescription(event),
120-
},
121-
{
122-
event,
123-
},
124-
);
106+
const client = getCurrentHub().getClient();
107+
client && client.on && client.on('beforeSendEvent', addSentryBreadcrumb);
125108
}
126109
}
127110
}
128111

112+
/**
113+
* Adds a breadcrumb for Sentry events or transactions if this option is enabled.
114+
*/
115+
function addSentryBreadcrumb(event: SentryEvent): void {
116+
getCurrentHub().addBreadcrumb(
117+
{
118+
category: `sentry.${event.type === 'transaction' ? 'transaction' : 'event'}`,
119+
event_id: event.event_id,
120+
level: event.level,
121+
message: getEventDescription(event),
122+
},
123+
{
124+
event,
125+
},
126+
);
127+
}
128+
129129
/**
130130
* A HOC that creaes a function that creates breadcrumbs from DOM API calls.
131131
* This is a HOC so that we get access to dom options in the closure.

packages/browser/src/profiling/hubextensions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ export function wrapTransactionWithProfiling(transaction: Transaction): Transact
174174

175175
// This is temporary - we will use the collected span data to evaluate
176176
// if deferring txn.finish until profiler resolves is a viable approach.
177-
const stopProfilerSpan = transaction.startChild({ description: 'profiler.stop', op: 'profiler' });
177+
const stopProfilerSpan = transaction.startChild({
178+
description: 'profiler.stop',
179+
op: 'profiler',
180+
origin: 'auto.profiler.browser',
181+
});
178182

179183
return profiler
180184
.stop()

packages/core/src/baseclient.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
322322
* @inheritDoc
323323
*/
324324
public sendEvent(event: Event, hint: EventHint = {}): void {
325+
this.emit('beforeSendEvent', event, hint);
326+
325327
if (this._dsn) {
326328
let env = createEventEnvelope(event, this._dsn, this._options._metadata, this._options.tunnel);
327329

@@ -381,6 +383,9 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
381383
/** @inheritdoc */
382384
public on(hook: 'beforeEnvelope', callback: (envelope: Envelope) => void): void;
383385

386+
/** @inheritdoc */
387+
public on(hook: 'beforeSendEvent', callback: (event: Event, hint?: EventHint) => void): void;
388+
384389
/** @inheritdoc */
385390
public on(
386391
hook: 'afterSendEvent',
@@ -412,6 +417,9 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
412417
/** @inheritdoc */
413418
public emit(hook: 'beforeEnvelope', envelope: Envelope): void;
414419

420+
/** @inheritdoc */
421+
public emit(hook: 'beforeSendEvent', event: Event, hint?: EventHint): void;
422+
415423
/** @inheritdoc */
416424
public emit(hook: 'afterSendEvent', event: Event, sendResponse: TransportMakeRequestResponse | void): void;
417425

packages/core/src/scope.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,5 @@ function generatePropagationContext(): PropagationContext {
636636
return {
637637
traceId: uuid4(),
638638
spanId: uuid4().substring(16),
639-
sampled: false,
640639
};
641640
}

packages/core/src/tracing/span.ts

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
Primitive,
55
Span as SpanInterface,
66
SpanContext,
7+
SpanOrigin,
78
TraceContext,
89
Transaction,
910
} from '@sentry/types';
@@ -115,30 +116,27 @@ export class Span implements SpanInterface {
115116
*/
116117
public instrumenter: Instrumenter;
117118

119+
/**
120+
* The origin of the span, giving context about what created the span.
121+
*/
122+
public origin?: SpanOrigin;
123+
118124
/**
119125
* You should never call the constructor manually, always use `Sentry.startTransaction()`
120126
* or call `startChild()` on an existing span.
121127
* @internal
122128
* @hideconstructor
123129
* @hidden
124130
*/
125-
public constructor(spanContext?: SpanContext) {
126-
this.traceId = uuid4();
127-
this.spanId = uuid4().substring(16);
128-
this.startTimestamp = timestampInSeconds();
129-
this.tags = {};
130-
this.data = {};
131-
this.instrumenter = 'sentry';
132-
133-
if (!spanContext) {
134-
return this;
135-
}
136-
if (spanContext.traceId) {
137-
this.traceId = spanContext.traceId;
138-
}
139-
if (spanContext.spanId) {
140-
this.spanId = spanContext.spanId;
141-
}
131+
public constructor(spanContext: SpanContext = {}) {
132+
this.traceId = spanContext.traceId || uuid4();
133+
this.spanId = spanContext.spanId || uuid4().substring(16);
134+
this.startTimestamp = spanContext.startTimestamp || timestampInSeconds();
135+
this.tags = spanContext.tags || {};
136+
this.data = spanContext.data || {};
137+
this.instrumenter = spanContext.instrumenter || 'sentry';
138+
this.origin = spanContext.origin || 'manual';
139+
142140
if (spanContext.parentSpanId) {
143141
this.parentSpanId = spanContext.parentSpanId;
144142
}
@@ -155,24 +153,12 @@ export class Span implements SpanInterface {
155153
if (spanContext.name) {
156154
this.description = spanContext.name;
157155
}
158-
if (spanContext.data) {
159-
this.data = spanContext.data;
160-
}
161-
if (spanContext.tags) {
162-
this.tags = spanContext.tags;
163-
}
164156
if (spanContext.status) {
165157
this.status = spanContext.status;
166158
}
167-
if (spanContext.startTimestamp) {
168-
this.startTimestamp = spanContext.startTimestamp;
169-
}
170159
if (spanContext.endTimestamp) {
171160
this.endTimestamp = spanContext.endTimestamp;
172161
}
173-
if (spanContext.instrumenter) {
174-
this.instrumenter = spanContext.instrumenter;
175-
}
176162
}
177163

178164
/**
@@ -355,6 +341,7 @@ export class Span implements SpanInterface {
355341
tags?: { [key: string]: Primitive };
356342
timestamp?: number;
357343
trace_id: string;
344+
origin?: SpanOrigin;
358345
} {
359346
return dropUndefinedKeys({
360347
data: Object.keys(this.data).length > 0 ? this.data : undefined,
@@ -367,6 +354,7 @@ export class Span implements SpanInterface {
367354
tags: Object.keys(this.tags).length > 0 ? this.tags : undefined,
368355
timestamp: this.endTimestamp,
369356
trace_id: this.traceId,
357+
origin: this.origin,
370358
});
371359
}
372360
}

packages/ember/addon/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,14 @@ export const instrumentRoutePerformance = <T extends RouteConstructor>(BaseRoute
8787
if (!currentTransaction) {
8888
return result;
8989
}
90-
currentTransaction.startChild({ op, description, startTimestamp }).finish();
90+
currentTransaction
91+
.startChild({
92+
op,
93+
description,
94+
origin: 'auto.ui.ember',
95+
startTimestamp,
96+
})
97+
.finish();
9198
return result;
9299
};
93100

0 commit comments

Comments
 (0)