当前位置: 首页>>代码示例>>Java>>正文


Java ScheduledReporter.report方法代码示例

本文整理汇总了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();
}
 
开发者ID:signalfx,项目名称:signalfx-java,代码行数:24,代码来源:BasicJvmMetrisTest.java

示例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();
    }
}
 
开发者ID:apache,项目名称:incubator-omid,代码行数:9,代码来源:CodahaleMetricsProvider.java

示例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);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:36,代码来源:DatadogMetricFilterTest.java

示例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);
}
 
开发者ID:pravega,项目名称:pravega,代码行数:15,代码来源:StatsProviderImpl.java

示例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");
    }
}
 
开发者ID:iZettle,项目名称:dropwizard-metrics-influxdb,代码行数:37,代码来源:SendToLocalInfluxDB.java

示例6: shutdown

import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
public void shutdown() {

        cluster.close();
        for (ScheduledReporter reporter : reporters) {
            reporter.report();
            reporter.stop();
        }
    }
 
开发者ID:jshook,项目名称:testclient,代码行数:9,代码来源:ExecutionContext.java

示例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");
	}
}
 
开发者ID:davidB,项目名称:metrics-influxdb,代码行数:33,代码来源:SendToLocalInfluxDB.java

示例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);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:61,代码来源:DatadogMetricFilterTest.java

示例9: triggerMetricReporting

import com.codahale.metrics.ScheduledReporter; //导入方法依赖的package包/类
/**
 * Immediately trigger metric reporting.
 */
public void triggerMetricReporting() {
  for(ScheduledReporter reporter : this.scheduledReporters) {
    reporter.report();
  }
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:9,代码来源:GobblinMetrics.java

示例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();
  }
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:10,代码来源:MetricContext.java

示例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));
}
 
开发者ID:jdamick,项目名称:dropwizard-metrics-cloudwatch,代码行数:44,代码来源:CloudWatchReporterFactoryTest.java

示例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");
	}
}
 
开发者ID:davidB,项目名称:metrics-influxdb,代码行数:42,代码来源:SendToLocalInfluxDB_V09.java


注:本文中的com.codahale.metrics.ScheduledReporter.report方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。