本文整理汇总了Java中com.codahale.metrics.ScheduledReporter.report方法的典型用法代码示例。如果您正苦于以下问题:Java ScheduledReporter.report方法的具体用法?Java ScheduledReporter.report怎么用?Java ScheduledReporter.report使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.codahale.metrics.ScheduledReporter
的用法示例。
在下文中一共展示了ScheduledReporter.report方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPointsSent
import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
@Test
public void testPointsSent() throws Exception {
MetricRegistry registry = new MetricRegistry();
new BasicJvmMetrics(registry);
ScheduledReporter reporter = new ScheduledReporter(registry, "test", MetricFilter.ALL,
TimeUnit.SECONDS, TimeUnit.MILLISECONDS) {
@Override
public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
SortedMap<String, Histogram> histograms,
SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) {
Assert.assertFalse(gauges.isEmpty());
Assert.assertNotNull(gauges.get("jvm.uptime"));
for (Map.Entry<String, Gauge> entry : gauges.entrySet()) {
Assert.assertNotNull(entry.getValue().getValue());
}
}
};
reporter.report();
reporter.close();
}
示例2: stopMetrics
import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
@Override
public void stopMetrics() {
for (ScheduledReporter r : reporters) {
r.report();
LOG.info("Stopping reporter {}", r.toString());
r.stop();
}
}
示例3: testExpansionFilterExclusion
import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
@Test
public void testExpansionFilterExclusion() throws Exception {
String json =
"{" +
"\"type\": \"datadogExpansionFiltered\"," +
"\"host\": \"test-host\"," +
"\"excludeExpansions\": [\"min\", \"max\", \"p75\", \"p95\", \"p98\", \"p99\", \"p999\"]," +
"\"transport\": {" +
"\"type\": \"http\"," +
"\"apiKey\": \"12345\"" +
"}" +
"}";
ScheduledReporter reporter = createReporter(json);
// Create a representative type.
Histogram histogram = _metricRegistry.histogram("test.histogram");
histogram.update(1);
histogram.update(2);
histogram.update(3);
reporter.report();
// Verify only the desired metrics were sent. Notably min, max, and the nth percentiles should be absent.
verify(_request).addCounter(argThat(hasCounter("test.histogram.count", 3)));
verify(_request).addGauge(argThat(hasGauge("test.histogram.mean", 2)));
verify(_request).addGauge(argThat(hasGauge("test.histogram.median", 2)));
verify(_request).addGauge(argThat(hasGauge("test.histogram.stddev", 1.0)));
// Send was called exactly once
verify(_request).send();
verifyNoMoreInteractions(_request);
}
示例4: close
import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
@Synchronized
@Override
public void close() {
for (ScheduledReporter r : reporters) {
try {
r.report();
r.stop();
} catch (Exception e) {
log.error("Exception report or stop reporter", e);
}
}
metrics.removeMatching(MetricFilter.ALL);
}
示例5: main
import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
public static void main(String[] args) {
InfluxDbReporter influxDbReporter = null;
ScheduledReporter consoleReporter = null;
Timer.Context context = null;
try {
final MetricRegistry registry = new MetricRegistry();
consoleReporter = startConsoleReporter(registry);
influxDbReporter = startInfluxDbReporter(registry, GetHttpSender());
final Meter myMeter = registry.meter(MetricRegistry.name(SendToLocalInfluxDB.class, "testMetric"));
final Timer myTimer = registry.timer("testTimer");
context = myTimer.time();
for (int i = 0; i < 5000; i++) {
myMeter.mark();
myMeter.mark(Math.round(Math.random() * 100.0));
Thread.sleep(2000);
}
} catch (Exception exc) {
exc.printStackTrace();
System.exit(1);
} finally {
if (context != null) {
context.stop();
}
if (influxDbReporter != null) {
influxDbReporter.report();
influxDbReporter.stop();
}
if (consoleReporter != null) {
consoleReporter.report();
consoleReporter.stop();
}
System.out.println("Finished");
}
}
示例6: shutdown
import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
public void shutdown() {
cluster.close();
for (ScheduledReporter reporter : reporters) {
reporter.report();
reporter.stop();
}
}
示例7: main
import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
public static void main(String[] args) {
ScheduledReporter r0 = null;
ScheduledReporter r1 = null;
try {
final MetricRegistry registry = new MetricRegistry();
r0 = startConsoleReporter(registry);
r1 = startInfluxdbReporter(registry);
registerGaugeWithValues(registry, "double", Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 1);
registerGaugeWithValues(registry, "float", Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, 1);
final Meter mymeter0 = registry.meter("MyMeter.0");
for (int i = 0; i < 100; i++) {
mymeter0.mark();
mymeter0.mark(Math.round(Math.random() * 100.0));
Thread.sleep(Math.round(Math.random() * 1000.0));
}
} catch (Exception exc) {
exc.printStackTrace();
System.exit(1);
} finally {
if (r1 != null) {
r1.report();
r1.stop();
}
if (r0 != null) {
r0.report();
r0.stop();
}
System.out.println("STOP");
}
}
示例8: testExpansionFilterInclusion
import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
@Test
public void testExpansionFilterInclusion() throws Exception {
String json =
"{" +
"\"type\": \"datadogExpansionFiltered\"," +
"\"host\": \"test-host\"," +
"\"includeExpansions\": [\"count\", \"min\", \"max\", \"p95\"]," +
"\"transport\": {" +
"\"type\": \"http\"," +
"\"apiKey\": \"12345\"" +
"}" +
"}";
ScheduledReporter reporter = createReporter(json);
// Create some metrics for each major type
Counter counter = _metricRegistry.counter("test.counter");
counter.inc(10);
Histogram histogram = _metricRegistry.histogram("test.histogram");
histogram.update(1);
histogram.update(2);
histogram.update(3);
Meter meter = _metricRegistry.meter("test.meter");
meter.mark(100);
Timer timer = _metricRegistry.timer("test.timer");
timer.update(1, TimeUnit.SECONDS);
timer.update(2, TimeUnit.SECONDS);
timer.update(3, TimeUnit.SECONDS);
_metricRegistry.register("test.gauge", new Gauge<Integer>() {
@Override
public Integer getValue() {
return 50;
}
});
reporter.report();
// Verify only the desired metrics were sent
verify(_request).addCounter(argThat(hasCounter("test.counter", 10)));
verify(_request).addCounter(argThat(hasCounter("test.histogram.count", 3)));
verify(_request).addGauge(argThat(hasGauge("test.histogram.min", 1)));
verify(_request).addGauge(argThat(hasGauge("test.histogram.max", 3)));
verify(_request).addGauge(argThat(hasGauge("test.histogram.p95", 3.0)));
verify(_request).addCounter(argThat(hasCounter("test.timer.count", 3)));
verify(_request).addGauge(argThat(hasGauge("test.timer.min", 1000f)));
verify(_request).addGauge(argThat(hasGauge("test.timer.max", 3000f)));
verify(_request).addGauge(argThat(hasGauge("test.timer.p95", 3000f)));
verify(_request).addCounter(argThat(hasCounter("test.meter.count", 100)));
verify(_request).addGauge(argThat(hasGauge("test.gauge", 50)));
// Send was called exactly once
verify(_request).send();
verifyNoMoreInteractions(_request);
}
示例9: triggerMetricReporting
import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
/**
* Immediately trigger metric reporting.
*/
public void triggerMetricReporting() {
for(ScheduledReporter reporter : this.scheduledReporters) {
reporter.report();
}
}
示例10: reportMetrics
import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
/**
* Call the {@link com.codahale.metrics.ScheduledReporter#report} method of the
* {@link com.codahale.metrics.ScheduledReporter}s associated with this {@link MetricContext}.
*/
public void reportMetrics() {
for (ScheduledReporter reporter : this.contextAwareScheduledReporters.values()) {
reporter.report();
}
}
示例11: verifySendingToCloudWatch
import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
@Test
public void verifySendingToCloudWatch() throws Exception {
CloudWatchReporterFactory factory = new CloudWatchReporterFactory();
MetricRegistry registry = new MetricRegistry();
Counter counter = registry.counter(MetricRegistry.name(this.getClass(), "test machine=123*"));
AmazonCloudWatchAsync mockClient = mock(AmazonCloudWatchAsync.class);
final Future<Void> mockFuture = mock(Future.class);
when(mockClient.putMetricDataAsync(any(PutMetricDataRequest.class))).thenReturn(mockFuture);
when(mockClient.putMetricDataAsync(any(PutMetricDataRequest.class))).thenAnswer(new Answer<Future>() {
@Override
public Future answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
if (args.length > 0 && args[0] != null) {
PutMetricDataRequest req = (PutMetricDataRequest) args[0];
assertEquals(req.getNamespace(), "myspace");
for (MetricDatum datum : req.getMetricData()) {
System.out.println(datum.toString());
assertTrue(datum.toString().contains("env"));
}
}
return mockFuture;
}
});
factory.setClient(mockClient);
factory.setAwsAccessKeyId("fakeKey");
factory.setAwsSecretKey("fakeSecret");
factory.setNamespace("myspace");
factory.setGlobalDimensions(Lists.newArrayList("env=dev"));
ScheduledReporter reporter = factory.build(registry);
for (int i = 0; i < 200; i++) {
counter.inc();
}
reporter.report();
verify(mockClient.putMetricDataAsync(any(PutMetricDataRequest.class)), times(1));
}
示例12: main
import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
public static void main(String[] args) {
ScheduledReporter r0 = null;
ScheduledReporter r1 = null;
ScheduledReporter r2 = null;
try {
final MetricRegistry registry = new MetricRegistry();
r0 = startConsoleReporter(registry);
r1 = startInfluxdbReporterHttpV09(registry);
r2 = startInfluxdbReporterUDPV09(registry);
// TODO what to do with NaN & infinity
registerGaugeWithValues(registry, "integer", Integer.MIN_VALUE, Integer.MAX_VALUE, 1);
registerGaugeWithValues(registry, "long", Long.MIN_VALUE, Long.MAX_VALUE, 1l);
registerGaugeWithValues(registry, "double", Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0d);
registerGaugeWithValues(registry, "float", Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, 1.0f);
final Meter mymeter0 = registry.meter("MyMeter.0");
for (int i = 0; i < 100; i++) {
mymeter0.mark();
mymeter0.mark(Math.round(Math.random() * 100.0));
Thread.sleep(Math.round(Math.random() * 1000.0));
}
} catch (Exception exc) {
exc.printStackTrace();
System.exit(1);
} finally {
if (r2 != null) {
r2.report();
r2.stop();
}
if (r1 != null) {
r1.report();
r1.stop();
}
if (r0 != null) {
r0.report();
r0.stop();
}
System.out.println("STOP");
}
}