Harden instrumentation, health checks and the admin server
CI / test (push) Failing after 43s

- Admin pprof is opt-in (AdminConfig.EnablePprof)
- Client spans drop the URL query string; HostFunc bounds the host label
- Config.HTTP/HTTPClient/GRPC configure the Observer's instrumentation
- A panic after a partial HTTP response counts as 500
- GaugeFunc, CounterFunc and RegisterDBStats panic on duplicates
- Abandoned client gRPC streams are recorded as Canceled
- OTEL_EXPORTER_OTLP_PROTOCOL selects the protocol when unset
- Health reports are cached for 1s; hung checks are not restarted
- Environment is exported as deployment.environment.name

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
M.ShakhmatovandClaude Fable 5.2 committed 2026-11-15 16:56:39 +03:00
1 parent 8647fdf1bb
commit c92fd9826b
21 files changed
+457 -101

No files matched your search

+15 -5
View File
@@ -23,18 +23,28 @@ type Config struct {
Health HealthConfig // Metrics is set automatically
Admin AdminConfig
// HTTP, HTTPClient and GRPC tune the instrumentation created by the
// Observer (RouteFunc, Skip, Buckets, Propagator, HostFunc...). Metrics,
// Logger and TracerProvider default to the Observer's own.
HTTP HTTPServerConfig
HTTPClient HTTPClientConfig
GRPC GRPCConfig
// DisableAccessLog turns off per-request logs from the HTTP and gRPC
// server instrumentation.
DisableAccessLog bool
}
// AdminConfig configures the internal admin HTTP server exposing /metrics,
// /healthz, /readyz, /buildinfo, /loglevel and /debug/pprof/.
// /healthz, /readyz, /buildinfo, /loglevel and, when enabled, /debug/pprof/.
// The server has no authentication: bind it to an internal address.
type AdminConfig struct {
// Addr to listen on, e.g. ":9090". When empty no server is started; mount
// Observer.AdminHandler on your own server instead.
Addr string
DisablePprof bool
Addr string
// EnablePprof serves /debug/pprof/. Off by default: profiling is costly
// and the admin server is unauthenticated.
EnablePprof bool
}
func (c *Config) defaults() {
@@ -72,7 +82,7 @@ func (c *Config) defaults() {
// OBSX_METRICS_NAMESPACE Metrics.Namespace
// OBSX_HEALTH_TIMEOUT Health.Timeout (Go duration, e.g. "3s")
// OBSX_ADMIN_ADDR Admin.Addr
// OBSX_ADMIN_DISABLE_PPROF Admin.DisablePprof
// OBSX_ADMIN_ENABLE_PPROF Admin.EnablePprof
// OBSX_DISABLE_ACCESS_LOG DisableAccessLog
//
// Standard OTEL_EXPORTER_OTLP_* and OTEL_RESOURCE_ATTRIBUTES variables are
@@ -94,7 +104,7 @@ func (c Config) WithEnv() Config {
envString(&c.Metrics.Namespace, "OBSX_METRICS_NAMESPACE")
envDuration(&c.Health.Timeout, "OBSX_HEALTH_TIMEOUT")
envString(&c.Admin.Addr, "OBSX_ADMIN_ADDR")
envBool(&c.Admin.DisablePprof, "OBSX_ADMIN_DISABLE_PPROF")
envBool(&c.Admin.EnablePprof, "OBSX_ADMIN_ENABLE_PPROF")
envBool(&c.DisableAccessLog, "OBSX_DISABLE_ACCESS_LOG")
return c
}