From c6734a4cf6592e2e7042aea312c32b99f23047d3 Mon Sep 17 00:00:00 2001 From: Kevin Franklin Kim Date: Wed, 17 Apr 2024 09:55:52 +0200 Subject: [PATCH] feat: add keel attr --- net/http/middleware/telemetry.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/http/middleware/telemetry.go b/net/http/middleware/telemetry.go index b643893..cfe7f3b 100644 --- a/net/http/middleware/telemetry.go +++ b/net/http/middleware/telemetry.go @@ -76,6 +76,13 @@ func TelemetryWithOptions(opts TelemetryOptions) Middleware { otel.GetTextMapPropagator().Inject(r.Context(), propagation.HeaderCarrier(w.Header())) } + if labeler, ok := otelhttp.LabelerFromContext(r.Context()); ok { + labeler.Add( + log.KeelServiceTypeKey.String("http"), + log.KeelServiceNameKey.String(name), + ) + } + if labeler, ok := httplog.LabelerFromRequest(r); ok { if spanCtx := trace.SpanContextFromContext(r.Context()); spanCtx.IsValid() && spanCtx.IsSampled() { labeler.Add(log.FTraceID(spanCtx.TraceID().String()))