Search in sources :

Example 1 with CamelMetrics

use of org.apache.syncope.common.lib.to.CamelMetrics in project syncope by apache.

the class CamelRouteLogic method metrics.

@PreAuthorize("isAuthenticated()")
public CamelMetrics metrics() {
    CamelMetrics metrics = new CamelMetrics();
    MetricsRegistryService registryService = context.getCamelContext().hasService(MetricsRegistryService.class);
    if (registryService == null) {
        LOG.warn("Camel metrics not available");
    } else {
        MetricRegistry registry = registryService.getMetricsRegistry();
        registry.getTimers().entrySet().stream().map(entry -> {
            CamelMetrics.MeanRate meanRate = new CamelMetrics.MeanRate();
            meanRate.setRouteId(StringUtils.substringBetween(entry.getKey(), ".", "."));
            meanRate.setValue(entry.getValue().getMeanRate());
            return meanRate;
        }).forEachOrdered(meanRate -> {
            metrics.getResponseMeanRates().add(meanRate);
        });
        Collections.sort(metrics.getResponseMeanRates(), (o1, o2) -> Collections.reverseOrder(Comparator.<Double>naturalOrder()).compare(o1.getValue(), o2.getValue()));
    }
    return metrics;
}
Also used : CamelRouteDataBinder(org.apache.syncope.core.provisioning.api.data.CamelRouteDataBinder) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Autowired(org.springframework.beans.factory.annotation.Autowired) ArrayUtils(org.apache.commons.lang3.ArrayUtils) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) MetricsRegistryService(org.apache.camel.component.metrics.routepolicy.MetricsRegistryService) CamelRouteTO(org.apache.syncope.common.lib.to.CamelRouteTO) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) CamelException(org.apache.syncope.core.provisioning.camel.CamelException) ClientExceptionType(org.apache.syncope.common.lib.types.ClientExceptionType) CamelEntitlement(org.apache.syncope.common.lib.types.CamelEntitlement) CamelRouteDAO(org.apache.syncope.core.persistence.api.dao.CamelRouteDAO) Method(java.lang.reflect.Method) MetricRegistry(com.codahale.metrics.MetricRegistry) CamelMetrics(org.apache.syncope.common.lib.to.CamelMetrics) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) CamelRoute(org.apache.syncope.core.persistence.api.entity.CamelRoute) List(java.util.List) Component(org.springframework.stereotype.Component) SyncopeCamelContext(org.apache.syncope.core.provisioning.camel.SyncopeCamelContext) Comparator(java.util.Comparator) Collections(java.util.Collections) Transactional(org.springframework.transaction.annotation.Transactional) CamelMetrics(org.apache.syncope.common.lib.to.CamelMetrics) MetricRegistry(com.codahale.metrics.MetricRegistry) MetricsRegistryService(org.apache.camel.component.metrics.routepolicy.MetricsRegistryService) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 List (java.util.List)1 MetricsRegistryService (org.apache.camel.component.metrics.routepolicy.MetricsRegistryService)1 ArrayUtils (org.apache.commons.lang3.ArrayUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1 CamelMetrics (org.apache.syncope.common.lib.to.CamelMetrics)1 CamelRouteTO (org.apache.syncope.common.lib.to.CamelRouteTO)1 AnyTypeKind (org.apache.syncope.common.lib.types.AnyTypeKind)1 CamelEntitlement (org.apache.syncope.common.lib.types.CamelEntitlement)1 ClientExceptionType (org.apache.syncope.common.lib.types.ClientExceptionType)1 CamelRouteDAO (org.apache.syncope.core.persistence.api.dao.CamelRouteDAO)1 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)1 CamelRoute (org.apache.syncope.core.persistence.api.entity.CamelRoute)1 CamelRouteDataBinder (org.apache.syncope.core.provisioning.api.data.CamelRouteDataBinder)1 CamelException (org.apache.syncope.core.provisioning.camel.CamelException)1