From bd63ba9929542f4b6e43b28071aca4569acc22f3 Mon Sep 17 00:00:00 2001 From: Marcel Ludwig Date: Mon, 5 Dec 2022 12:48:19 +0100 Subject: [PATCH] additional fixups; rm total suffix still broken due to https://github.com/open-telemetry/opentelemetry-go/pull/3369 --- handler/middleware/trace.go | 10 ++++++---- server/http_telemetry_test.go | 2 +- telemetry/instrumentation/instrumentation.go | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/handler/middleware/trace.go b/handler/middleware/trace.go index 9596a7c63..8e2c3e239 100644 --- a/handler/middleware/trace.go +++ b/handler/middleware/trace.go @@ -65,10 +65,12 @@ func (th *TraceHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { meter := provider.Meter("couper/server") counter, _ := meter.SyncInt64(). - Counter(instrumentation.ClientRequest, instrument.WithDescription(string(unit.Dimensionless))) + Counter(instrumentation.ClientRequest, + instrument.WithDescription(string(unit.Dimensionless))) duration, _ := meter.SyncFloat64(). - Histogram(instrumentation.ClientRequestDuration, instrument.WithDescription(string(unit.Dimensionless))) + Histogram(instrumentation.ClientRequestDuration, + instrument.WithDescription(string(unit.Dimensionless))) - counter.Add(req.Context(), 1) - duration.Record(req.Context(), end.Seconds()) + counter.Add(req.Context(), 1, metricsAttrs...) + duration.Record(req.Context(), end.Seconds(), metricsAttrs...) } diff --git a/server/http_telemetry_test.go b/server/http_telemetry_test.go index 84fe6e557..c82a76c87 100644 --- a/server/http_telemetry_test.go +++ b/server/http_telemetry_test.go @@ -57,7 +57,7 @@ func TestServeMetrics(t *testing.T) { `couper_client_request_total{code="404",host="localhost:8080",method="GET",service_name="my-service",service_version="0"} 1`, `couper_client_request_error_types_total{error="route_not_found_error",service_name="my-service",service_version="0"} 1`, `couper_client_connections_total{service_name="my-service",service_version="0"} 3`, - `go_goroutines{service_name="my-service"}`, + `go_goroutines{service_name="my-service",service_version="0"}`, } for _, expMetric := range expMetrics { diff --git a/telemetry/instrumentation/instrumentation.go b/telemetry/instrumentation/instrumentation.go index 545bb9bb4..ab4a78d3c 100644 --- a/telemetry/instrumentation/instrumentation.go +++ b/telemetry/instrumentation/instrumentation.go @@ -8,12 +8,12 @@ const ( BackendConnections = Prefix + "backend_connections_count" BackendConnectionsLifetime = Prefix + "backend_connections_lifetime_seconds" - BackendConnectionsTotal = Prefix + "backend_connections_total" + BackendConnectionsTotal = Prefix + "backend_connections" BackendHealthState = Prefix + "backend_up" - BackendRequest = Prefix + "backend_request_total" + BackendRequest = Prefix + "backend_request" BackendRequestDuration = Prefix + "backend_request_duration_seconds" ClientConnections = Prefix + "client_connections_count" - ClientConnectionsTotal = Prefix + "client_connections_total" - ClientRequest = Prefix + "client_request_total" + ClientConnectionsTotal = Prefix + "client_connections" + ClientRequest = Prefix + "client_request" ClientRequestDuration = Prefix + "client_request_duration_seconds" )