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));
}
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));
}
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);
}
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);
}
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);
}
Aggregations