{"modulePath":"github.com/randomswdev/apm-agent-go","version":"v0.4.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package stacktrace\n\nPackage stacktrace provides a simplified stack frame type, functions for obtaining stack frames, and related utilities.\n\n## Functions\n\n```go\nfunc IsLibraryPackage(pkg string) bool\n```\nIsLibraryPackage reports whether or not the given package path is a library package. This includes known library packages (e.g. stdlib or apm-agent-go), vendored packages, and any packages with a prefix registered with RegisterLibraryPackage but not RegisterApplicationPackage.\n\n```go\nfunc RegisterApplicationPackage(pkg ...string)\n```\nRegisterApplicationPackage registers the given packages as being an application path. This must not be called concurrently with any other functions or methods in this package; it is expected to be used by init functions.\n\nIt is not typically necessary to register application paths. If a package does not match a registered \\*library\\* package path prefix, then the path is considered an application path. This function exists for the unusual case that an application exists within a library (e.g. an example program).\n\n```go\nfunc RegisterLibraryPackage(pkg ...string)\n```\nRegisterLibraryPackage registers the given packages as being well-known library path prefixes. This must not be called concurrently with any other functions or methods in this package; it is expected to be used by init functions.\n\n```go\nfunc SetContext(setter ContextSetter, frames []model.StacktraceFrame, pre, post int) error\n```\nSetContext sets the source context for the given stack frames, with the specified number of pre- and post- lines.\n\n```go\nfunc SplitFunctionName(in string) (packagePath, function string)\n```\nSplitFunctionName splits the function name as formatted in runtime.Frame.Function, and returns the package path and function name components.\n\n## Types\n\n```go\ntype ContextSetter interface {\n\t// SetContext sets the source context for the given stack frame,\n\t// with the specified number of pre- and post- lines.\n\tSetContext(frame *model.StacktraceFrame, pre, post int) error\n}\n```\nContextSetter is an interface that can be used for setting the source context for a stack frame.\n\n```go\nfunc FileSystemContextSetter(fs http.FileSystem) ContextSetter\n```\nFileSystemContextSetter returns a ContextSetter that sets context by reading file contents from the provided http.FileSystem.\n\n```go\ntype Frame struct {\n\t// File is the filename of the location of the stack frame.\n\t// This may be either the absolute or base name of the file.\n\tFile string\n\n\t// Line is the 1-based line number of the location of the\n\t// stack frame, or zero if unknown.\n\tLine int\n\n\t// Function is the name of the function name for this stack\n\t// frame. This should be package-qualified, and may be split\n\t// using stacktrace.SplitFunctionName.\n\tFunction string\n}\n```\nFrame describes a stack frame.\n\n```go\nfunc AppendCallerFrames(frames []Frame, callers []uintptr) []Frame\n```\nAppendCallerFrames appends to frames for the PCs in callers, and returns the extended slice.\n\nSee RuntimeFrame for information on what details are included.\n\n```go\nfunc AppendStacktrace(frames []Frame, skip, n int) []Frame\n```\nAppendStacktrace appends at most n entries to frames, skipping skip frames starting with AppendStacktrace, and returns the extended slice. If n is negative, then all stack frames will be appended.\n\nSee RuntimeFrame for information on what details are included.\n\n```go\nfunc RuntimeFrame(in runtime.Frame) Frame\n```\nRuntimeFrame returns a Frame based on the given runtime.Frame.\n\nThe resulting Frame will have the file path, package-qualified function name, and line number set. The function name can be split using SplitFunctionName, and the absolute path of the file and its base name can be determined using standard filepath functions.\n\n","path":"github.com/randomswdev/apm-agent-go/stacktrace","name":"stacktrace","synopsis":"Package stacktrace provides a simplified stack frame type, functions for obtaining stack frames, and related utilities.","isRedistributable":true}
