Skip to content

fix(angular): Use ui category for span operations #4222

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 2 commits into from
Dec 3, 2021
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
2 changes: 1 addition & 1 deletion packages/angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ const boostrapSpan =
activeTransaction &&
activeTransaction.startChild({
description: 'platform-browser-dynamic',
op: 'angular.bootstrap',
op: 'ui.angular.bootstrap',
});

platformBrowserDynamic()
Expand Down
5 changes: 5 additions & 0 deletions packages/angular/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const ANGULAR_ROUTING_OP = 'ui.angular.routing';

export const ANGULAR_INIT_OP = 'ui.angular.init';

export const ANGULAR_OP = 'ui.angular';
9 changes: 5 additions & 4 deletions packages/angular/src/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getGlobalObject, logger, stripUrlQueryAndFragment, timestampWithMs } fr
import { Observable, Subscription } from 'rxjs';
import { filter, tap } from 'rxjs/operators';

import { ANGULAR_INIT_OP, ANGULAR_OP, ANGULAR_ROUTING_OP } from './constants';
import { runOutsideAngular } from './zone';

let instrumentationInitialized: boolean;
Expand Down Expand Up @@ -83,7 +84,7 @@ export class TraceService implements OnDestroy {
}
this._routingSpan = activeTransaction.startChild({
description: `${navigationEvent.url}`,
op: `angular.routing`,
op: ANGULAR_ROUTING_OP,
tags: {
'routing.instrumentation': '@sentry/angular',
url: strippedUrl,
Expand Down Expand Up @@ -146,7 +147,7 @@ export class TraceDirective implements OnInit, AfterViewInit {
if (activeTransaction) {
this._tracingSpan = activeTransaction.startChild({
description: `<${this.componentName}>`,
op: `angular.initialize`,
op: ANGULAR_INIT_OP,
});
}
}
Expand Down Expand Up @@ -187,7 +188,7 @@ export function TraceClassDecorator(): ClassDecorator {
if (activeTransaction) {
tracingSpan = activeTransaction.startChild({
description: `<${target.name}>`,
op: `angular.initialize`,
op: ANGULAR_INIT_OP,
});
}
if (originalOnInit) {
Expand Down Expand Up @@ -224,7 +225,7 @@ export function TraceMethodDecorator(): MethodDecorator {
activeTransaction.startChild({
description: `<${target.constructor.name}>`,
endTimestamp: now,
op: `angular.${String(propertyKey)}`,
op: `${ANGULAR_OP}.${String(propertyKey)}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing as React comments, especially since we recommend low cardinality ops, we should probably only use the same exported const ops and consume them here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but not sure how to best start considering: 1) we have 0 tests for angular (lol) and 2) this matches existing behaviour.

The propertyKey should be a set of strings though, not uuids or unique names, so I think we still fit the low cardinality aspect.

startTimestamp: now,
});
}
Expand Down