package middleware import ( "github.com/gin-gonic/gin" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" ) func Tracing(serviceName string) gin.HandlerFunc { tracer := otel.Tracer(serviceName) return func(c *gin.Context) { ctx, span := tracer.Start(c.Request.Context(), c.FullPath()) defer span.End() span.SetAttributes( attribute.String("http.method", c.Request.Method), attribute.String("http.path", c.Request.URL.Path), ) c.Request = c.Request.WithContext(ctx) c.Next() } }