Help us shape the future of Go! Take the 2026 Go Developer Survey

spanerror

package
v1.12.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package spanerror records errors and panics on spans without their text. Forge never puts an error message on a span: the status description is the error's class and the exception event carries exception.type only. It imports nothing from forge, so the router and the telemetry package can both use it.

Index

Constants

View Source
const PanicClass = "panic"

PanicClass is what a recovered panic is recorded as. The panic value never goes on the span.

Variables

This section is empty.

Functions

func AddException

func AddException(span trace.Span, class string, stack bool)

AddException adds an exception event whose only attribute is exception.type, plus exception.stacktrace when stack is true. It leaves the span's status alone.

func ErrorClass

func ErrorClass(err error) string

ErrorClass names err without its message: context.Canceled or context.DeadlineExceeded when err is or wraps one, otherwise the Go type of the innermost error in its Unwrap chain, so a wrapped driver error reports the driver's type rather than *fmt.wrapError. Error text can quote a DSN, a credential or a bound query value, so forge puts only this on a span.

func RecordError

func RecordError(span trace.Span, err error)

RecordError gives span an Error status described by err's class and adds an exception event that carries only exception.type. It does nothing for a nil err. Use it in place of span.RecordError, which copies err.Error() onto the span as exception.message.

func RecordPanic

func RecordPanic(span trace.Span, stack bool)

RecordPanic gives span an Error status described as PanicClass and adds an exception event of that type. With stack, the event also carries the goroutine's stack trace, which names code locations and holds no request data. Call it from the deferred function that recovered the panic, so the stack still includes the frames that panicked.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL