Search in sources :

Example 1 with Meter

use of com.yammer.metrics.core.Meter in project bagheera by mozilla-metrics.

the class HttpMetric method updateRequestMetrics.

public void updateRequestMetrics(String method, int contentSize) {
    requests.mark();
    throughput.mark(contentSize);
    if (methods.containsKey(method)) {
        methods.get(method).mark();
    } else {
        Meter methodMeter = Metrics.newMeter(new MetricName(DEFAULT_GROUP, DEFAULT_TYPE, this.id + ".method." + method), "requests", TimeUnit.SECONDS);
        methodMeter.mark();
        methods.put(method, methodMeter);
    }
}
Also used : MetricName(com.yammer.metrics.core.MetricName) Meter(com.yammer.metrics.core.Meter)

Example 2 with Meter

use of com.yammer.metrics.core.Meter in project netty by netty.

the class NioUdtMessageRendezvousChannelTest method basicEcho.

/**
 * verify basic echo message rendezvous
 *
 * FIXME: Re-enable after making it pass on Windows without unncessary tight loop.
 *        https://github.com/netty/netty/issues/2853
 */
@Test
@Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
@Disabled
public void basicEcho() throws Exception {
    final int messageSize = 64 * 1024;
    final int transferLimit = messageSize * 16;
    final Meter rate1 = Metrics.newMeter(NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes", TimeUnit.SECONDS);
    final Meter rate2 = Metrics.newMeter(NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes", TimeUnit.SECONDS);
    final InetSocketAddress addr1 = UnitHelp.localSocketAddress();
    final InetSocketAddress addr2 = UnitHelp.localSocketAddress();
    final EchoMessageHandler handler1 = new EchoMessageHandler(rate1, messageSize);
    final EchoMessageHandler handler2 = new EchoMessageHandler(rate2, messageSize);
    final NioEventLoopGroup group1 = new NioEventLoopGroup(1, Executors.defaultThreadFactory(), NioUdtProvider.MESSAGE_PROVIDER);
    final NioEventLoopGroup group2 = new NioEventLoopGroup(1, Executors.defaultThreadFactory(), NioUdtProvider.MESSAGE_PROVIDER);
    final Bootstrap boot1 = new Bootstrap();
    boot1.group(group1).channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS).localAddress(addr1).remoteAddress(addr2).handler(handler1);
    final Bootstrap boot2 = new Bootstrap();
    boot2.group(group2).channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS).localAddress(addr2).remoteAddress(addr1).handler(handler2);
    final ChannelFuture connectFuture1 = boot1.connect();
    final ChannelFuture connectFuture2 = boot2.connect();
    while (handler1.meter().count() < transferLimit && handler2.meter().count() < transferLimit) {
        log.info("progress : {} {}", handler1.meter().count(), handler2.meter().count());
        Thread.sleep(1000);
    }
    connectFuture1.channel().close().sync();
    connectFuture2.channel().close().sync();
    log.info("handler1 : {}", handler1.meter().count());
    log.info("handler2 : {}", handler2.meter().count());
    assertTrue(handler1.meter().count() >= transferLimit);
    assertTrue(handler2.meter().count() >= transferLimit);
    assertEquals(handler1.meter().count(), handler2.meter().count());
    group1.shutdownGracefully();
    group2.shutdownGracefully();
    group1.terminationFuture().sync();
    group2.terminationFuture().sync();
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) Meter(com.yammer.metrics.core.Meter) InetSocketAddress(java.net.InetSocketAddress) EchoMessageHandler(io.netty.test.udt.util.EchoMessageHandler) Bootstrap(io.netty.bootstrap.Bootstrap) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout) Disabled(org.junit.jupiter.api.Disabled)

Example 3 with Meter

use of com.yammer.metrics.core.Meter in project java by wavefrontHQ.

the class WavefrontYammerMetricsReporterTest method testPlainMeter.

@Test(timeout = 1000)
public void testPlainMeter() throws Exception {
    Meter meter = metricsRegistry.newMeter(WavefrontYammerMetricsReporterTest.class, "mymeter", "requests", TimeUnit.SECONDS);
    meter.mark(42);
    wavefrontYammerMetricsReporter.run();
    assertThat(receiveFromSocket(5, fromMetrics), containsInAnyOrder(equalTo("\"mymeter.count\" 42.0 1485224035"), startsWith("\"mymeter.mean\""), startsWith("\"mymeter.m1\""), startsWith("\"mymeter.m5\""), startsWith("\"mymeter.m15\"")));
}
Also used : Meter(com.yammer.metrics.core.Meter) Test(org.junit.Test)

Example 4 with Meter

use of com.yammer.metrics.core.Meter in project netty by netty.

the class NioUdtByteRendezvousChannelTest method basicEcho.

/**
 * verify basic echo byte rendezvous
 */
@Test
@Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void basicEcho() throws Exception {
    final int messageSize = 64 * 1024;
    final int transferLimit = messageSize * 16;
    final Meter rate1 = Metrics.newMeter(NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes", TimeUnit.SECONDS);
    final Meter rate2 = Metrics.newMeter(NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes", TimeUnit.SECONDS);
    final InetSocketAddress addr1 = UnitHelp.localSocketAddress();
    final InetSocketAddress addr2 = UnitHelp.localSocketAddress();
    final EchoByteHandler handler1 = new EchoByteHandler(rate1, messageSize);
    final EchoByteHandler handler2 = new EchoByteHandler(rate2, messageSize);
    final NioEventLoopGroup group1 = new NioEventLoopGroup(1, Executors.defaultThreadFactory(), NioUdtProvider.BYTE_PROVIDER);
    final NioEventLoopGroup group2 = new NioEventLoopGroup(1, Executors.defaultThreadFactory(), NioUdtProvider.BYTE_PROVIDER);
    final Bootstrap boot1 = new Bootstrap();
    boot1.group(group1).channelFactory(NioUdtProvider.BYTE_RENDEZVOUS).localAddress(addr1).remoteAddress(addr2).handler(handler1);
    final Bootstrap boot2 = new Bootstrap();
    boot2.group(group1).channelFactory(NioUdtProvider.BYTE_RENDEZVOUS).localAddress(addr2).remoteAddress(addr1).handler(handler2);
    final ChannelFuture connectFuture1 = boot1.connect();
    final ChannelFuture connectFuture2 = boot2.connect();
    while (handler1.meter().count() < transferLimit && handler2.meter().count() < transferLimit) {
        log.info("progress : {} {}", handler1.meter().count(), handler2.meter().count());
        Thread.sleep(1000);
    }
    connectFuture1.channel().close().sync();
    connectFuture2.channel().close().sync();
    log.info("handler1 : {}", handler1.meter().count());
    log.info("handler2 : {}", handler2.meter().count());
    assertTrue(handler1.meter().count() >= transferLimit);
    assertTrue(handler2.meter().count() >= transferLimit);
    assertEquals(handler1.meter().count(), handler2.meter().count());
    group1.shutdownGracefully();
    group2.shutdownGracefully();
    group1.terminationFuture().sync();
    group2.terminationFuture().sync();
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) Meter(com.yammer.metrics.core.Meter) InetSocketAddress(java.net.InetSocketAddress) Bootstrap(io.netty.bootstrap.Bootstrap) EchoByteHandler(io.netty.test.udt.util.EchoByteHandler) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout)

Aggregations

Meter (com.yammer.metrics.core.Meter)4 Bootstrap (io.netty.bootstrap.Bootstrap)2 ChannelFuture (io.netty.channel.ChannelFuture)2 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)2 InetSocketAddress (java.net.InetSocketAddress)2 Test (org.junit.jupiter.api.Test)2 Timeout (org.junit.jupiter.api.Timeout)2 MetricName (com.yammer.metrics.core.MetricName)1 EchoByteHandler (io.netty.test.udt.util.EchoByteHandler)1 EchoMessageHandler (io.netty.test.udt.util.EchoMessageHandler)1 Test (org.junit.Test)1 Disabled (org.junit.jupiter.api.Disabled)1