MCPcopy
hub / github.com/electron/forge / _autoTrace

Function _autoTrace

packages/utils/tracer/src/index.ts:32–65  ·  view source on GitHub ↗
(
  tracer: Tracer | null,
  autoTraceId: string,
  opts: TraceOptions,
  fn: (childTrace: typeof autoTrace, ...args: Args) => R,
)

Source from the content-addressed store, hash-verified

30};
31
32function _autoTrace<Args extends any[], R = void>(
33 tracer: Tracer | null,
34 autoTraceId: string,
35 opts: TraceOptions,
36 fn: (childTrace: typeof autoTrace, ...args: Args) => R,
37): (...args: Args) => R {
38 return (async (...args: Args) => {
39 const traceArgs: Fields = {
40 id: autoTraceId,
41 name: opts.name,
42 cat: [opts.category],
43 args: opts.extraDetails,
44 tid: autoTraceId.split('-')[autoTraceId.split('-').length - 1],
45 };
46 tracer?.begin(traceArgs);
47 const childTrace = (opts: TraceOptions, fn: any) => {
48 return _autoTrace(
49 tracer?.child(traceArgs) ?? null,
50 opts.newRoot ? nextRoot() : autoTraceId,
51 opts,
52 fn,
53 );
54 };
55 (childTrace as any)._autoEnd = true;
56 (childTrace as any)._end = () => tracer?.end(traceArgs);
57 try {
58 return await Promise.resolve(fn(childTrace as any, ...args));
59 } finally {
60 if ((childTrace as any)._autoEnd) {
61 (childTrace as any)._end();
62 }
63 }
64 }) as any;
65}
66
67export function delayTraceTillSignal<O extends object, K extends keyof O>(
68 trace: typeof autoTrace,

Callers 2

childTraceFunction · 0.85
autoTraceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected