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

+9 -6
View File
@@ -90,9 +90,10 @@ func (m *Metrics) Gauge(name, help string, labels ...string) *prometheus.GaugeVe
}
// GaugeFunc registers a gauge whose value is computed by fn on every scrape,
// e.g. queue length or cache size.
// e.g. queue length or cache size. Unlike Counter and friends it panics when
// the name is already registered: a second fn would otherwise be ignored.
func (m *Metrics) GaugeFunc(name, help string, fn func() float64) {
register[prometheus.Collector](m.registry, prometheus.NewGaugeFunc(prometheus.GaugeOpts{
m.registry.MustRegister(prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: m.cfg.Namespace,
Subsystem: m.cfg.Subsystem,
Name: name,
@@ -101,9 +102,10 @@ func (m *Metrics) GaugeFunc(name, help string, fn func() float64) {
}
// CounterFunc registers a counter whose value is computed by fn on every
// scrape. fn must return monotonically increasing values.
// scrape. fn must return monotonically increasing values. It panics when the
// name is already registered.
func (m *Metrics) CounterFunc(name, help string, fn func() float64) {
register[prometheus.Collector](m.registry, prometheus.NewCounterFunc(prometheus.CounterOpts{
m.registry.MustRegister(prometheus.NewCounterFunc(prometheus.CounterOpts{
Namespace: m.cfg.Namespace,
Subsystem: m.cfg.Subsystem,
Name: name,
@@ -112,9 +114,10 @@ func (m *Metrics) CounterFunc(name, help string, fn func() float64) {
}
// RegisterDBStats exports database/sql connection pool statistics
// (go_sql_* metrics) labeled with db_name=name.
// (go_sql_* metrics) labeled with db_name=name. It panics when name is
// already registered: stats of a second pool would otherwise be dropped.
func (m *Metrics) RegisterDBStats(db *sql.DB, name string) {
register(m.registry, collectors.NewDBStatsCollector(db, name))
m.registry.MustRegister(collectors.NewDBStatsCollector(db, name))
}
// Handler returns an http.Handler for the /metrics endpoint.