otelutil

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package otelutil is plumbing shared by the tracing and metrics services: exporter registry, otlp config, HTTP semconv helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

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

Decode rejects unknown keys; empty raw leaves into untouched.

func ProtocolVersion added in v0.6.15

func ProtocolVersion(r *http.Request) string

ProtocolVersion spells semconv's "1.1", "2", "3", not Go's "HTTP/2.0".

func RequestMethod added in v0.6.15

func RequestMethod(method string) httpconv.RequestMethodAttr

RequestMethod is case-sensitive: anything outside the known set (including "get") is _OTHER, so clients cannot mint new series.

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 otlp config; a zero field keeps the exporter's default. grpc/http-typed knobs belong in an app-registered Factory instead.

type Duration

type Duration time.Duration

Duration decodes "5s"-style yaml, which yaml.v3 does not do for time.Duration.

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 safe for concurrent use; a failed Lookup names the blank-import that would provide 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 panics on a duplicate name, so a conflicting init() fails at startup.

type Retry

type Retry struct {
	// nil means on, matching otlp's default
	Enabled         *bool    `yaml:"enabled"`
	InitialInterval Duration `yaml:"initial_interval"`
	MaxInterval     Duration `yaml:"max_interval"`
	MaxElapsedTime  Duration `yaml:"max_elapsed_time"`
}

func (*Retry) On

func (r *Retry) On() bool

On is nil-safe: a nil Retry or unset Enabled is on.

Jump to

Keyboard shortcuts

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