com.yammer.metrics.Metrics类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中com.yammer.metrics.Metrics类的一些代码示例,展示了Metrics类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metrics类的具体详情如下:
包路径:com.yammer.metrics.Metrics
类名称:Metrics

Metrics介绍

[英]A set of factory methods for creating centrally registered metric instances.
[中]用于创建集中注册的度量实例的一组工厂方法。

代码示例

代码示例来源:origin: linkedin/cruise-control

private void reportYammerMetrics(long now) throws Exception {
 LOG.debug("Reporting yammer metrics.");
 YammerMetricProcessor.Context context = new YammerMetricProcessor.Context(this, now, _brokerId, _reportingIntervalMs);
 for (Map.Entry<com.yammer.metrics.core.MetricName, Metric> entry : Metrics.defaultRegistry().allMetrics().entrySet()) {
  LOG.trace("Processing yammer metric {}, scope = {}", entry.getKey(), entry.getKey().getScope());
  entry.getValue().processWith(_yammerMetricProcessor, entry.getKey(), context);
 }
 LOG.debug("Finished reporting yammer metrics.");
}

代码示例来源:origin: apache/incubator-pinot

/**
 *
 * Return an existing counter if
 *  (a) A counter already exist with the same metric name.
 * Otherwise, creates a new meter and registers
 *
 * @param registry MetricsRegistry
 * @param name metric name
 * @return Counter
 */
public static Counter newCounter(MetricsRegistry registry, MetricName name) {
 if (registry != null) {
  return registry.newCounter(name);
 } else {
  return Metrics.newCounter(name);
 }
}

代码示例来源:origin: apache/usergrid

Timer timer = Metrics.newTimer( BcryptCommandTest.class, "hashtimer" );
ConsoleReporter reporter = new ConsoleReporter( Metrics.defaultRegistry(), System.out, MetricPredicate.ALL );

代码示例来源:origin: lealone/Lealone

/**
 * Create metrics for given ThreadPoolExecutor.
 *
 * @param executor Thread pool
 * @param path Type of thread pool
 * @param poolName Name of thread pool to identify metrics
 */
public ThreadPoolMetrics(final ThreadPoolExecutor executor, String path, String poolName) {
  this.factory = new ThreadPoolMetricNameFactory("ThreadPools", path, poolName);
  activeTasks = Metrics.newGauge(factory.createMetricName("ActiveTasks"), new Gauge<Integer>() {
    public Integer value() {
      return executor.getActiveCount();
    }
  });
  totalBlocked = Metrics.newCounter(factory.createMetricName("TotalBlockedTasks"));
  currentBlocked = Metrics.newCounter(factory.createMetricName("CurrentlyBlockedTasks"));
  completedTasks = Metrics.newGauge(factory.createMetricName("CompletedTasks"), new Gauge<Long>() {
    public Long value() {
      return executor.getCompletedTaskCount();
    }
  });
  pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge<Long>() {
    public Long value() {
      return executor.getTaskCount() - executor.getCompletedTaskCount();
    }
  });
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server

public CASClientRequestMetrics(String scope) {
  super(scope);
  contention = Metrics.newHistogram(factory.createMetricName("ContentionHistogram"), true);
  conditionNotMet =  Metrics.newCounter(factory.createMetricName("ConditionNotMet"));
  unfinishedCommit =  Metrics.newCounter(factory.createMetricName("UnfinishedCommit"));
}

代码示例来源:origin: apache/incubator-pinot

/**
 *
 * Return an existing timer if
 *  (a) A timer already exist with the same metric name.
 * Otherwise, creates a new timer and registers
 *
 * @param registry MetricsRegistry
 * @param name metric name
 * @param durationUnit TimeUnit for duration
 * @param rateUnit TimeUnit for rate determination
 * @return Timer
 */
public static Timer newTimer(MetricsRegistry registry, MetricName name, TimeUnit durationUnit, TimeUnit rateUnit) {
 if (registry != null) {
  return registry.newTimer(name, durationUnit, rateUnit);
 } else {
  return Metrics.newTimer(name, durationUnit, rateUnit);
 }
}

代码示例来源:origin: apache/incubator-pinot

