parent
5666e363d1
commit
49a63e2c37
|
@ -43,7 +43,7 @@ public class DefaultClientRequestObservationConvention implements ClientRequestO
|
||||||
|
|
||||||
private static final String DEFAULT_NAME = "http.client.requests";
|
private static final String DEFAULT_NAME = "http.client.requests";
|
||||||
|
|
||||||
private static final Pattern PATTERN_BEFORE_PATH = Pattern.compile("^https?://[^/]+/?");
|
private static final Pattern PATTERN_BEFORE_PATH = Pattern.compile("^https?://[^/]+");
|
||||||
|
|
||||||
private static final KeyValue URI_NONE = KeyValue.of(LowCardinalityKeyNames.URI, KeyValue.NONE_VALUE);
|
private static final KeyValue URI_NONE = KeyValue.of(LowCardinalityKeyNames.URI, KeyValue.NONE_VALUE);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -88,6 +88,16 @@ class DefaultClientRequestObservationConventionTests {
|
||||||
assertThat(this.observationConvention.getHighCardinalityKeyValues(context)).contains(KeyValue.of("http.url", "https://example.org/resource/42"));
|
assertThat(this.observationConvention.getHighCardinalityKeyValues(context)).contains(KeyValue.of("http.url", "https://example.org/resource/42"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void addsKeyValuesForRequestWithUriTemplateWithoutPath() {
|
||||||
|
ClientRequestObservationContext context = createContext(
|
||||||
|
new MockClientHttpRequest(HttpMethod.GET, "https://example.org"), response);
|
||||||
|
context.setUriTemplate("https://example.org");
|
||||||
|
assertThat(this.observationConvention.getLowCardinalityKeyValues(context))
|
||||||
|
.contains(KeyValue.of("exception", "none"), KeyValue.of("method", "GET"), KeyValue.of("uri", "/"),
|
||||||
|
KeyValue.of("status", "200"), KeyValue.of("client.name", "example.org"), KeyValue.of("outcome", "SUCCESS"));
|
||||||
|
assertThat(this.observationConvention.getHighCardinalityKeyValues(context)).contains(KeyValue.of("http.url", "https://example.org"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void addsKeyValuesForRequestWithoutUriTemplate() {
|
void addsKeyValuesForRequestWithoutUriTemplate() {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class DefaultClientRequestObservationConvention implements ClientRequestO
|
||||||
|
|
||||||
private static final String ROOT_PATH = "/";
|
private static final String ROOT_PATH = "/";
|
||||||
|
|
||||||
private static final Pattern PATTERN_BEFORE_PATH = Pattern.compile("^https?://[^/]+/?");
|
private static final Pattern PATTERN_BEFORE_PATH = Pattern.compile("^https?://[^/]+");
|
||||||
|
|
||||||
private static final KeyValue URI_NONE = KeyValue.of(LowCardinalityKeyNames.URI, KeyValue.NONE_VALUE);
|
private static final KeyValue URI_NONE = KeyValue.of(LowCardinalityKeyNames.URI, KeyValue.NONE_VALUE);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -91,6 +91,19 @@ class DefaultClientRequestObservationConventionTests {
|
||||||
.contains(KeyValue.of("http.url", "/resource/42"));
|
.contains(KeyValue.of("http.url", "/resource/42"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldAddKeyValuesForRequestWithUriTemplateNoPath() {
|
||||||
|
ClientRequest.Builder request = ClientRequest.create(HttpMethod.GET, URI.create("https://example.org"))
|
||||||
|
.attribute(WebClient.class.getName() + ".uriTemplate", "https://example.org");
|
||||||
|
ClientRequestObservationContext context = createContext(request);
|
||||||
|
context.setUriTemplate("https://example.org");
|
||||||
|
assertThat(this.observationConvention.getLowCardinalityKeyValues(context))
|
||||||
|
.contains(KeyValue.of("exception", "none"), KeyValue.of("method", "GET"), KeyValue.of("uri", "/"),
|
||||||
|
KeyValue.of("status", "200"), KeyValue.of("client.name", "example.org"), KeyValue.of("outcome", "SUCCESS"));
|
||||||
|
assertThat(this.observationConvention.getHighCardinalityKeyValues(context)).hasSize(1)
|
||||||
|
.contains(KeyValue.of("http.url", "https://example.org"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldAddKeyValuesForRequestWithoutUriTemplate() {
|
void shouldAddKeyValuesForRequestWithoutUriTemplate() {
|
||||||
ClientRequestObservationContext context = createContext(ClientRequest.create(HttpMethod.GET, URI.create("/resource/42")));
|
ClientRequestObservationContext context = createContext(ClientRequest.create(HttpMethod.GET, URI.create("/resource/42")));
|
||||||
|
|
Loading…
Reference in New Issue