MetricRegistry getConsolidatedRegistry()

in src/main/java/org/apache/sling/commons/metrics/internal/MetricWebConsolePlugin.java [427:444]


    MetricRegistry getConsolidatedRegistry() {
        MetricRegistry registry = new MetricRegistry();
        for (Map.Entry<ServiceReference, MetricRegistry> registryEntry : registries.entrySet()){
            String metricRegistryName = (String) registryEntry.getKey().getProperty(METRIC_REGISTRY_NAME);
            for (Map.Entry<String, Metric> metricEntry : registryEntry.getValue().getMetrics().entrySet()){
                String metricName = metricEntry.getKey();
                try{
                    if (metricRegistryName != null){
                        metricName = metricRegistryName + ":" + metricName;
                    }
                    registry.register(metricName, metricEntry.getValue());
                }catch (IllegalArgumentException ex){
                    log.warn("Duplicate Metric name found {}", metricName, ex);
                }
            }
        }
        return registry;
    }