( options: A | undefined )
| 7 | |
| 8 | /** @internal */ |
| 9 | export const addSpanStackTrace = <A extends Tracer.TraceOptions>( |
| 10 | options: A | undefined |
| 11 | ): A => { |
| 12 | if (options?.captureStackTrace === false) { |
| 13 | return options |
| 14 | } else if (options?.captureStackTrace !== undefined && typeof options.captureStackTrace !== "boolean") { |
| 15 | return options |
| 16 | } |
| 17 | const limit = getStackTraceLimit() |
| 18 | setStackTraceLimit(3) |
| 19 | const traceError = new Error() |
| 20 | setStackTraceLimit(limit) |
| 21 | return { |
| 22 | ...options, |
| 23 | captureStackTrace: spanCleaner(() => traceError.stack) |
| 24 | } as A |
| 25 | } |
| 26 | |
| 27 | /** @internal */ |
| 28 | export const makeStackCleaner = (line: number) => (stack: () => string | undefined): () => string | undefined => { |
no test coverage detected
searching dependent graphs…