MCPcopy Create free account
hub / github.com/Effect-TS/effect / addSpanStackTrace

Function addSpanStackTrace

packages/effect/src/internal/tracer.ts:120–146  ·  view source on GitHub ↗
(options: Tracer.SpanOptions | undefined)

Source from the content-addressed store, hash-verified

118
119/** @internal */
120export const addSpanStackTrace = (options: Tracer.SpanOptions | undefined): Tracer.SpanOptions => {
121 if (options?.captureStackTrace === false) {
122 return options
123 } else if (options?.captureStackTrace !== undefined && typeof options.captureStackTrace !== "boolean") {
124 return options
125 }
126 const limit = getStackTraceLimit()
127 setStackTraceLimit(3)
128 const traceError = new Error()
129 setStackTraceLimit(limit)
130 let cache: false | string = false
131 return {
132 ...options,
133 captureStackTrace: () => {
134 if (cache !== false) {
135 return cache
136 }
137 if (traceError.stack !== undefined) {
138 const stack = traceError.stack.split("\n")
139 if (stack[3] !== undefined) {
140 cache = stack[3].trim()
141 return cache
142 }
143 }
144 }
145 }
146}
147
148/** @internal */
149export const DisablePropagation = Context.Reference<Tracer.DisablePropagation>()("effect/Tracer/DisablePropagation", {

Callers

nothing calls this directly

Calls 3

splitMethod · 0.80
getStackTraceLimitFunction · 0.70
setStackTraceLimitFunction · 0.70

Tested by

no test coverage detected