otelutil

package
v0.6.14 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 6 Imported by: 0

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(raw []byte, into any) error

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.

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

type Duration time.Duration

Duration decodes a Go duration string ("5s", "1m30s") from yaml, which yaml.v3 does not do for time.Duration itself.

func (Duration) Std

func (d Duration) Std() time.Duration

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(node *yaml.Node) error

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

func NewRegistry[F any](kind, hint string) *Registry[F]

func (*Registry[F]) Lookup

func (r *Registry[F]) Lookup(name string) (F, error)

func (*Registry[F]) Register

func (r *Registry[F]) Register(name string, f F)

Register makes f available under name. Double-registration panics so a conflicting init() surfaces at startup instead of silently winning.

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).

func (*Retry) On

func (r *Retry) On() bool

On resolves the tri-state Enabled: a present block without the key is on. Nil-safe, so an unguarded cfg.Retry.On() reads as the default (on) rather than panicking.

Jump to

Keyboard shortcuts

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