Documentation
¶
Overview ¶
Package errclass implements a pluggable classifier that maps errors to a closed set of OpenTelemetry-compatible error.type labels. The base module defines only vendor-neutral classes (timeouts, cancellation, network, auth, rate-limiting, invalid requests, permission denial, upstream 5xx). Each consuming SDK registers its own sentinels or matchers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AttrKey = attribute.Key("error.type")
AttrKey is the OTel-standard error.type attribute key. Recorded spans and metrics use it as the closed-set error classification label.
Functions ¶
This section is empty.
Types ¶
type Class ¶
type Class string
Class is a closed-set label. Consuming libraries may define their own Class constants, but they SHOULD keep the total cardinality bounded and stable.
const ( // Unknown is the default when no matcher fires. Use sparingly — an Unknown // rate climbing is a signal that your sentinel coverage is lagging. Unknown Class = "unknown" // Standard closed set. Timeout Class = "timeout" Canceled Class = "canceled" InvalidRequest Class = "invalid_request" RateLimited Class = "rate_limited" Auth Class = "auth" PermissionDenied Class = "permission_denied" Upstream5xx Class = "upstream_5xx" Network Class = "network" )
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds an ordered list of matchers. First match wins.
func New ¶
func New() *Registry
New returns an empty registry. Consider calling RegisterDefaults() if you want the standard context.Canceled / context.DeadlineExceeded mappings.
func (*Registry) Classify ¶
Classify returns the class for err. Returns "" for a nil error and Unknown if no matcher fires.
func (*Registry) RegisterDefaults ¶
func (r *Registry) RegisterDefaults()
RegisterDefaults registers the baseline mappings that apply to every library: context.DeadlineExceeded → Timeout, context.Canceled → Canceled.
func (*Registry) RegisterMatcher ¶
RegisterMatcher appends a custom matcher. Matchers are tried in registration order, so register more specific matchers before more general ones.
func (*Registry) RegisterSentinel ¶
RegisterSentinel wires a sentinel error to a class via errors.Is.