telemetry

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package telemetry holds what herald's spans and metrics share: the tracer, the attribute keys, the error classes and a small label vector over a go-utils metrics sink.

Nothing here ever reads an error's message. A driver error can quote up to 1KB of the vendor's response, and an SMTP error can name the recipient, so a failed span carries a class and the error's Go type, never its text.

Index

Constants

View Source
const (
	KeyChannel        = attribute.Key("herald.channel")
	KeyTemplate       = attribute.Key("herald.template")
	KeyDriver         = attribute.Key("herald.driver")
	KeyProviderID     = attribute.Key("herald.provider.id")
	KeyResolveVia     = attribute.Key("herald.resolve.via")
	KeyRecipientCount = attribute.Key("herald.recipient.count")
	KeySent           = attribute.Key("herald.delivery.sent")
	KeyFailed         = attribute.Key("herald.delivery.failed")
	KeySuppressed     = attribute.Key("herald.suppressed")
	KeyChannelCount   = attribute.Key("herald.channel.count")
	KeyChannelsFailed = attribute.Key("herald.channel.failed")
	KeyLocale         = attribute.Key("herald.template.locale")
	KeyLocaleMatch    = attribute.Key("herald.template.locale_match")

	KeyServerAddress  = attribute.Key("server.address")
	KeyServerPort     = attribute.Key("server.port")
	KeyHTTPMethod     = attribute.Key("http.request.method")
	KeyHTTPStatusCode = attribute.Key("http.response.status_code")
	KeyURLTemplate    = attribute.Key("url.template")
	KeyErrorType      = attribute.Key("error.type")
	KeyExceptionType  = attribute.Key("exception.type")
)

Attribute keys herald sets. The semconv ones use the OpenTelemetry names.

View Source
const (
	ClassTimeout    = "timeout"
	ClassCanceled   = "canceled"
	ClassDNS        = "dns"
	ClassTLS        = "tls"
	ClassConnection = "connection"
	ClassOther      = "other"
)

Network failure classes. These are the only values NetClass returns.

View Source
const ScopeName = "github.com/xraph/herald"

ScopeName is the instrumentation scope every herald span carries.

Variables

This section is empty.

Functions

func CallClass

func CallClass(ctx context.Context, err error) string

CallClass is NetClass for a call made under ctx. A deadline that has passed or a canceled ctx decides the class whatever err says, since http.Client's own timeout can surface as an unexported "request canceled" error that is neither a context error nor a net.Error.

func Fail

func Fail(span trace.Span, class, errType string)

Fail marks span as failed with class as the status description, and adds an exception event carrying only errType as exception.type. Both must be a class or a type name from a fixed set, never an error's message.

func FailErr

func FailErr(span trace.Span, class string, err error)

FailErr is Fail with the Go type of err's innermost error. err's message is never read.

func NetClass

func NetClass(err error) string

NetClass sorts a transport failure into timeout, canceled, dns, tls, connection or other.

func SMTPClass

func SMTPClass(ctx context.Context, err error) string

SMTPClass is the class of a failed SMTP conversation under ctx: the server's reply code ("535", "550") when it answered with an error, otherwise CallClass.

func Tracer

func Tracer() trace.Tracer

Tracer returns herald's tracer from the global provider, which forge.New installs. It looks the provider up on every call, so a provider set after herald starts (or swapped in a test) is the one that gets the spans.

func TypeOf

func TypeOf(err error) string

TypeOf is the Go type of the innermost error in err's chain, such as *net.OpError or syscall.Errno. It follows single-error Unwrap only, so a joined error reports its own type.

Types

This section is empty.

Directories

Path Synopsis
Package metricsvec declares herald's labelled counters and histograms over a go-utils metrics sink.
Package metricsvec declares herald's labelled counters and histograms over a go-utils metrics sink.
Package telemetrytest records what herald's telemetry emits, for tests: a span recorder installed as the global tracer provider, and a go-utils metrics sink that remembers every series registered on it.
Package telemetrytest records what herald's telemetry emits, for tests: a span recorder installed as the global tracer provider, and a go-utils metrics sink that remembers every series registered on it.

Jump to

Keyboard shortcuts

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