/**
 *
 * Return an existing gauge if
 *  (a) A gauge already exist with the same metric name.
 * Otherwise, creates a new meter and registers
 *
 * @param registry MetricsRegistry
 * @param name metric name
 * @param gauge Underlying gauge to be tracked
 * @return gauge
 */
public static <T> Gauge<T> newGauge(MetricsRegistry registry, MetricName name, Gauge<T> gauge) {
 if (registry != null) {
  return registry.newGauge(name, gauge);
 } else {
  return Metrics.newGauge(name, gauge);
 }
}

代码示例来源:origin: apache/incubator-pinot

/**
 *
 * Return an existing meter if
 *  (a) A meter already exist with the same metric name.
 * Otherwise, creates a new meter and registers
 *
 * @param registry MetricsRegistry
 * @param name metric name
 * @param eventType Event Type
 * @param unit TimeUnit for rate determination
 * @return Meter
 */
public static Meter newMeter(MetricsRegistry registry, MetricName name, String eventType, TimeUnit unit) {
 if (registry != null) {
  return registry.newMeter(name, eventType, unit);
 } else {
  return Metrics.newMeter(name, eventType, unit);
 }
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server

/**
 * Create LatencyMetrics with given group, type, prefix to append to each metric name, and scope.
 *
 * @param factory MetricName factory to use
 * @param namePrefix Prefix to append to each metric name
 */
public LatencyMetrics(MetricNameFactory factory, String namePrefix)
{
  this.factory = factory;
  this.namePrefix = namePrefix;
  latency = Metrics.newTimer(factory.createMetricName(namePrefix + "Latency"), TimeUnit.MICROSECONDS, TimeUnit.SECONDS);
  totalLatency = Metrics.newCounter(factory.createMetricName(namePrefix + "TotalLatency"));
}

代码示例来源:origin: com.sematext.ag/ag-player

/**
 * Constructor.
 * 
 * @param clazz
 *          class for calculating metrics
 */
public BasicMetrics(Class<?> clazz) {
 requests = Metrics.newMeter(clazz, "requests", "requests", TimeUnit.SECONDS);
 timer = Metrics.newTimer(clazz, "responses", TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
}

代码示例来源:origin: addthis/metrics-reporter-config

private void runLoop(ReporterConfig config) throws Exception
{
  Counter counter = Metrics.newCounter(getClass(), "counter");
  Meter meter = Metrics.newMeter(getClass(), "meter", "foo", TimeUnit.SECONDS);
  config.enableConsole();
  for (int i=0; i< loops; i++)
  {
    counter.inc();
    meter.mark();
    Thread.sleep(1000);
    log.debug("runLoop tick");
  }
  log.info("Done with sample data loop");
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server

public FileCacheMetrics()
  {
    hits = Metrics.newMeter(factory.createMetricName("Hits"), "hits", TimeUnit.SECONDS);
    requests = Metrics.newMeter(factory.createMetricName("Requests"), "requests", TimeUnit.SECONDS);
    hitRate = Metrics.newGauge(factory.createMetricName("HitRate"), new RatioGauge()
    {
      protected double getNumerator()
      {
        return hits.count();
      }

      protected double getDenominator()
      {
        return requests.count();
      }
    });
    size = Metrics.newGauge(factory.createMetricName("Size"), new Gauge<Long>()
    {
      public Long value()
      {
        return FileCacheService.instance.sizeInBytes();
      }
    });
  }
}

代码示例来源:origin: apache/incubator-pinot

/**
 *
 * Return an existing histogram if
 *  (a) A histogram already exist with the same metric name.
 * Otherwise, creates a new meter and registers
 *
 * @param registry MetricsRegistry
 * @param name metric name
 * @param biased (true if uniform distribution, otherwise exponential weighted)
 * @return histogram
 */
public static Histogram newHistogram(MetricsRegistry registry, MetricName name, boolean biased) {
 if (registry != null) {
  return registry.newHistogram(name, biased);
 } else {
  return Metrics.newHistogram(name, biased);
 }
}

代码示例来源:origin: com.senseidb/sensei-core

IndexingMetrics(int partition) {
  MetricName docsIndexedName = new MetricName(MetricsConstants.Domain, "meter", "docs-indexed",
    "indexer");
  docsIndexedMetric = Metrics.newMeter(docsIndexedName, "indexing", TimeUnit.SECONDS);
  MetricName docsLeftoverName = new MetricName(MetricsConstants.Domain, "meter",
    "docs-leftover", "indexer");
  docsLeftoverMetric = Metrics.newMeter(docsLeftoverName, "indexing", TimeUnit.SECONDS);
  MetricName flushTimeName = new MetricName(MetricsConstants.Domain, "histogram", "flush-time",
    "indexer");
  flushTimeHistogram = Metrics.newHistogram(flushTimeName, false);
 }
}

代码示例来源:origin: com.wavefront/proxy

public FilebeatIngester(LogsIngester logsIngester, Supplier<Long> currentMillis) {
 this.logsIngester = logsIngester;
 this.received = Metrics.newCounter(new MetricName("logsharvesting", "", "filebeat-received"));
 this.malformed = Metrics.newCounter(new MetricName("logsharvesting", "", "filebeat-malformed"));
 this.drift = Metrics.newHistogram(new MetricName("logsharvesting", "", "filebeat-drift"));
 this.currentMillis = currentMillis;
}

代码示例来源:origin: urbanairship/statshtable

SHTimerMetric(TimeUnit durationUnit, TimeUnit rateUnit) {
  t = Metrics.newTimer(this.getClass(),"Timer",durationUnit, rateUnit);
}

代码示例来源:origin: lealone/Lealone

activeTasks = Metrics.newGauge(factory.createMetricName("ActiveTasks"), new Gauge<Integer>() {
  public Integer value() {
    return executor.getActiveCount();
pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge<Long>() {
  public Long value() {
    return executor.getPendingTasks();
totalBlocked = Metrics.newGauge(factory.createMetricName("TotalBlockedTasks"), new Gauge<Integer>() {
  public Integer value() {
    return executor.getTotalBlockedTasks();
currentBlocked = Metrics.newGauge(factory.createMetricName("CurrentlyBlockedTasks"), new Gauge<Long>() {
  public Long value() {
    return (long) executor.getCurrentlyBlockedTasks();
completedTasks = Metrics.newGauge(factory.createMetricName("CompletedTasks"), new Gauge<Long>() {
  public Long value() {
    return executor.getCompletedTasks();

代码示例来源:origin: lealone/Lealone

/**
 * Create metrics for given connection pool.
 *
 * @param ip IP address to use for metrics label
 */
public ConnectionMetrics(NetEndpoint ip) {
  // ipv6 addresses will contain colons, which are invalid in a JMX ObjectName
  String address = ip.getHostAddress().replaceAll(":", ".");
  factory = new DefaultNameFactory("Connection", address);
  timeouts = Metrics.newMeter(factory.createMetricName("Timeouts"), "timeouts", TimeUnit.SECONDS);
}

代码示例来源:origin: com.wavefront/proxy

ReportingObjectQueueWrapper(ObjectQueue<T> backingQueue, String title) {
 this.addCounter = Metrics.newCounter(new MetricName("tape." + title, "", "add"));
 this.removeCounter = Metrics.newCounter(new MetricName("tape." + title, "", "remove"));
 this.peekCounter = Metrics.newCounter(new MetricName("tape." + title, "", "peek"));
 Metrics.newGauge(new MetricName("tape." + title, "", "size"),
   new Gauge<Integer>() {
    @Override
    public Integer value() {
     return backingQueue.size();
    }
   });
 this.backingQueue = backingQueue;
}

代码示例来源:origin: facebookarchive/hive-io-experimental

/**
 * Constructor
 *
 * @param name String name
 * @param printPeriod how often to print
 */
public MetricsObserver(String name, int printPeriod) {
 TimeUnit durationUnit = TimeUnit.MICROSECONDS;
 TimeUnit rateUnit = TimeUnit.MILLISECONDS;
 this.printPeriod = printPeriod;
 readTimer = Metrics.newTimer(new MetricName(name, "", "reads"),
   durationUnit, rateUnit);
 readSuccessRatio =
   new CounterRatioGauge(Metrics.newCounter(new MetricName(name, "", "successes")),
     Metrics.newCounter(new MetricName(name, "", "-reads")));
 parseTimer = Metrics.newTimer(new MetricName(name, "", "parses"),
   durationUnit, rateUnit);
}

相关文章