com.yammer.metrics.core.Meter Java Examples

The following examples show how to use com.yammer.metrics.core.Meter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HBaseIndexerMapper.java    From hbase-indexer with Apache License 2.0 6 votes vote down vote up
private void copyIndexingMetricsToCounters(Context context) {
    final String COUNTER_GROUP = "HBase Indexer Metrics";
    SortedMap<String, SortedMap<MetricName, Metric>> groupedMetrics = Metrics.defaultRegistry().groupedMetrics(
            new IndexerMetricsUtil.IndexerMetricPredicate());
    for (Entry<String, SortedMap<MetricName, Metric>> metricsGroupEntry : groupedMetrics.entrySet()) {
        SortedMap<MetricName, Metric> metricsGroupMap = metricsGroupEntry.getValue();
        for (Entry<MetricName, Metric> metricEntry : metricsGroupMap.entrySet()) {
            MetricName metricName = metricEntry.getKey();
            Metric metric = metricEntry.getValue();
            String counterName = metricName.getType() + ": " + metricName.getName();
            if (metric instanceof Counter) {
                Counter counter = (Counter) metric;
                context.getCounter(COUNTER_GROUP, counterName).increment(counter.count());
            } else if (metric instanceof Meter) {
                Meter meter = (Meter) metric;
                context.getCounter(COUNTER_GROUP, counterName).increment(meter.count());
            } else if (metric instanceof Timer) {
                Timer timer = (Timer) metric;
                context.getCounter(COUNTER_GROUP, counterName).increment((long) timer.sum());
            }
        }
    }
}
 
Example #2
Source File: HdfsDirectory.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
protected MetricsGroup createNewMetricsGroup(String scope) {
  MetricName readRandomAccessName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Random Latency in \u00B5s", scope);
  MetricName readStreamAccessName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Stream Latency in \u00B5s", scope);
  MetricName writeAcccessName = new MetricName(ORG_APACHE_BLUR, HDFS, "Write Latency in \u00B5s", scope);
  MetricName readRandomThroughputName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Random Throughput", scope);
  MetricName readStreamThroughputName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Stream Throughput", scope);
  MetricName readSeekName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Stream Seeks", scope);
  MetricName writeThroughputName = new MetricName(ORG_APACHE_BLUR, HDFS, "Write Throughput", scope);
  MetricName totalHdfsBlocks = new MetricName(ORG_APACHE_BLUR, HDFS, "Hdfs Blocks Total", scope);
  MetricName localHdfsBlocks = new MetricName(ORG_APACHE_BLUR, HDFS, "Hdfs Blocks Local", scope);

  Histogram readRandomAccess = Metrics.newHistogram(readRandomAccessName);
  Histogram readStreamAccess = Metrics.newHistogram(readStreamAccessName);
  Histogram writeAccess = Metrics.newHistogram(writeAcccessName);
  Meter readRandomThroughput = Metrics.newMeter(readRandomThroughputName, "Read Random Bytes", TimeUnit.SECONDS);
  Meter readStreamThroughput = Metrics.newMeter(readStreamThroughputName, "Read Stream Bytes", TimeUnit.SECONDS);
  Meter readStreamSeek = Metrics.newMeter(readSeekName, "Read Stream Seeks", TimeUnit.SECONDS);
  Meter writeThroughput = Metrics.newMeter(writeThroughputName, "Write Bytes", TimeUnit.SECONDS);
  Counter totalHdfsBlock = Metrics.newCounter(totalHdfsBlocks);
  Counter localHdfsBlock = Metrics.newCounter(localHdfsBlocks);

  return new MetricsGroup(readRandomAccess, readStreamAccess, writeAccess, readRandomThroughput,
      readStreamThroughput, readStreamSeek, writeThroughput, totalHdfsBlock, localHdfsBlock);
}
 
