MCPcopy
hub / github.com/triggerdotdev/trigger.dev / startActiveSpan

Method startActiveSpan

packages/core/src/v3/tracer.ts:54–103  ·  view source on GitHub ↗
(
    name: string,
    fn: (span: Span) => Promise<T>,
    options?: SpanOptions,
    ctx?: Context
  )

Source from the content-addressed store, hash-verified

52 }
53
54 startActiveSpan<T>(
55 name: string,
56 fn: (span: Span) => Promise<T>,
57 options?: SpanOptions,
58 ctx?: Context
59 ): Promise<T> {
60 const parentContext = ctx ?? context.active();
61
62 const attributes = options?.attributes ?? {};
63
64 return this.tracer.startActiveSpan(
65 name,
66 {
67 ...options,
68 attributes,
69 startTime: clock.preciseNow(),
70 },
71 parentContext,
72 async (span) => {
73 this.tracer
74 .startSpan(
75 name,
76 {
77 ...options,
78 attributes: {
79 ...attributes,
80 [SemanticInternalAttributes.SPAN_PARTIAL]: true,
81 [SemanticInternalAttributes.SPAN_ID]: span.spanContext().spanId,
82 },
83 },
84 parentContext
85 )
86 .end();
87
88 try {
89 return await fn(span);
90 } catch (e) {
91 if (typeof e === "string" || e instanceof Error) {
92 span.recordException(e);
93 }
94
95 span.setStatus({ code: SpanStatusCode.ERROR });
96
97 throw e;
98 } finally {
99 span.end(clock.preciseNow());
100 }
101 }
102 );
103 }
104
105 startSpan(name: string, options?: SpanOptions, ctx?: Context) {
106 const parentContext = ctx ?? context.active();

Callers 15

buildAndPushImageFunction · 0.80
compileProjectFunction · 0.80
resolveDependenciesFunction · 0.80
typecheckProjectFunction · 0.80
copyAdditionalFilesFunction · 0.80
loginFunction · 0.80
getPersonalAccessTokenFunction · 0.80
createAuthorizationCodeFunction · 0.80

Calls 2

startSpanMethod · 0.80
preciseNowMethod · 0.65

Tested by

no test coverage detected