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

Function TraceMethod

packages/angular/src/tracing.ts:360–385  ·  view source on GitHub ↗
(options?: TraceMethodOptions)

Source from the content-addressed store, hash-verified

358 * Decorator function that can be used to capture a single lifecycle methods of the component.
359 */
360export function TraceMethod(options?: TraceMethodOptions): MethodDecorator {
361 return (_target: unknown, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
362 const originalMethod = descriptor.value;
363 descriptor.value = function (...args: unknown[]): ReturnType<typeof originalMethod> {
364 const now = timestampInSeconds();
365
366 runOutsideAngular(() => {
367 startInactiveSpan({
368 onlyIfParent: true,
369 name: `<${options?.name ? options.name : 'unnamed'}>`,
370 op: `${ANGULAR_OP}.${String(propertyKey)}`,
371 startTime: now,
372 attributes: {
373 [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.angular.trace_method_decorator',
374 },
375 }).end(now);
376 });
377
378 if (originalMethod) {
379 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
380 return originalMethod.apply(this, args);
381 }
382 };
383 return descriptor;
384 };
385}
386
387/**
388 * Takes the parameterized route from a given ActivatedRouteSnapshot and concatenates the snapshot's

Calls 5

timestampInSecondsFunction · 0.90
runOutsideAngularFunction · 0.90
endMethod · 0.65
startInactiveSpanFunction · 0.50
applyMethod · 0.45

Tested by

no test coverage detected