From a4af13177c6c84a21cd8e5d42ac9b3dbceff749f Mon Sep 17 00:00:00 2001 From: M1a0 Date: Fri, 2 Feb 2024 16:21:06 +0800 Subject: [PATCH] feat: use app.GetHandlerName replace of reflect value (#49) --- tracing/utils.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tracing/utils.go b/tracing/utils.go index 00f5242..5927da5 100644 --- a/tracing/utils.go +++ b/tracing/utils.go @@ -33,7 +33,11 @@ import ( // Ref to https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#name // naming rule: $HandlerName:$FullPath func serverSpanNaming(c *app.RequestContext) string { - return c.HandlerName() + ":" + c.FullPath() + handlerName := app.GetHandlerName(c.Handler()) + if handlerName == "" { + handlerName = c.HandlerName() + } + return handlerName + ":" + c.FullPath() } func clientSpanNaming(req *protocol.Request) string {