Example #3
Source File: IndexManager.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
public SimpleQueryParallelCall(AtomicBoolean running, String table, QueryStatus status, Query query,
    Selector selector, Meter queriesInternalMeter, ShardServerContext shardServerContext, boolean runSlow,
    int fetchCount, int maxHeapPerRowFetch, Similarity similarity, TableContext context, Sort sort,
    DeepPagingCache deepPagingCache, MemoryAllocationWatcher memoryAllocationWatcher) {
  _running = running;
  _table = table;
  _status = status;
  _query = query;
  _selector = selector;
  _queriesInternalMeter = queriesInternalMeter;
  _shardServerContext = shardServerContext;
  _runSlow = runSlow;
  _fetchCount = fetchCount;
  _maxHeapPerRowFetch = maxHeapPerRowFetch;
  _similarity = similarity;
  _context = context;
  _sort = sort;
  _deepPagingCache = deepPagingCache;
  _memoryAllocationWatcher = memoryAllocationWatcher;
}
 
Example #4
Source File: ScheduledReporterTest.java    From ambari-metrics with Apache License 2.0 6 votes vote down vote up
private Set<Entry<MetricName, Metric>> set(List<Metric> metrics) {
  final Map<MetricName, Metric> map = new HashMap<MetricName, Metric>();
  for (Metric metric : metrics) {
    String name = null;
    if (metric instanceof Gauge) {
      name = "gauge";
    } else if (metric instanceof Counter) {
      name = "counter";
    } else if (metric instanceof Histogram) {
      name = "histogram";
    } else if (metric instanceof Meter) {
      name = "meter";
    } else if (metric instanceof Timer) {
      name = "timer";
    }
    map.put(new MetricName(System.class, name), metric);
  }
  return map.entrySet();
}
 
Example #5
Source File: MeterPool.java    From common-kafka with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the meter corresponding to the given scope.
 *
 * @param scope The scope of the meter to return.
 *
 * @return a {@link Meter} with the given scope.
 *
 * @throws IllegalArgumentException
 *             if {@code scope} is {@code null}.
 */
public Meter getMeter(String scope) {
    if (scope == null) {
        throw new IllegalArgumentException("scope cannot be null");
    }
    Meter meter = meters.get(scope);
    if (meter == null) {
        meter = Metrics.newMeter(clazz, name, scope, name, TimeUnit.SECONDS);
        Meter existing = meters.putIfAbsent(scope, meter);
        if (existing != null) {
            meter = existing;
        }
    }
    return meter;
}
 
Example #6
Source File: EchoMessageHandler.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
public EchoMessageHandler(final Meter meter, final int messageSize) {
    this.meter = meter;

    final ByteBuf byteBuf = Unpooled.buffer(messageSize);

    for (int i = 0; i < byteBuf.capacity(); i++) {
        byteBuf.writeByte((byte) i);
    }

    message = new UdtMessage(byteBuf);
}
 
Example #7
Source File: StatsDReporterTest.java    From kafka-statsd-metrics2 with Apache License 2.0 5 votes vote down vote up
@Test
public final void meter() throws Exception {
  addMetricAndRunReporter(
      new Callable<Meter>() {
        @Override
        public Meter call() throws Exception {
          return createMeter();
        }
      });
  verifyMeter();
}
 
Example #8
Source File: StatsDReporterTest.java    From kafka-statsd-metrics2 with Apache License 2.0 5 votes vote down vote up
static Meter createMeter() throws Exception {
  final Meter mock = mock(Meter.class);
  setupMeteredMock(mock);
  return configureMatcher(mock, doAnswer(new MetricsProcessorAction() {
    @Override
    void delegateToProcessor(MetricProcessor<Object> processor, MetricName name, Object context) throws Exception {
      processor.processMeter(name, mock, context);
    }
  }));
}
 
Example #9
Source File: MeterWrapper.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
public static MeterWrapper wrap(final Meter meter) {
  return wrap(new SimpleMeter() {
    @Override
    public void mark(long l) {
      meter.mark(l);
    }
  });
}
 
