telemetry

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package telemetry provides logging, metrics, and health.

Package telemetry provides structured logging, Prometheus metrics, and health checks so the gateway itself is observable from day one.

Index

Constants

View Source
const RequestIDHeader = "X-Request-Id"

RequestIDHeader carries a correlation id across the request boundary.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(level slog.Level, jsonOut bool) *slog.Logger

NewLogger builds a structured slog logger (JSON in prod, text in dev).

func RequestID

func RequestID(ctx context.Context) string

RequestID returns the correlation id stored on the context, if any.

func RequestIDMiddleware

func RequestIDMiddleware(next http.Handler) http.Handler

RequestIDMiddleware ensures every request carries a correlation id, echoes it on the response, and stores it in the context for structured logging.

Types

type Check

type Check func(ctx context.Context) error

Check reports whether a subsystem is healthy.

type Health

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

Health aggregates named liveness/readiness checks behind a status endpoint.

func NewHealth

func NewHealth() *Health

NewHealth returns an empty health registry.

func (*Health) Handler

func (h *Health) Handler() http.HandlerFunc

Handler runs every check and reports overall status. Any failing check yields HTTP 503 so a load balancer can route around an unhealthy instance.

func (*Health) Register

func (h *Health) Register(name string, c Check)

Register adds (or replaces) a named check.

type Metrics

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

Metrics holds the gateway's Prometheus collectors on a private registry.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics registers the collectors on a fresh registry.

func (*Metrics) AddRecordingBytes

func (m *Metrics) AddRecordingBytes(n int)

AddRecordingBytes counts bytes written to recordings.

func (*Metrics) Handler

func (m *Metrics) Handler() http.Handler

Handler serves the metrics in Prometheus text format.

func (*Metrics) IncAuthzFailure

func (m *Metrics) IncAuthzFailure()

IncAuthzFailure counts a denied authorization.

func (*Metrics) IncSecretAccess

func (m *Metrics) IncSecretAccess()

IncSecretAccess counts a secret decryption.

func (*Metrics) ObserveAction

func (m *Metrics) ObserveAction(risk, result string, d time.Duration)

ObserveAction records a handler's latency labelled by risk + result.

func (*Metrics) RecordingFailed

func (m *Metrics) RecordingFailed()

RecordingFailed counts a recording that failed to capture.

func (*Metrics) RecordingFinished

func (m *Metrics) RecordingFinished()

func (*Metrics) RecordingStarted

func (m *Metrics) RecordingStarted()

RecordingStarted / RecordingFinished track active recordings.

func (*Metrics) Registry

func (m *Metrics) Registry() *prometheus.Registry

Registry exposes the underlying registry (for tests or extra collectors).

func (*Metrics) SetChannels

func (m *Metrics) SetChannels(n int)

func (*Metrics) SetSessions

func (m *Metrics) SetSessions(n int)

SetSessions / SetChannels reflect the live registry counts.

func (*Metrics) WSClosed

func (m *Metrics) WSClosed()

func (*Metrics) WSOpened

func (m *Metrics) WSOpened()

WSOpened / WSClosed track active WebSocket connections.

Jump to

Keyboard shortcuts

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