observ

package
v0.6.2 Latest Latest
Warning

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

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

Documentation

Overview

Package observ is the edge observability middleware (ADR-0114, F76): RED metrics (request rate / errors / duration by function+status) off the OTel meter, an edge span that mints or adopts a W3C traceparent so the downstream invocation span parents under it (the ingress hop joins the one-run-one-trace waterfall, ADR-0101/0102), and a structured access log correlated by X-Request-Id. It is additive (never rejects) and no-op-friendly (the default no-op Telemetry ⇒ no metric/trace dials; the access log uses slog). It sits outer than the F75 limiter (so it times the whole hop incl. rejects) and inner than RequestID (so it can read the id). Its ResponseWriter wrapper forwards http.Flusher + http.Hijacker so SSE/WS are never broken.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chain

func Chain(cfg Config, telemetry *observability.Telemetry, logger *slog.Logger) func(http.Handler) http.Handler

Chain returns the observability middleware. A zero Config is a pass-through.

Types

type Config

type Config struct {
	Metrics   bool
	AccessLog bool
	Trace     bool
}

Config toggles the three observability signals. A zero Config is a pass-through.

type Target

type Target struct {
	Namespace string
	Function  string
}

Target is the request-scoped holder observ seeds and dataplane fills with the resolved function, so the metric/log label is correct even for a Route hit (observ runs outside dataplane.Handler).

func TargetFrom

func TargetFrom(ctx context.Context) (*Target, bool)

TargetFrom returns the request's Target holder, if seeded.

func WithTarget

func WithTarget(ctx context.Context) (context.Context, *Target)

WithTarget seeds an empty Target holder into ctx.

Jump to

Keyboard shortcuts

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