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 -5
View File
@@ -25,10 +25,14 @@ const routeUnmatched = "unmatched"
// HTTPServerConfig configures the HTTP server middleware.
type HTTPServerConfig struct {
Metrics *Metrics // nil disables metrics
Logger *slog.Logger // nil disables access logs
TracerProvider trace.TracerProvider // nil: global provider
Propagator propagation.TextMapPropagator // nil: global propagator
Metrics *Metrics // nil disables metrics
Logger *slog.Logger // nil disables access logs
TracerProvider trace.TracerProvider // nil: global provider
// Propagator extracts the incoming trace context; nil: global propagator.
// Sampling follows the caller's decision, so on endpoints reachable by
// untrusted clients set propagation.NewCompositeTextMapPropagator() to
// ignore incoming trace headers.
Propagator propagation.TextMapPropagator
// RouteFunc returns the low-cardinality route template of a request
// (e.g. "/users/{id}"). It is called after the handler has run. The
@@ -134,7 +138,7 @@ func NewHTTPMiddleware(cfg HTTPServerConfig) func(http.Handler) http.Handler {
status := rw.status
switch {
case rec != nil && !rw.wroteHeader:
case rec != nil: // also after a partial response: the connection is aborted
status = http.StatusInternalServerError
case status == 0:
status = http.StatusOK