dd-trace-java icon indicating copy to clipboard operation
dd-trace-java copied to clipboard

Traces "path group" is not transformed correctly

Open aallou opened this issue 2 years ago • 4 comments

Using Java 17 and APM agent :

For a specific endpoint, i have a strange behaviour :

Sometimes my traces are displayed like this : http.path_group : /films/actor_id/notes (with actor_id is different per actor) Examples : http.path_group : /films/paul/notes http.path_group : /films/paul/notes http.path_group : /films/paul/notes

And sometimes, they are displayed like : http.path_group : /films/?/notes (so the path variable is recognized)

So, logically, all traces should be displayed like : http.path_group : /films/?/notes

aallou avatar Dec 28 '23 19:12 aallou

We are seeing similar issue with resource grouping under the Resource pane in APM. Our service defines a route with path variable but the calls are not grouped under single resource in APM. We are seeing most of them as separate resources when calling the endpoint with different parameters. Some calls are grouped correctly but very small portion of them (I ran a brief test and only 10 out of ~1000 requests got grouped correctly).

We use Kotlin, JDK 21 and Ktor with Netty. dd-java-agent version is 1.27.0.

Here's a simplified version of how we define our routing in Ktor. We'd expect to see all requests go under /v1/foo/? resource in APM.

embeddedServer(Netty, port = 8080) {
    routing {
        route("/v1") {
            get("/foo/{slug}") {
                call.respond(HttpStatusCode.OK)
            }
        }
    }
}.start(wait = true)

joni- avatar Jan 16 '24 13:01 joni-

Seeing the issue using Java 8, Jetty 9.4, dd-java-agent v1.13.0

shedrach-deliverr avatar Jan 17 '24 17:01 shedrach-deliverr

@joni- Was this issue fixed for you?

I am also seeing this issue, using Kotlin, Jetty 12.09 and dd-java-agent 1.34.0

hoanghun avatar May 31 '24 09:05 hoanghun

@joni- Was this issue fixed for you?

I am also seeing this issue, using Kotlin, Jetty 12.09 and dd-java-agent 1.34.0

We ended up doing something like this to get the grouping work properly. Does the job for us.

    get("/foo/{slug}") {
        val span = GlobalTracer.get().activeSpan()
        span?.setTag("http.path_group", "/foo/{slug}")
        span?.setTag(DDTags.RESOURCE_NAME, "GET /foo/{slug}")
        ...
    }

This page describes the logic behind quantization in more detail: https://docs.datadoghq.com/tracing/troubleshooting/quantization/

joni- avatar May 31 '24 12:05 joni-