MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / TraceService

Class TraceService

packages/angular/src/tracing.ts:72–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70 */
71@Injectable({ providedIn: 'root' })
72export class TraceService implements OnDestroy {
73 public navStart$: Observable<Event> = this._router.events.pipe(
74 filter((event): event is NavigationStart => event instanceof NavigationStart),
75 tap(navigationEvent => {
76 if (!instrumentationInitialized) {
77 IS_DEBUG_BUILD &&
78 debug.error('Angular integration has tracing enabled, but Tracing integration is not configured');
79 return;
80 }
81
82 if (this._routingSpan) {
83 this._routingSpan.end();
84 this._routingSpan = null;
85 }
86
87 const client = getClient();
88 const strippedUrl = stripUrlQueryAndFragment(navigationEvent.url);
89
90 if (client) {
91 // see comment in `_isPageloadOngoing` for rationale
92 if (!this._isPageloadOngoing()) {
93 runOutsideAngular(() => {
94 startBrowserTracingNavigationSpan(client, {
95 name: strippedUrl,
96 attributes: {
97 [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.angular',
98 [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
99 },
100 });
101 });
102 } else {
103 // The first time we end up here, we set the pageload flag to false
104 // Subsequent navigations are going to get their own navigation root span
105 // even if the pageload root span is still ongoing.
106 this._pageloadOngoing = false;
107 }
108
109 this._routingSpan =
110 runOutsideAngular(() =>
111 startInactiveSpan({
112 name: `${navigationEvent.url}`,
113 op: ANGULAR_ROUTING_OP,
114 attributes: {
115 [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.angular',
116 [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
117 url: strippedUrl,
118 ...(navigationEvent.navigationTrigger && {
119 navigationTrigger: navigationEvent.navigationTrigger,
120 }),
121 },
122 }),
123 ) || null;
124
125 return;
126 }
127 }),
128 );
129

Callers

nothing calls this directly

Calls 14

_isPageloadOngoingMethod · 0.95
getClientFunction · 0.90
stripUrlQueryAndFragmentFunction · 0.90
runOutsideAngularFunction · 0.90
getRootSpanFunction · 0.85
setTransactionNameMethod · 0.80
errorMethod · 0.65
endMethod · 0.65
startInactiveSpanFunction · 0.50

Tested by

no test coverage detected