Description
I'm going to recommend we make a standard tag of http.route
, a way to help people make good low-cardinality names or tags from http requests. Main idea is that instead of parsing http.url
which can be trouble, allow frameworks to provide http.route
which might not always be the same format, but would always be variable and parameter free. It also has a higher likelihood of matching 255 char indexing constraints, which are common on storage backends.
Here are some examples of http route values for the same endpoint:
- vert.x web route "/items/:itemId"
- Play "/items/$id<[0-9]+>"
- Spring WebMVC request mapping "/items/{itemId}"
Until we have something like this, it is almost nonsense to answer some folks who want to push spans into metrics (see #1869). For example, in prometheus, counters etc will reset on each small deviation of tags, a problem far worse than ours wrt cardinality.
Example framework relationships:
- Jersey - response has the template
- ratpack - response has the template
- spring - attribute includes the template
- sparkjava - not yet supported
- play - via tags kamon example
In interop tests, we can't necessarily test for equality of this value as it will be framework specific. However, we can test for cardinality! Ex we make an endpoint with a path variable and execute it against two values of that. Then, we test http.path
tag is different while http.template
is the same. Ideally the http template is already "washed", but those derived from paths might need normalization. For example, you may need to ensure there's only one leading slash.
Besides a lookup tag, http.template
can be used to create a better name for the span. For example, if a template is available, it could be a better choice than the http method. Implementation-wise, this implies a span rename feature, as templates are not always known before-the-fact. That said a primary use case is navigating to other systems like metrics, whether that's directly via the http.template tag or something derived from it.
For example, requests that don't match any template need to be eventually handled. For example, if the http.response_code
tag is present and http.template
is absent, you might have a heuristic to create a bucketed tag like 'REDIRECT' to share with metrics. Doing so allows bot-like behavior from poisoning metrics. This sort of logic exists in micrometer.
Thanks for input on this, notably @jkschneider and @mikewrighton. CC'ing the "firehose" crowd @bplotnick @kaisen @drolando and @narayaruna, and others interested in collaborating like @ivantopo