use of org.springframework.boot.actuate.endpoint.web.WebEndpointResponse in project spring-boot by spring-projects.
the class PrometheusScrapeEndpoint method scrape.
@ReadOperation(producesFrom = TextOutputFormat.class)
public WebEndpointResponse<String> scrape(TextOutputFormat format, @Nullable Set<String> includedNames) {
try {
Writer writer = new StringWriter();
Enumeration<MetricFamilySamples> samples = (includedNames != null) ? this.collectorRegistry.filteredMetricFamilySamples(includedNames) : this.collectorRegistry.metricFamilySamples();
format.write(writer, samples);
return new WebEndpointResponse<>(writer.toString(), format);
} catch (IOException ex) {
// This actually never happens since StringWriter doesn't throw an IOException
throw new IllegalStateException("Writing metrics failed", ex);
}
}
use of org.springframework.boot.actuate.endpoint.web.WebEndpointResponse in project spring-boot by spring-projects.
the class CachesEndpointWebExtension method cache.
@ReadOperation
public WebEndpointResponse<CacheEntry> cache(@Selector String cache, @Nullable String cacheManager) {
try {
CacheEntry entry = this.delegate.cache(cache, cacheManager);
int status = (entry != null) ? WebEndpointResponse.STATUS_OK : WebEndpointResponse.STATUS_NOT_FOUND;
return new WebEndpointResponse<>(entry, status);
} catch (NonUniqueCacheException ex) {
return new WebEndpointResponse<>(WebEndpointResponse.STATUS_BAD_REQUEST);
}
}
use of org.springframework.boot.actuate.endpoint.web.WebEndpointResponse in project spring-boot by spring-projects.
the class HealthEndpointAutoConfigurationTests method runWhenHasReactiveHealthEndpointWebExtensionBeanDoesNotCreateExtraReactiveHealthEndpointWebExtension.
@Test
void runWhenHasReactiveHealthEndpointWebExtensionBeanDoesNotCreateExtraReactiveHealthEndpointWebExtension() {
this.reactiveContextRunner.withUserConfiguration(ReactiveHealthEndpointWebExtensionConfiguration.class).run((context) -> {
ReactiveHealthEndpointWebExtension webExtension = context.getBean(ReactiveHealthEndpointWebExtension.class);
Mono<WebEndpointResponse<? extends HealthComponent>> response = webExtension.health(ApiVersion.V3, WebServerNamespace.SERVER, SecurityContext.NONE, true, "simple");
assertThat(response).isNull();
});
}
use of org.springframework.boot.actuate.endpoint.web.WebEndpointResponse in project spring-boot by spring-projects.
the class HealthEndpointAutoConfigurationTests method runCreatesReactiveHealthEndpointWebExtension.
@Test
void runCreatesReactiveHealthEndpointWebExtension() {
this.reactiveContextRunner.run((context) -> {
ReactiveHealthEndpointWebExtension webExtension = context.getBean(ReactiveHealthEndpointWebExtension.class);
Mono<WebEndpointResponse<? extends HealthComponent>> response = webExtension.health(ApiVersion.V3, WebServerNamespace.SERVER, SecurityContext.NONE, true, "simple");
Health health = (Health) (response.block().getBody());
assertThat(health.getDetails()).containsEntry("counter", 42);
});
}
Aggregations