MCPcopy Create free account
hub / github.com/riverqueue/river / captureStackTraceSkipFrames

Function captureStackTraceSkipFrames

internal/jobexecutor/job_executor.go:533–549  ·  view source on GitHub ↗

captureStackTrace returns a formatted stack trace string starting after skipping the specified number of frames. The skip parameter should be adjusted so that frames you want to hide (like the ones generated by the tracing functions themselves) are excluded.

(skip int)

Source from the content-addressed store, hash-verified

531// adjusted so that frames you want to hide (like the ones generated by the
532// tracing functions themselves) are excluded.
533func captureStackTraceSkipFrames(skip int) string {
534 // Allocate room for up to 100 callers; adjust as needed.
535 pcs := make([]uintptr, 100)
536 // Skip the specified number of frames.
537 n := runtime.Callers(skip, pcs)
538 frames := runtime.CallersFrames(pcs[:n])
539
540 var stackTraceSB strings.Builder
541 for {
542 frame, more := frames.Next()
543 fmt.Fprintf(&stackTraceSB, "%s\n\t%s:%d\n", frame.Function, frame.File, frame.Line)
544 if !more {
545 break
546 }
547 }
548 return stackTraceSB.String()
549}

Callers 1

executeMethod · 0.85

Calls 1

NextMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…