DataDog / dd-trace-java

Datadog APM client for Java
https://docs.datadoghq.com/tracing/languages/java
Apache License 2.0
593 stars 292 forks source link

Enhanced configuration of request path normalizer #3056

Open mkorosec opened 3 years ago

mkorosec commented 3 years ago

I'm searching for a way to combine request paths with a similar pattern into the same resource name. Similar to #2761, but the use-case is a bit different, I would not like to list each resource one by one, since there are too many.

With #2761 I can map /tenant1/some/url and /tenant2/some/url to /some/url. I would like to generalize this for all resource paths following the first part of the URL.

One approach could be to use a matcher /[^/]*/(.*)$ and then use the matched group for the result (or turn this around and remove the matched part of the request path). Alternatively, also skipping the first N segments in SimplePathNormalizer would do the trick.

Could this be achieved with some existing configuration that I overlooked? Or would it make sense to add such a feature?

devinsba commented 3 years ago

@mkorosec Thanks for the request, can I make sure I understand with an example.

given the paths: /v1/users, /v2/users, and /alpha/users

You would like this config to make all 3 of these have the resource /users

AND

given the paths: /v1/users, /v1/subscriptions, and /v1/products

You would like these to be /users, /subscriptions, and /products respectively

mkorosec commented 3 years ago

Hi @devinsba That's correct. The result could also be /?/users, as longs as the paths can be grouped without considering the first segment(s).