Search in sources :

Example 21 with ReadOperation

use of org.springframework.boot.actuate.endpoint.annotation.ReadOperation in project spring-boot by spring-projects.

the class ConditionsReportEndpoint method applicationConditionEvaluation.

@ReadOperation
public ApplicationConditionEvaluation applicationConditionEvaluation() {
    Map<String, ContextConditionEvaluation> contextConditionEvaluations = new HashMap<>();
    ConfigurableApplicationContext target = this.context;
    while (target != null) {
        contextConditionEvaluations.put(target.getId(), new ContextConditionEvaluation(target));
        target = getConfigurableParent(target);
    }
    return new ApplicationConditionEvaluation(contextConditionEvaluations);
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation)

Example 22 with ReadOperation

use of org.springframework.boot.actuate.endpoint.annotation.ReadOperation in project spring-boot by spring-projects.

the class LiquibaseEndpoint method liquibaseBeans.

@ReadOperation
public ApplicationLiquibaseBeans liquibaseBeans() {
    ApplicationContext target = this.context;
    Map<String, ContextLiquibaseBeans> contextBeans = new HashMap<>();
    while (target != null) {
        Map<String, LiquibaseBean> liquibaseBeans = new HashMap<>();
        DatabaseFactory factory = DatabaseFactory.getInstance();
        target.getBeansOfType(SpringLiquibase.class).forEach((name, liquibase) -> liquibaseBeans.put(name, createReport(liquibase, factory)));
        ApplicationContext parent = target.getParent();
        contextBeans.put(target.getId(), new ContextLiquibaseBeans(liquibaseBeans, (parent != null) ? parent.getId() : null));
        target = parent;
    }
    return new ApplicationLiquibaseBeans(contextBeans);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) HashMap(java.util.HashMap) DatabaseFactory(liquibase.database.DatabaseFactory) SpringLiquibase(liquibase.integration.spring.SpringLiquibase) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation)

Example 23 with ReadOperation

use of org.springframework.boot.actuate.endpoint.annotation.ReadOperation 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);
    }
}
Also used : StringWriter(java.io.StringWriter) WebEndpointResponse(org.springframework.boot.actuate.endpoint.web.WebEndpointResponse) MetricFamilySamples(io.prometheus.client.Collector.MetricFamilySamples) IOException(java.io.IOException) StringWriter(java.io.StringWriter) Writer(java.io.Writer) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation)

Example 24 with ReadOperation

use of org.springframework.boot.actuate.endpoint.annotation.ReadOperation in project spring-boot by spring-projects.

the class BeansEndpoint method beans.

@ReadOperation
public ApplicationBeans beans() {
    Map<String, ContextBeans> contexts = new HashMap<>();
    ConfigurableApplicationContext context = this.context;
    while (context != null) {
        contexts.put(context.getId(), ContextBeans.describing(context));
        context = getConfigurableParent(context);
    }
    return new ApplicationBeans(contexts);
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) HashMap(java.util.HashMap) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation)

Example 25 with ReadOperation

use of org.springframework.boot.actuate.endpoint.annotation.ReadOperation 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);
    }
}
Also used : WebEndpointResponse(org.springframework.boot.actuate.endpoint.web.WebEndpointResponse) CacheEntry(org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntry) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation)

Aggregations

ReadOperation (org.springframework.boot.actuate.endpoint.annotation.ReadOperation)27 Operation (io.swagger.v3.oas.annotations.Operation)14 lombok.val (lombok.val)14 HashMap (java.util.HashMap)10 LinkedHashMap (java.util.LinkedHashMap)10 Map (java.util.Map)9 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)9 BaseCasActuatorEndpoint (org.apereo.cas.web.BaseCasActuatorEndpoint)9 Endpoint (org.springframework.boot.actuate.endpoint.annotation.Endpoint)9 Parameter (io.swagger.v3.oas.annotations.Parameter)8 StringUtils (org.apache.commons.lang3.StringUtils)8 Nullable (org.springframework.lang.Nullable)6 ApplicationContext (org.springframework.context.ApplicationContext)5 Collectors (java.util.stream.Collectors)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Objects (java.util.Objects)3 StreamSupport (java.util.stream.StreamSupport)3 Slf4j (lombok.extern.slf4j.Slf4j)3 CollectionUtils (org.apereo.cas.util.CollectionUtils)3