adjust tracing middleware for practical use
This commit is contained in:
parent
d7b45a1439
commit
3024e888c7
@ -24,7 +24,6 @@ type Config struct {
|
||||
Version string
|
||||
// Name of an organization providing the service
|
||||
ServiceProvider string
|
||||
|
||||
Exporters []exporters.TraceExporter
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ package fiber_tracing
|
||||
// into the package.
|
||||
|
||||
import (
|
||||
"git.ma-al.com/maal-libraries/observer/pkg/attr"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"go.opentelemetry.io/otel"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.25.0"
|
||||
@ -50,28 +51,27 @@ func new(config ...middlewareConfig) fiber.Handler {
|
||||
|
||||
// Return new handler
|
||||
return func(c *fiber.Ctx) error {
|
||||
spanStartAttributes := trace.WithAttributes(
|
||||
spanStartAttributes := []attr.KeyValue{
|
||||
semconv.HTTPMethod(c.Method()),
|
||||
semconv.HTTPTarget(string(c.Request().RequestURI())),
|
||||
semconv.HTTPRoute(c.Route().Path),
|
||||
semconv.HTTPURL(c.OriginalURL()),
|
||||
semconv.HostIP(c.IP()),
|
||||
semconv.HTTPUserAgent(string(c.Request().Header.UserAgent())),
|
||||
semconv.HTTPRequestContentLength(c.Request().Header.ContentLength()),
|
||||
semconv.HTTPScheme(c.Protocol()),
|
||||
semconv.NetTransportTCP,
|
||||
)
|
||||
spanKind := trace.WithSpanKind(trace.SpanKindServer)
|
||||
}
|
||||
spanStartAttributes = append(spanStartAttributes, attr.ProcessStart()...)
|
||||
|
||||
opts := []trace.SpanStartOption{
|
||||
spanStartAttributes,
|
||||
spanKind,
|
||||
trace.WithAttributes(spanStartAttributes...),
|
||||
trace.WithSpanKind(trace.SpanKindServer),
|
||||
}
|
||||
opts = append(opts, cfg.TracerStartAttributes...)
|
||||
|
||||
otelCtx, span := Tracer.Start(
|
||||
c.UserContext(),
|
||||
c.Method()+" "+c.Route().Path,
|
||||
c.Method()+" "+c.OriginalURL(),
|
||||
opts...,
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user