Search in sources :

Example 71 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project nifi by apache.

the class MetricsReportingTask method init.

/**
 * Register all wanted metrics to {@link #metricRegistry}.
 * <p>
 * {@inheritDoc}
 */
@Override
protected void init(ReportingInitializationContext config) {
    metricRegistry = new MetricRegistry();
    currentStatusReference = new AtomicReference<>();
    metricRegistry.registerAll(new MemoryUsageGaugeSet());
    metricRegistry.registerAll(new FlowMetricSet(currentStatusReference));
}
Also used : MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) MetricRegistry(com.codahale.metrics.MetricRegistry) FlowMetricSet(org.apache.nifi.metrics.FlowMetricSet)

Example 72 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project nifi by apache.

the class GraphiteMetricReporterServiceTest method setUp.

/**
 * Instantiate the runner and mocks between tests. Register metrics to the {@link #metricRegistryStub}.
 */
@Before
public void setUp() throws Exception {
    runner = TestRunners.newTestRunner(processorDummy);
    testedService = new GraphiteMetricReporterService();
    metricRegistryStub = new MetricRegistry();
    metricRegistryStub.register(TEST_METRIC_NAME, ((Gauge<Integer>) () -> TEST_METRIC_VALUE));
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) Gauge(com.codahale.metrics.Gauge) Before(org.junit.Before)

Example 73 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project nifi by apache.

the class MetricsReportingTaskTest method testValidLifeCycleReportsCorrectly.

/**
 * Make sure that in a single life cycle the correct metrics are registered, the correct {@link ProcessGroupStatus}
 * is used and that metrics are actually reported.
 */
@Test
public void testValidLifeCycleReportsCorrectly() throws Exception {
    reportingContextStub.getEventAccess().setProcessGroupStatus(rootGroupStatus);
    testedReportingTask.initialize(reportingInitContextStub);
    testedReportingTask.connect(configurationContextStub);
    testedReportingTask.onTrigger(reportingContextStub);
    verify(reporterMock).report();
    // Verify correct metrics are registered
    ArgumentCaptor<MetricRegistry> registryCaptor = ArgumentCaptor.forClass(MetricRegistry.class);
    verify(reporterServiceStub).createReporter(registryCaptor.capture());
    MetricRegistry usedRegistry = registryCaptor.getValue();
    Map<String, Metric> usedMetrics = usedRegistry.getMetrics();
    assertTrue(usedMetrics.keySet().containsAll(new MemoryUsageGaugeSet().getMetrics().keySet()));
    assertTrue(usedMetrics.keySet().containsAll(new FlowMetricSet(testedReportingTask.currentStatusReference).getMetrics().keySet()));
    // Verify the most current ProcessGroupStatus is updated
    assertEquals(testedReportingTask.currentStatusReference.get(), rootGroupStatus);
}
Also used : MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) MetricRegistry(com.codahale.metrics.MetricRegistry) Metric(com.codahale.metrics.Metric) FlowMetricSet(org.apache.nifi.metrics.FlowMetricSet) Test(org.junit.Test)

Example 74 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project oxCore by GluuFederation.

the class MetricService method initTimer.

public void initTimer(int metricInterval) {
    this.metricRegistry = new MetricRegistry();
    this.registeredMetricTypes = new HashSet<MetricType>();
    LdapEntryReporter ldapEntryReporter = LdapEntryReporter.forRegistry(this.metricRegistry, getMetricServiceInstance()).build();
    int metricReporterInterval = metricInterval;
    if (metricReporterInterval <= 0) {
        metricReporterInterval = DEFAULT_METRIC_REPORTER_INTERVAL;
    }
    ldapEntryReporter.start(metricReporterInterval, TimeUnit.SECONDS);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) MetricType(org.xdi.model.metric.MetricType)

Example 75 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project indy by Commonjava.

the class ReporterIntializer method initGraphiteReporterForHealthCheckMetric.

private void initGraphiteReporterForHealthCheckMetric(MetricRegistry metrics, IndyMetricsConfig config) {
    final Graphite graphite = new Graphite(new InetSocketAddress(config.getGrphiterHostName(), config.getGrphiterPort()));
    final GraphiteReporter reporter = GraphiteReporter.forRegistry(metrics).prefixedWith(config.getGrphiterPrefix()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter((name, metric) -> {
        if (!name.contains(FILTER_SIMPLE) && name.contains(FILTER_HEALTHCHECK)) {
            return true;
        }
        return false;
    }).build(graphite);
    reporter.start(config.getGrphiterHealthcheckPeriod(), TimeUnit.SECONDS);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) ZabbixCacheStorage(org.commonjava.indy.metrics.zabbix.cache.ZabbixCacheStorage) IndyMetricsConfig(org.commonjava.indy.metrics.conf.IndyMetricsConfig) IndyZabbixSender(org.commonjava.indy.metrics.zabbix.sender.IndyZabbixSender) Graphite(com.codahale.metrics.graphite.Graphite) InetSocketAddress(java.net.InetSocketAddress) IndyHttpProvider(org.commonjava.indy.subsys.http.IndyHttpProvider) Inject(javax.inject.Inject) TimeUnit(java.util.concurrent.TimeUnit) IndyZabbixReporter(org.commonjava.indy.metrics.zabbix.reporter.IndyZabbixReporter) IndyMetricsNamed(org.commonjava.indy.metrics.conf.annotation.IndyMetricsNamed) GraphiteReporter(com.codahale.metrics.graphite.GraphiteReporter) ConsoleReporter(com.codahale.metrics.ConsoleReporter) ApplicationScoped(javax.enterprise.context.ApplicationScoped) InetSocketAddress(java.net.InetSocketAddress) GraphiteReporter(com.codahale.metrics.graphite.GraphiteReporter) Graphite(com.codahale.metrics.graphite.Graphite)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)505 Test (org.junit.Test)177 Before (org.junit.Before)61 Test (org.junit.jupiter.api.Test)45 VerifiableProperties (com.github.ambry.config.VerifiableProperties)42 ArrayList (java.util.ArrayList)33 Counter (com.codahale.metrics.Counter)30 File (java.io.File)29 Properties (java.util.Properties)28 List (java.util.List)23 Metric (com.codahale.metrics.Metric)22 Map (java.util.Map)22 IOException (java.io.IOException)21 HashMap (java.util.HashMap)20 Size (com.github.joschi.jadconfig.util.Size)17 CountDownLatch (java.util.concurrent.CountDownLatch)17 TimeUnit (java.util.concurrent.TimeUnit)17 Timer (com.codahale.metrics.Timer)15 DefaultTaggedMetricRegistry (com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry)15 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)15