Help us shape the future of Go! Take the 2026 Go Developer Survey

obs

package
v1.149.0 Latest Latest
Warning

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

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

Documentation

Overview

Package obs owns the platform's observability layer: the metrics recorder, its /metrics HTTP listener, and the (independently-gated) OTel tracer.

Split out of pkg/platform (#756) so the assembly and teardown of these three coupled handles is one testable unit with an explicit constructor, rather than three fields mutated in place on the Platform god-struct. Every accessor is nil-receiver-safe and returns nil-safe observability handles, so callers record and trace unconditionally and a disabled deployment behaves as a zero-overhead no-op.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Layer

type Layer struct {
	// contains filtered or unexported fields
}

Layer owns the metrics recorder, its listener, and the tracer.

func Assemble

func Assemble() (*Layer, error)

Assemble reads metrics and tracing config from the environment and builds the recorder, its listener, and the tracer. It returns a non-nil Layer even when both subsystems are disabled (the handles are nil and nil-safe). NewTracer installs the global OTel TracerProvider when tracing is enabled, so toolkit adapters and the tracing middleware emit nested spans without an injected handle.

func New

func New(metrics *observability.Metrics, tracer *observability.Tracer) *Layer

New builds a Layer from explicit handles, deriving the /metrics listener from the recorder. Assemble is the env-driven factory; New constructs a Layer from handles the caller already holds — used by tests that inject a specific recorder or tracer without going through the environment.

func (*Layer) Enabled

func (l *Layer) Enabled() bool

Enabled reports whether either metrics or tracing is active. It gates installation of the instrumenting decorators, which serve both subsystems.

func (*Layer) Listener

func (l *Layer) Listener() *observability.Listener

Listener returns the /metrics HTTP listener, or nil when the layer is nil. The returned type is nil-safe (a disabled listener starts/stops as a no-op), so the platform orchestrates and wraps Start/Shutdown at its own boundary.

func (*Layer) Metrics

func (l *Layer) Metrics() *observability.Metrics

Metrics returns the recorder, or nil when metrics are disabled or the layer is nil. The returned type is nil-safe.

func (*Layer) Tracer

func (l *Layer) Tracer() *observability.Tracer

Tracer returns the tracer, or nil when tracing is disabled or the layer is nil. The returned type is nil-safe.

Jump to

Keyboard shortcuts

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