|
|
@ -57,7 +57,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
|
|
|
|
@SuppressWarnings({ "deprecation", "removal" })
|
|
|
|
@SuppressWarnings({ "deprecation", "removal" })
|
|
|
|
class RestTemplateObservationConfigurationTests {
|
|
|
|
class RestTemplateObservationConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().with(MetricsRun.simple())
|
|
|
|
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
|
|
|
.withBean(ObservationRegistry.class, TestObservationRegistry::create)
|
|
|
|
.withBean(ObservationRegistry.class, TestObservationRegistry::create)
|
|
|
|
.withConfiguration(AutoConfigurations.of(ObservationAutoConfiguration.class,
|
|
|
|
.withConfiguration(AutoConfigurations.of(ObservationAutoConfiguration.class,
|
|
|
|
RestTemplateAutoConfiguration.class, HttpClientObservationsAutoConfiguration.class));
|
|
|
|
RestTemplateAutoConfiguration.class, HttpClientObservationsAutoConfiguration.class));
|
|
|
@ -118,22 +118,23 @@ class RestTemplateObservationConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void afterMaxUrisReachedFurtherUrisAreDenied(CapturedOutput output) {
|
|
|
|
void afterMaxUrisReachedFurtherUrisAreDenied(CapturedOutput output) {
|
|
|
|
this.contextRunner.withPropertyValues("management.metrics.web.client.max-uri-tags=2").run((context) -> {
|
|
|
|
this.contextRunner.with(MetricsRun.simple()).withPropertyValues("management.metrics.web.client.max-uri-tags=2")
|
|
|
|
|
|
|
|
.run((context) -> {
|
|
|
|
RestTemplate restTemplate = context.getBean(RestTemplateBuilder.class).build();
|
|
|
|
|
|
|
|
MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate);
|
|
|
|
RestTemplate restTemplate = context.getBean(RestTemplateBuilder.class).build();
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate);
|
|
|
|
server.expect(requestTo("/test/" + i)).andRespond(withStatus(HttpStatus.OK));
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
}
|
|
|
|
server.expect(requestTo("/test/" + i)).andRespond(withStatus(HttpStatus.OK));
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
}
|
|
|
|
restTemplate.getForObject("/test/" + i, String.class);
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
}
|
|
|
|
restTemplate.getForObject("/test/" + i, String.class);
|
|
|
|
TestObservationRegistry registry = context.getBean(TestObservationRegistry.class);
|
|
|
|
}
|
|
|
|
TestObservationRegistryAssert.assertThat(registry);
|
|
|
|
TestObservationRegistry registry = context.getBean(TestObservationRegistry.class);
|
|
|
|
// TODO: check observation count for name
|
|
|
|
TestObservationRegistryAssert.assertThat(registry);
|
|
|
|
assertThat(output).contains("Reached the maximum number of URI tags for 'http.client.requests'.")
|
|
|
|
// TODO: check observation count for name
|
|
|
|
.contains("Are you using 'uriVariables'?");
|
|
|
|
assertThat(output).contains("Reached the maximum number of URI tags for 'http.client.requests'.")
|
|
|
|
});
|
|
|
|
.contains("Are you using 'uriVariables'?");
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|