Example #10
Source File: MeterPoolTest.java    From common-kafka with Apache License 2.0 5 votes vote down vote up
@Test
public void getMeterDifferentScope() {
    MeterPool pool = new MeterPool(Object.class, "name");

    Meter meter1 = pool.getMeter("scope1");
    Meter meter2 = pool.getMeter("scope2");

    assertThat(meter1, is(not(equalTo(meter2))));
}
 
Example #11
Source File: MeterPoolTest.java    From common-kafka with Apache License 2.0 5 votes vote down vote up
@Test
public void getMeterSameScope() {
    MeterPool pool = new MeterPool(Object.class, "name");

    Meter meter1 = pool.getMeter("scope");
    Meter meter2 = pool.getMeter("scope");

    assertSame(meter1, meter2);
}
 
Example #12
Source File: MeterPool.java    From common-kafka with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a pool for meters.
 *
 * @param clazz The class that owns the meter.
 * @param name The name of the meter.
 *
 * @throws IllegalArgumentException
 *             if any argument is {@code null}.
 */
public MeterPool(Class<?> clazz, String name) {
    if (clazz == null) {
        throw new IllegalArgumentException("class cannot be null");
    }
    if (name == null) {
        throw new IllegalArgumentException("name cannot be null");
    }
    this.clazz = clazz;
    this.name = name;
    this.meters = new ConcurrentHashMap<String, Meter>();
}
 
Example #13
Source File: ScheduledReporterTest.java    From ambari-metrics with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
  Gauge g = registry.newGauge(System.class, "gauge", gauge);
  Counter counter = registry.newCounter(System.class, "counter");
  Histogram histogram = registry.newHistogram(System.class, "histogram");
  Meter meter = registry.newMeter(System.class, "meter", "empty", TimeUnit.MILLISECONDS);
  Timer timer = registry.newTimer(System.class, "timer");
  list.add(g);
  list.add(counter);
  list.add(histogram);
  list.add(meter);
  list.add(timer);
  reporter.start(200, TimeUnit.MILLISECONDS);
}
 
Example #14
Source File: KafkaTimelineMetricsReporterTest.java    From ambari-metrics with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  @SuppressWarnings({ "rawtypes", "unchecked" })
  Gauge g = registry.newGauge(System.class, "gauge", gauge);
  Counter counter = registry.newCounter(System.class, "counter");
  Histogram histogram = registry.newHistogram(System.class, "histogram");
  Meter meter = registry.newMeter(System.class, "meter", "empty", TimeUnit.MILLISECONDS);
  Timer timer = registry.newTimer(System.class, "timer");
  list.add(g);
  list.add(counter);
  list.add(histogram);
  list.add(meter);
  list.add(timer);
  Properties properties = new Properties();
  properties.setProperty("zookeeper.connect", "localhost:2181");
  properties.setProperty("kafka.timeline.metrics.sendInterval", "5900");
  properties.setProperty("kafka.timeline.metrics.maxRowCacheSize", "10000");
  properties.setProperty("kafka.timeline.metrics.hosts", "localhost:6188");
  properties.setProperty("kafka.timeline.metrics.port", "6188");
  properties.setProperty("kafka.timeline.metrics.reporter.enabled", "true");
  properties.setProperty("external.kafka.metrics.exclude.prefix", "a.b.c");
  properties.setProperty("external.kafka.metrics.include.prefix", "a.b.c.d");
  properties.setProperty("external.kafka.metrics.include.regex", "a.b.c.*.f");
  properties.setProperty("kafka.timeline.metrics.instanceId", "cluster");
  properties.setProperty("kafka.timeline.metrics.set.instanceId", "false");
  props = new VerifiableProperties(properties);
}
 
Example #15
Source File: BufferStore.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
private static BlockingQueue<byte[]> setupBuffers(int bufferSize, int count, Meter meter) {
  BlockingQueue<byte[]> queue = new ArrayBlockingQueue<byte[]>(count);
  for (int i = 0; i < count; i++) {
    meter.mark();
    queue.add(new byte[bufferSize]);
  }
  return queue;
}
 
