Documentation
¶
Overview ¶
Package otelutil holds the shared plumbing behind framingo's telemetry services (tracing, metrics): the name-to-factory Registry their exporter subpackages register into from init(), and the transport-agnostic otlp config vocabulary (Duration, Retry, Config, the strict Decode) their factories build exporters from. Signal-specific knobs layer on top in the signal's own package - tracing's exporters/model wraps Config with the span-exporter-only max_request_size, which is why it is absent here. It also holds the HTTP convention helpers the api server's metrics and the trace middleware share (RequestMethod), so a span and a metric never disagree about the same request.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode strict-decodes raw into the factory's config struct: unknown keys fail, so a typo'd exporter config entry surfaces at Init instead of being silently ignored. nil or empty raw leaves the struct zero.
func ProtocolVersion ¶ added in v0.6.15
ProtocolVersion is the network.protocol.version value for a request: "1.0" or "1.1" for HTTP/1, and the bare major - "2", "3" - above it, the convention's spelling rather than Go's "HTTP/2.0". Shared by the api server's metrics and the trace middleware's span, like RequestMethod.
func RequestMethod ¶ added in v0.6.15
func RequestMethod(method string) httpconv.RequestMethodAttr
RequestMethod maps a request method onto the http.request.method convention's value set; anything outside it is _OTHER - the convention's guard against a client minting a new series, or span attribute value, per made-up or oddly-cased method. net/http validates a method's characters but keeps its spelling, so "get" and "FOO" both arrive verbatim. Shared by the api server's metrics and the trace middleware's span, so both agree.
Types ¶
type Config ¶
type Config struct {
Endpoint string `yaml:"endpoint"` // host:port, no scheme
Insecure bool `yaml:"insecure"`
Headers map[string]string `yaml:"headers"`
Compression string `yaml:"compression"` // "gzip", or ""/"none"
Timeout Duration `yaml:"timeout"`
Retry *Retry `yaml:"retry"`
}
Config is the transport-agnostic half of the otlp exporter surface. A zero field leaves the exporter's own default in place. Knobs that carry grpc or http types (dial options, connections, proxies) are deliberately absent - an exporter needing those is an app-registered Factory instead, whose closure captures whatever construction requires.
type Duration ¶
Duration decodes a Go duration string ("5s", "1m30s") from yaml, which yaml.v3 does not do for time.Duration itself.
type Registry ¶
type Registry[F any] struct { // contains filtered or unexported fields }
Registry is the name-to-factory registry behind pluggable implementations that register themselves from subpackage init()s - the discipline the tracing and metrics exporter registries share: Register panics on a duplicate name so misconfiguration surfaces at startup, and a failed Lookup names the blank-import that would have provided it.
func NewRegistry ¶
type Retry ¶
type Retry struct {
// Enabled defaults to true when the retry block is present - writing
// intervals is opting in, matching otlp's own retry-on default.
Enabled *bool `yaml:"enabled"`
InitialInterval Duration `yaml:"initial_interval"`
MaxInterval Duration `yaml:"max_interval"`
MaxElapsedTime Duration `yaml:"max_elapsed_time"`
}
Retry mirrors the otlp exporters' retry settings (their RetryConfig types are per-package aliases of the same shape).