yo11y

package
v0.0.0-...-d168c4f Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

yo11y contains helpers for setting up the opentelemetry (otel) sdk. The sdks primarily take configuration from the "OTEL_" environment variables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(c Config) (O11y, O11yReg)

func NewMetric

func NewMetric(ctx context.Context, res *resource.Resource, c Config) (func(context.Context) error, error)

func NewTrace

func NewTrace(ctx context.Context, res *resource.Resource, c Config) (http.Handler, func(context.Context) error, error)

Types

type Config

type Config struct {
	LogLevel  slog.Level `env:"LOG_LEVEL"`
	LogFormat string     `env:"LOG_FORMAT"`
}

type O11y

type O11y struct {
	T trace.Tracer
	M metric.Meter
	L *slog.Logger
	H slog.Handler
	// contains filtered or unexported fields
}

func (O11y) Err

func (o O11y) Err(ctx context.Context, msg string, err error, attrs ...slog.Attr) error

func (O11y) HTTPErr

func (o O11y) HTTPErr(ctx context.Context, msg string, err error, rw http.ResponseWriter, code int, attrs ...slog.Attr)

func (O11y) Region

func (o O11y) Region(ctx context.Context, name string, do func(ctx context.Context, span trace.Span) error) error

func (O11y) Sub

func (o O11y) Sub(name string) O11y

type O11yReg

type O11yReg struct {
	LogZpage   http.Handler
	TraceZpage http.Handler

	ShutTrace  func(context.Context) error
	ShutMetric func(context.Context) error
}