Restrict "uri" KeyValue for client observations
Prior to this commit, the "uri" KeyValue for low cardinality metadata would contain the entire uri template given to the HTTP client when creating the request. This was a breaking change for existing metrics dashboards, as previous support was removing the protocol, host and port parts of the URI. Indeed, this information is available in the "client.name" and "http.uri" KayValue. This commit parses and removes the protocol+host+port information from the uri template for the "uri" KeyValue. Fixes gh-29885
This commit is contained in:
@@ -114,6 +114,14 @@ class DefaultClientRequestObservationConventionTests {
|
||||
assertThat(this.observationConvention.getLowCardinalityKeyValues(context)).contains(KeyValue.of("uri", "/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldOnlyConsiderPathForUriKeyValue() {
|
||||
ClientRequestObservationContext context = createContext(ClientRequest.create(HttpMethod.GET, URI.create("https://example.org/resource/42")));
|
||||
context.setUriTemplate("https://example.org/resource/{id}");
|
||||
context.setRequest(context.getCarrier().build());
|
||||
assertThat(this.observationConvention.getLowCardinalityKeyValues(context)).contains(KeyValue.of("uri", "/resource/{id}"));
|
||||
}
|
||||
|
||||
private ClientRequestObservationContext createContext(ClientRequest.Builder request) {
|
||||
ClientRequestObservationContext context = new ClientRequestObservationContext();
|
||||
context.setCarrier(request);
|
||||
|
||||
Reference in New Issue
Block a user