Add http client url template customizer#15217
Conversation
Declarative config is ready to be used, so we should support declarative config only - similar to how you have to use declarative config for more advanced method config |
zeitlinger
left a comment
There was a problem hiding this comment.
I'm wondering how this customizer is/should be related to the recently added InstrumenterCustomizer. They are closely related, so maybe InstrumenterCustomizer can just be extended.
I don't know how to implement this on top of |
implemented |
something like but that's not thought through |
|
I wonder what the right place to document this is, in particular the declarative config syntax. Maybe a javadoc or README? |
The first hurdle is that you need to somehow tell which instrumenters are for http clients, incidentally I was planning to implement something for it. Assuming you can do it then you'd need some way to detect whether this attribute is already set. This can be done by calling |
Add an SPI for customizing http client
url.templateattribute and the http client span name that is computed from it. This PR also includes a regular expression based customizer that allows for matching the http client url agains regular expressions to produce url templates. It can be configured by settingotel.instrumentation.http.client.url_template_rulesin declarative config where each rule consists of regex pattern used to match url, replacement and whether this rule can override existing url template (optional parameter). Url template is computed viapattern.matcher(url).replaceFirst(replacement)so replacement can contain capture groups used in the pattern. Note that since url templates are experimentalotel.instrumentation.http.client.emit-experimental-telemetryalso needs to be set.