Example #16
Source File: MetricsGroup.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
MetricsGroup(Histogram readRandomAccess, Histogram readStreamAccess, Histogram writeAccess,
    Meter readRandomThroughput, Meter readStreamThroughput, Meter readStreamSeek, Meter writeThroughput,
    Counter totalHdfsBlock, Counter localHdfsBlock) {
  this.readRandomAccess = readRandomAccess;
  this.readStreamAccess = readStreamAccess;
  this.writeAccess = writeAccess;
  this.readRandomThroughput = readRandomThroughput;
  this.readStreamThroughput = readStreamThroughput;
  this.writeThroughput = writeThroughput;
  this.readStreamSeek = readStreamSeek;
  this.totalHdfsBlock = totalHdfsBlock;
  this.localHdfsBlock = localHdfsBlock;
}
 
Example #17
Source File: EchoMessageHandler.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
public EchoMessageHandler(final Meter meter, final int messageSize) {
    this.meter = meter;

    final ByteBuf byteBuf = Unpooled.buffer(messageSize);

    for (int i = 0; i < byteBuf.capacity(); i++) {
        byteBuf.writeByte((byte) i);
    }

    message = new UdtMessage(byteBuf);
}
 
Example #18
Source File: NioUdtByteRendezvousChannelTest.java    From netty4.0.27Learn with Apache License 2.0 4 votes vote down vote up
/**
 * verify basic echo byte rendezvous
 */
@Test(timeout = 10 * 1000)
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();
}
 
Example #19
Source File: StormYammerMetricsAdapter.java    From storm-metrics-reporter with Apache License 2.0 4 votes vote down vote up
/**
 * See {@link com.yammer.metrics.core.MetricsRegistry#newMeter}
 */
public Meter createMeter(final String component, final String methodName, final String eventType) {
  return metricsRegistry.newMeter(getMetricName(component, methodName), eventType, TimeUnit.SECONDS);
}
 
Example #20
Source File: TransmitterSummary.java    From mireka with Apache License 2.0 4 votes vote down vote up
public Meter errorsMeter() {
    return errors;
}
 
Example #21
Source File: TransmitterSummary.java    From mireka with Apache License 2.0 4 votes vote down vote up
public Meter partialFailuresMeter() {
    return partialFailures;
}
 
Example #22
Source File: TransmitterSummary.java    From mireka with Apache License 2.0 4 votes vote down vote up
public Meter transientFailuresMeter() {
    return transientFailures;
}
 
Example #23
Source File: TransmitterSummary.java    From mireka with Apache License 2.0 4 votes vote down vote up
public Meter permanentFailuresMeter() {
    return permanentFailures;
}
 
Example #24
Source File: TransmitterSummary.java    From mireka with Apache License 2.0 4 votes vote down vote up
public Meter successfulMailTransactionsMeter() {
    return successfulMailTransactions;
}
 
Example #25
Source File: CaliperMeasure.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
/**
 * Rate meter.
 */
public Meter rate() {
    return rate;
}
 
Example #26
Source File: EchoMessageHandler.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
public Meter meter() {
    return meter;
}
 
Example #27
Source File: NioUdtMessageRendezvousChannelTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
/**
 * 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 = 10 * 1000)
@Ignore
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();
}
 
Example #28
Source File: NioUdtByteRendezvousChannelTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
/**
 * verify basic echo byte rendezvous
 */
@Test(timeout = 10 * 1000)
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();
}
 
Example #29
Source File: EchoByteHandler.java    From netty4.0.27Learn with Apache License 2.0 4 votes vote down vote up
public Meter meter() {
    return meter;
}
 
Example #30
Source File: CaliperMeasure.java    From netty4.0.27Learn with Apache License 2.0 4 votes vote down vote up
/**
 * Rate meter.
 */
public Meter rate() {
    return rate;
}