@@ -246,18 +246,38 @@ func parseSymbol(name string) symbol {
246246 }
247247}
248248
249+ // captureStack is the core stack capture implementation used by all public capture functions.
250+ // It captures a stack trace with the given skip count, depth limit, and frame processing options.
251+ func captureStack (skip int , maxDepth int , opts frameOptions ) StackTrace {
252+ return iterator (skip , maxDepth , opts ).capture ()
253+ }
254+
249255// Capture create a new stack trace from the current call stack
250256func Capture () StackTrace {
251257 return SkipAndCapture (defaultCallerSkip )
252258}
253259
254260// SkipAndCapture creates a new stack trace from the current call stack, skipping the first `skip` frames
255261func SkipAndCapture (skip int ) StackTrace {
256- return iterator (skip , defaultMaxDepth , frameOptions {
262+ return captureStack (skip , defaultMaxDepth , frameOptions {
257263 skipInternalFrames : true ,
258264 redactCustomerFrames : false ,
259265 internalPackagePrefixes : internalSymbolPrefixes ,
260- }).capture ()
266+ })
267+ }
268+
269+ // SkipAndCaptureWithInternalFrames creates a new stack trace from the current call stack without filtering internal frames.
270+ // This is useful for tracer span error stacktraces where we want to capture all frames.
271+ func SkipAndCaptureWithInternalFrames (depth int , skip int ) StackTrace {
272+ // Use default depth if not specified
273+ if depth == 0 {
274+ depth = defaultMaxDepth
275+ }
276+ return captureStack (skip , depth , frameOptions {
277+ skipInternalFrames : false ,
278+ redactCustomerFrames : false ,
279+ internalPackagePrefixes : nil ,
280+ })
261281}
262282
263283// SkipAndCaptureWithInternalFrames creates a new stack trace from the current call stack without filtering internal frames.
@@ -290,11 +310,11 @@ func CaptureRaw(skip int) RawStackTrace {
290310// This is designed for telemetry logging where we want to see internal frames for debugging
291311// but need to redact customer code for security
292312func CaptureWithRedaction (skip int ) StackTrace {
293- return iterator (skip + 1 , defaultMaxDepth , frameOptions {
313+ return captureStack (skip + 1 , defaultMaxDepth , frameOptions {
294314 skipInternalFrames : false , // Keep DD internal frames
295315 redactCustomerFrames : true , // Redact customer code
296316 internalPackagePrefixes : internalSymbolPrefixes ,
297- }). capture ()
317+ })
298318}
299319
300320// Symbolicate converts raw PCs to a full StackTrace with symbolication,
0 commit comments