Skip to content

Commit

Permalink
Merge pull request #8896 from getsentry/prepare-release/7.66.0
Browse files Browse the repository at this point in the history
meta(changelog): Update changelog for 7.66.0
  • Loading branch information
lforst authored Aug 29, 2023
2 parents 79965a6 + cf95612 commit 6272f7c
Show file tree
Hide file tree
Showing 106 changed files with 651 additions and 313 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

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

## 7.66.0

- fix: Defer tracing decision to downstream SDKs when using SDK without performance (#8839)
- fix(nextjs): Fix `package.json` exports (#8895)
- fix(sveltekit): Ensure target file exists before applying auto instrumentation (#8881)
- ref: Use consistent console instrumentation (#8879)
- ref(browser): Refactor sentry breadcrumb to use hook (#8892)
- ref(tracing): Add `origin` to spans (#8765)

## 7.65.0

- build: Remove build-specific polyfills (#8809)
Expand Down
6 changes: 6 additions & 0 deletions packages/angular/src/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function routingInstrumentation(
customStartTransaction({
name: WINDOW.location.pathname,
op: 'pageload',
origin: 'auto.pageload.angular',
metadata: { source: 'url' },
});
}
Expand Down Expand Up @@ -84,6 +85,7 @@ export class TraceService implements OnDestroy {
activeTransaction = stashedStartTransaction({
name: strippedUrl,
op: 'navigation',
origin: 'auto.navigation.angular',
metadata: { source: 'url' },
});
}
Expand All @@ -95,6 +97,7 @@ export class TraceService implements OnDestroy {
this._routingSpan = activeTransaction.startChild({
description: `${navigationEvent.url}`,
op: ANGULAR_ROUTING_OP,
origin: 'auto.ui.angular',
tags: {
'routing.instrumentation': '@sentry/angular',
url: strippedUrl,
Expand Down Expand Up @@ -192,6 +195,7 @@ export class TraceDirective implements OnInit, AfterViewInit {
this._tracingSpan = activeTransaction.startChild({
description: `<${this.componentName}>`,
op: ANGULAR_INIT_OP,
origin: 'auto.ui.angular.trace_directive',
});
}
}
Expand Down Expand Up @@ -233,6 +237,7 @@ export function TraceClassDecorator(): ClassDecorator {
tracingSpan = activeTransaction.startChild({
description: `<${target.name}>`,
op: ANGULAR_INIT_OP,
origin: 'auto.ui.angular.trace_class_decorator',
});
}
if (originalOnInit) {
Expand Down Expand Up @@ -270,6 +275,7 @@ export function TraceMethodDecorator(): MethodDecorator {
description: `<${target.constructor.name}>`,
endTimestamp: now,
op: `${ANGULAR_OP}.${String(propertyKey)}`,
origin: 'auto.ui.angular.trace_method_decorator',
startTimestamp: now,
});
}
Expand Down
8 changes: 8 additions & 0 deletions packages/angular/test/tracing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('Angular Tracing', () => {
expect(startTransaction).toHaveBeenCalledWith({
name: '/',
op: 'pageload',
origin: 'auto.pageload.angular',
metadata: { source: 'url' },
});
});
Expand Down Expand Up @@ -137,6 +138,7 @@ describe('Angular Tracing', () => {
expect(customStartTransaction).toHaveBeenCalledWith({
name: url,
op: 'pageload',
origin: 'auto.pageload.angular',
metadata: { source: 'url' },
});

Expand Down Expand Up @@ -327,6 +329,7 @@ describe('Angular Tracing', () => {
expect(customStartTransaction).toHaveBeenCalledWith({
name: url,
op: 'navigation',
origin: 'auto.navigation.angular',
metadata: { source: 'url' },
});
expect(transaction.setName).toHaveBeenCalledWith(result, 'route');
Expand Down Expand Up @@ -358,6 +361,7 @@ describe('Angular Tracing', () => {

expect(transaction.startChild).toHaveBeenCalledWith({
op: 'ui.angular.init',
origin: 'auto.ui.angular.trace_directive',
description: '<unknown>',
});

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

expect(transaction.startChild).toHaveBeenCalledWith({
op: 'ui.angular.init',
origin: 'auto.ui.angular.trace_directive',
description: '<test-component>',
});

Expand Down Expand Up @@ -458,6 +463,7 @@ describe('Angular Tracing', () => {
expect(transaction.startChild).toHaveBeenCalledWith({
description: '<DecoratedComponent>',
op: 'ui.angular.init',
origin: 'auto.ui.angular.trace_class_decorator',
});

expect(origNgOnInitMock).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -511,13 +517,15 @@ describe('Angular Tracing', () => {
expect(transaction.startChild.mock.calls[0][0]).toEqual({
description: '<DecoratedComponent>',
op: 'ui.angular.ngOnInit',
origin: 'auto.ui.angular.trace_method_decorator',
startTimestamp: expect.any(Number),
endTimestamp: expect.any(Number),
});

expect(transaction.startChild.mock.calls[1][0]).toEqual({
description: '<DecoratedComponent>',
op: 'ui.angular.ngAfterViewInit',
origin: 'auto.ui.angular.trace_method_decorator',
startTimestamp: expect.any(Number),
endTimestamp: expect.any(Number),
});
Expand Down
22 changes: 0 additions & 22 deletions packages/browser/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { createClientReportEnvelope, dsnToString, getSDKSource, logger } from '@

import { eventFromException, eventFromMessage } from './eventbuilder';
import { WINDOW } from './helpers';
import type { Breadcrumbs } from './integrations';
import { BREADCRUMB_INTEGRATION_ID } from './integrations/breadcrumbs';
import type { BrowserTransportOptions } from './transports/types';
import { createUserFeedbackEnvelope } from './userfeedback';

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

/**
* @inheritDoc
*/
public sendEvent(event: Event, hint?: EventHint): void {
// We only want to add the sentry event breadcrumb when the user has the breadcrumb integration installed and
// activated its `sentry` option.
// We also do not want to use the `Breadcrumbs` class here directly, because we do not want it to be included in
// bundles, if it is not used by the SDK.
// 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
// way for now.
const breadcrumbIntegration = this.getIntegrationById(BREADCRUMB_INTEGRATION_ID) as Breadcrumbs | undefined;
// We check for definedness of `addSentryBreadcrumb` in case users provided their own integration with id
// "Breadcrumbs" that does not have this function.
if (breadcrumbIntegration && breadcrumbIntegration.addSentryBreadcrumb) {
breadcrumbIntegration.addSentryBreadcrumb(event);
}

super.sendEvent(event, hint);
}

/**
* Sends user feedback to Sentry.
*/
Expand Down
40 changes: 20 additions & 20 deletions packages/browser/src/integrations/breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ interface BreadcrumbsOptions {
/** maxStringLength gets capped to prevent 100 breadcrumbs exceeding 1MB event payload size */
const MAX_ALLOWED_STRING_LENGTH = 1024;

export const BREADCRUMB_INTEGRATION_ID = 'Breadcrumbs';

/**
* Default Breadcrumbs instrumentations
* TODO: Deprecated - with v6, this will be renamed to `Instrument`
Expand All @@ -51,7 +49,7 @@ export class Breadcrumbs implements Integration {
/**
* @inheritDoc
*/
public static id: string = BREADCRUMB_INTEGRATION_ID;
public static id: string = 'Breadcrumbs';

/**
* @inheritDoc
Expand Down Expand Up @@ -104,28 +102,30 @@ export class Breadcrumbs implements Integration {
if (this.options.history) {
addInstrumentationHandler('history', _historyBreadcrumb);
}
}

/**
* Adds a breadcrumb for Sentry events or transactions if this option is enabled.
*/
public addSentryBreadcrumb(event: SentryEvent): void {
if (this.options.sentry) {
getCurrentHub().addBreadcrumb(
{
category: `sentry.${event.type === 'transaction' ? 'transaction' : 'event'}`,
event_id: event.event_id,
level: event.level,
message: getEventDescription(event),
},
{
event,
},
);
const client = getCurrentHub().getClient();
client && client.on && client.on('beforeSendEvent', addSentryBreadcrumb);
}
}
}

/**
* Adds a breadcrumb for Sentry events or transactions if this option is enabled.
*/
function addSentryBreadcrumb(event: SentryEvent): void {
getCurrentHub().addBreadcrumb(
{
category: `sentry.${event.type === 'transaction' ? 'transaction' : 'event'}`,
event_id: event.event_id,
level: event.level,
message: getEventDescription(event),
},
{
event,
},
);
}

/**
* A HOC that creaes a function that creates breadcrumbs from DOM API calls.
* This is a HOC so that we get access to dom options in the closure.
Expand Down
6 changes: 5 additions & 1 deletion packages/browser/src/profiling/hubextensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ export function wrapTransactionWithProfiling(transaction: Transaction): Transact

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

return profiler
.stop()
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/baseclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
* @inheritDoc
*/
public sendEvent(event: Event, hint: EventHint = {}): void {
this.emit('beforeSendEvent', event, hint);

if (this._dsn) {
let env = createEventEnvelope(event, this._dsn, this._options._metadata, this._options.tunnel);

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

/** @inheritdoc */
public on(hook: 'beforeSendEvent', callback: (event: Event, hint?: EventHint) => void): void;

/** @inheritdoc */
public on(
hook: 'afterSendEvent',
Expand Down Expand Up @@ -412,6 +417,9 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
/** @inheritdoc */
public emit(hook: 'beforeEnvelope', envelope: Envelope): void;

/** @inheritdoc */
public emit(hook: 'beforeSendEvent', event: Event, hint?: EventHint): void;

/** @inheritdoc */
public emit(hook: 'afterSendEvent', event: Event, sendResponse: TransportMakeRequestResponse | void): void;

Expand Down
1 change: 0 additions & 1 deletion packages/core/src/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,5 @@ function generatePropagationContext(): PropagationContext {
return {
traceId: uuid4(),
spanId: uuid4().substring(16),
sampled: false,
};
}
46 changes: 17 additions & 29 deletions packages/core/src/tracing/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
Primitive,
Span as SpanInterface,
SpanContext,
SpanOrigin,
TraceContext,
Transaction,
} from '@sentry/types';
Expand Down Expand Up @@ -115,30 +116,27 @@ export class Span implements SpanInterface {
*/
public instrumenter: Instrumenter;

/**
* The origin of the span, giving context about what created the span.
*/
public origin?: SpanOrigin;

/**
* You should never call the constructor manually, always use `Sentry.startTransaction()`
* or call `startChild()` on an existing span.
* @internal
* @hideconstructor
* @hidden
*/
public constructor(spanContext?: SpanContext) {
this.traceId = uuid4();
this.spanId = uuid4().substring(16);
this.startTimestamp = timestampInSeconds();
this.tags = {};
this.data = {};
this.instrumenter = 'sentry';

if (!spanContext) {
return this;
}
if (spanContext.traceId) {
this.traceId = spanContext.traceId;
}
if (spanContext.spanId) {
this.spanId = spanContext.spanId;
}
public constructor(spanContext: SpanContext = {}) {
this.traceId = spanContext.traceId || uuid4();
this.spanId = spanContext.spanId || uuid4().substring(16);
this.startTimestamp = spanContext.startTimestamp || timestampInSeconds();
this.tags = spanContext.tags || {};
this.data = spanContext.data || {};
this.instrumenter = spanContext.instrumenter || 'sentry';
this.origin = spanContext.origin || 'manual';

if (spanContext.parentSpanId) {
this.parentSpanId = spanContext.parentSpanId;
}
Expand All @@ -155,24 +153,12 @@ export class Span implements SpanInterface {
if (spanContext.name) {
this.description = spanContext.name;
}
if (spanContext.data) {
this.data = spanContext.data;
}
if (spanContext.tags) {
this.tags = spanContext.tags;
}
if (spanContext.status) {
this.status = spanContext.status;
}
if (spanContext.startTimestamp) {
this.startTimestamp = spanContext.startTimestamp;
}
if (spanContext.endTimestamp) {
this.endTimestamp = spanContext.endTimestamp;
}
if (spanContext.instrumenter) {
this.instrumenter = spanContext.instrumenter;
}
}

/**
Expand Down Expand Up @@ -355,6 +341,7 @@ export class Span implements SpanInterface {
tags?: { [key: string]: Primitive };
timestamp?: number;
trace_id: string;
origin?: SpanOrigin;
} {
return dropUndefinedKeys({
data: Object.keys(this.data).length > 0 ? this.data : undefined,
Expand All @@ -367,6 +354,7 @@ export class Span implements SpanInterface {
tags: Object.keys(this.tags).length > 0 ? this.tags : undefined,
timestamp: this.endTimestamp,
trace_id: this.traceId,
origin: this.origin,
});
}
}
Expand Down
9 changes: 8 additions & 1 deletion packages/ember/addon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ export const instrumentRoutePerformance = <T extends RouteConstructor>(BaseRoute
if (!currentTransaction) {
return result;
}
currentTransaction.startChild({ op, description, startTimestamp }).finish();
currentTransaction
.startChild({
op,
description,
origin: 'auto.ui.ember',
startTimestamp,
})
.finish();
return result;
};

Expand Down
Loading

0 comments on commit 6272f7c

Please sign in to comment.