MCPcopy
hub / github.com/prisma/prisma / dispatchEngineSpan

Function dispatchEngineSpan

packages/instrumentation/src/ActiveTracingHelper.ts:108–151  ·  view source on GitHub ↗
(
  tracer: Tracer,
  engineSpan: EngineSpan,
  allSpans: EngineSpan[],
  linkIds: Map<string, string>,
  ignoreSpanTypes: (string | RegExp)[],
)

Source from the content-addressed store, hash-verified

106}
107
108function dispatchEngineSpan(
109 tracer: Tracer,
110 engineSpan: EngineSpan,
111 allSpans: EngineSpan[],
112 linkIds: Map<string, string>,
113 ignoreSpanTypes: (string | RegExp)[],
114) {
115 if (shouldIgnoreSpan(engineSpan.name, ignoreSpanTypes)) return
116
117 const spanOptions = {
118 attributes: engineSpan.attributes as Attributes,
119 kind: engineSpanKindToOtelSpanKind(engineSpan.kind),
120 startTime: engineSpan.startTime,
121 } satisfies SpanOptions
122
123 tracer.startActiveSpan(engineSpan.name, spanOptions, (span) => {
124 linkIds.set(engineSpan.id, span.spanContext().spanId)
125
126 if (engineSpan.links) {
127 span.addLinks(
128 engineSpan.links.flatMap((link) => {
129 const linkedId = linkIds.get(link)
130 if (!linkedId) {
131 return []
132 }
133 return {
134 context: {
135 spanId: linkedId,
136 traceId: span.spanContext().traceId,
137 traceFlags: span.spanContext().traceFlags,
138 },
139 }
140 }),
141 )
142 }
143
144 const children = allSpans.filter((s) => s.parentId === engineSpan.id)
145 for (const child of children) {
146 dispatchEngineSpan(tracer, child, allSpans, linkIds, ignoreSpanTypes)
147 }
148
149 span.end(engineSpan.endTime)
150 })
151}
152
153function endSpan<T>(span: Span, result: T): T {
154 if (isPromiseLike(result)) {

Callers 1

dispatchEngineSpansMethod · 0.85

Calls 7

shouldIgnoreSpanFunction · 0.85
setMethod · 0.80
spanContextMethod · 0.80
addLinksMethod · 0.80
endMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected