MCPcopy Index your code
hub / github.com/jetify-com/devbox / newSentryStack

Function newSentryStack

internal/telemetry/sentry.go:114–149  ·  view source on GitHub ↗
(frames []runtime.Frame, binPkg, modPath string)

Source from the content-addressed store, hash-verified

112}
113
114func newSentryStack(frames []runtime.Frame, binPkg, modPath string) *sentry.Stacktrace {
115 stack := &sentry.Stacktrace{
116 Frames: make([]sentry.Frame, len(frames)),
117 }
118 for i, frame := range frames {
119 pkgName, funcName := splitPkgFunc(frame.Function)
120
121 // The entrypoint has the full function name "main.main". Replace the
122 // package name with its full package path to make it easier to find.
123 if pkgName == "main" {
124 pkgName = binPkg
125 }
126
127 // The file path will be absolute unless the binary was built with -trimpath
128 // (which releases should be). Absolute paths make it more difficult for
129 // Sentry to correctly group errors, but there's no way to infer a relative
130 // path from an absolute path at runtime.
131 var absPath, relPath string
132 if filepath.IsAbs(frame.File) {
133 absPath = frame.File
134 } else {
135 relPath = frame.File
136 }
137
138 // Reverse the frames - Sentry wants the most recent call first.
139 stack.Frames[len(frames)-i-1] = sentry.Frame{
140 Function: funcName,
141 Module: pkgName,
142 Filename: relPath,
143 AbsPath: absPath,
144 Lineno: frame.Line,
145 InApp: strings.HasPrefix(frame.Function, modPath) || pkgName == binPkg,
146 }
147 }
148 return stack
149}
150
151// exportedErrType returns the underlying type name of err if it's exported.
152// Otherwise, it returns an empty string.

Callers 1

newSentryExceptionFunction · 0.85

Calls 1

splitPkgFuncFunction · 0.85

Tested by

no test coverage detected