otelutil

package module
v0.0.0-...-04ec335 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

README

OTEL Utilities

This repo implements some unified otel-based logging, metrics, and trace helpers mainly for use in Kubernetes controller projects, but more widely usable. It also contains some helpers for dumping logs, metrics, and traces to files in newline-delimited JSON format and additional helpers for tracing test execution runs through reconciler executions.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup(options ...Option) (shutdown func() error, err error)

Setup configures logging, tracing, and metrics otel configurations, including setting the global instances of logging, tracing, and metrics providers. Setup should be called exactly once at startup.

By default traces are ignored and logs are simply forwarded to stdout.

If `OTLP_DIR` is set, traces and logs will be written to a jsonnl file in the specified directory. (Paths are relative to the binary's working dir)

if `OTLP_GRPC` is set, traces and logs will be sent via the OTLP gRPC exporter to the specified endpoint.

Configuration options can also be passed via With* helpers.

See [config.fromEnv] for more details.

Types

type Option

type Option func(c config) config

Option customizes the behavior of Setup. Options are applied in order when calling Setup.

func WithBinaryName

func WithBinaryName(name string) Option

WithBinaryName sets the binary name used for file output naming.

func WithGRPCEndpoint

func WithGRPCEndpoint(endpoint string) Option

WithGRPCEndpoint sets the OTLP gRPC endpoint.

func WithLogLevel

func WithLogLevel(level log.TypedLevel) Option

WithLogLevel sets the logging level.

func WithMetricsInterval

func WithMetricsInterval(interval time.Duration) Option

WithMetricsInterval sets the interval for metric collection/export.

func WithServiceName

func WithServiceName(name string) Option

WithServiceName sets the OTEL service name for logs, traces, and metrics.

func WithTraceOutputDirectory

func WithTraceOutputDirectory(name string) Option

WithTraceOutputDirectory sets the directory where logs, traces, and metrics are written.

Directories

Path Synopsis
Package otelkube provides a client.Client and functions to propagate otel spans, traces, and baggage via Annotations on Kubernetes resources.
Package otelkube provides a client.Client and functions to propagate otel spans, traces, and baggage via Annotations on Kubernetes resources.

Jump to

Keyboard shortcuts

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