Skip to content

Commit

Permalink
feat: add query params on traces when debug is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Nov 13, 2024
1 parent 47f3206 commit 61b2c63
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"github.com/formancehq/go-libs/v2/api"
"github.com/formancehq/ledger/internal/controller/system"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
nooptracer "go.opentelemetry.io/otel/trace/noop"
"net/http"
Expand Down Expand Up @@ -47,6 +48,17 @@ func NewRouter(
middleware.RequestLogger(api.NewLogFormatter()),
}

if debug {
commonMiddlewares = append(commonMiddlewares, func(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
trace.SpanFromContext(r.Context()).
SetAttributes(attribute.String("raw-query", r.URL.RawQuery))

handler.ServeHTTP(w, r)
})
})
}

v2Router := v2.NewRouter(
systemController,
authenticator,
Expand Down

0 comments on commit 61b2c63

Please sign in to comment.