You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I've been using the router for some time now, but I'm having trouble figuring out the path being called to include in the Datadog.
Below is an example of middleware, retrieves the path already with parameter value, but I would like to display it as the original path.
It is showing with the concatenated parameter and not as declared.
https://github.com/qgxpagamentos/ddfasthttp
``
func Middleware(f fasthttp.RequestHandler) fasthttp.RequestHandler {
return func(ctx *fasthttp.RequestCtx) {
if _, ok := os.LookupEnv("DATADOG_ENABLED"); !ok {
f(ctx)
return
}
spanOpts := []ddtrace.StartSpanOption{
tracer.ResourceName(string(ctx.Request.Header.Method()) + " " + string(ctx.Request.URI().Path())),
}
var r http.Request
if e := fasthttpadaptor.ConvertRequest(ctx, &r, true); e != nil {
panic(e)
}
span, context := StartRequestSpan(&r, spanOpts...)
If you want to get and set the declared raw router path, so group by all keys in the same span, you must get it from user values:
// set this flag in your router instance myrouter.SaveMatchedRoutePath=true// and get the matched route path from user values in your request handlermatchedRoutePath:=ctx.UserValue(router.MatchedRoutePathParam).(string)
Hello,
I've been using the router for some time now, but I'm having trouble figuring out the path being called to include in the Datadog.
Below is an example of middleware, retrieves the path already with parameter value, but I would like to display it as the original path.
It is showing with the concatenated parameter and not as declared.
https://github.com/qgxpagamentos/ddfasthttp
``
func Middleware(f fasthttp.RequestHandler) fasthttp.RequestHandler {
return func(ctx *fasthttp.RequestCtx) {
if _, ok := os.LookupEnv("DATADOG_ENABLED"); !ok {
f(ctx)
return
}
spanOpts := []ddtrace.StartSpanOption{
tracer.ResourceName(string(ctx.Request.Header.Method()) + " " + string(ctx.Request.URI().Path())),
}
var r http.Request
if e := fasthttpadaptor.ConvertRequest(ctx, &r, true); e != nil {
panic(e)
}
span, context := StartRequestSpan(&r, spanOpts...)
}
``
The text was updated successfully, but these errors were encountered: