diagnostics

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DurationMillis

func DurationMillis(duration time.Duration) int64

func Enabled

func Enabled(debugEnabled bool, httpAddr string) bool

func IsLoopbackBind

func IsLoopbackBind(addr string) bool

func RegisterDebugHandlers added in v0.3.0

func RegisterDebugHandlers(mux *http.ServeMux, options DebugOptions)

RegisterDebugHandlers mounts the opt-in debug handlers (pprof, expvar) on the provided mux. It is the runtime counterpart to the [debug].pprof_enabled and expvar_enabled config flags: those flags are parsed by the config layer but, without this wiring, never actually exposed. The caller MUST gate this on diagnostics.Enabled (debug.enabled AND a loopback bind) so the handlers are unreachable from a non-loopback address even if the flags are on. The pprof handlers are registered explicitly on the supplied mux rather than via the net/http/pprof init side effects on http.DefaultServeMux, so they never leak to any other server that shares the default mux.

Routes mounted (pprofEnabled):

GET  /debug/pprof/            index (list of profiles)
GET  /debug/pprof/cmdline
GET  /debug/pprof/profile     CPU profile (default 30s; seconds GET param)
GET  /debug/pprof/symbol
GET  /debug/pprof/trace       execution trace
GET  /debug/pprof/{heap,goroutine,block,mutex,allocs,threadcreate}

Routes mounted (expvarEnabled):

GET  /debug/vars              expvar registry

func RegisterRoutes

func RegisterRoutes(mux *http.ServeMux, svc *Service)

Types

type DebugOptions added in v0.3.0

type DebugOptions struct {
	PprofEnabled  bool
	ExpvarEnabled bool
}

DebugOptions selects which optional debug handlers RegisterDebugHandlers mounts. Each handler is gated separately so an operator can enable, e.g., runtime metrics without exposing pprof.

type IngestionSnapshotter

type IngestionSnapshotter interface {
	IngestionDiagnostics() projectingestion.DiagnosticsSnapshot
}

type RuntimeOptions

type RuntimeOptions struct {
	Enabled bool
}

type RuntimeSnapshot

type RuntimeSnapshot struct {
	Goroutines      int    `json:"goroutines"`
	HeapAllocBytes  uint64 `json:"heap_alloc_bytes"`
	HeapInuseBytes  uint64 `json:"heap_inuse_bytes"`
	StackInuseBytes uint64 `json:"stack_inuse_bytes"`
}

type Service

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

func NewService

func NewService(ingestion IngestionSnapshotter, runtimeOptions RuntimeOptions) *Service

func (*Service) Snapshot

func (svc *Service) Snapshot() Snapshot

type Snapshot

type Snapshot struct {
	Ingestion projectingestion.DiagnosticsSnapshot `json:"ingestion"`
	Runtime   RuntimeSnapshot                      `json:"runtime,omitempty"`
}

Jump to

Keyboard shortcuts

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