com.yammer.metrics.core.MetricsRegistry.newTimer()方法的使用及代码示例

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

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

MetricsRegistry.newTimer介绍

[英]Creates a new Timer and registers it under the given metric name.
[中]创建一个新计时器,并将其注册到给定的度量名称下。

代码示例

代码示例来源: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: hector-client/hector

@Override
public Object start(final String tagName) {
 final Timer timer = metricsRegistry.newTimer(new MetricName(clusterName, TIMER_TYPE, tagName),
   durationUnit, rateUnit);
 return timer.time();
}

代码示例来源:origin: com.yammer.metrics/metrics-core

/**
 * Creates a new {@link Timer} and registers it under the given class and name, measuring
 * elapsed time in milliseconds and invocations per second.
 *
 * @param klass the class which owns the metric
 * @param name  the name of the metric
 * @return a new {@link Timer}
 */
public Timer newTimer(Class<?> klass,
           String name) {
  return newTimer(klass, name, null, TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
}

代码示例来源:origin: com.yammer.metrics/metrics-core

/**
 * Creates a new {@link com.yammer.metrics.core.Timer} and registers it under the given class
 * and name, measuring elapsed time in milliseconds and invocations per second.
 *
 * @param klass the class which owns the metric
 * @param name  the name of the metric
 * @return a new {@link com.yammer.metrics.core.Timer}
 */
public static Timer newTimer(Class<?> klass,
               String name) {
  return DEFAULT_REGISTRY.newTimer(klass, name);
}

代码示例来源:origin: harbby/presto-connectors

@Override public Timer newMetric(Class<?> clazz, String name, String scope) {
  return registry.newTimer(clazz, name, scope);
 }
};

代码示例来源:origin: com.yammer.metrics/metrics-core

/**
 * Creates a new {@link Timer} and registers it under the given class and name.
 *
 * @param klass        the class which owns the metric
 * @param name         the name of the metric
 * @param durationUnit the duration scale unit of the new timer
 * @param rateUnit     the rate scale unit of the new timer
 * @return a new {@link Timer}
 */
public Timer newTimer(Class<?> klass,
           String name,
           TimeUnit durationUnit,
           TimeUnit rateUnit) {
  return newTimer(klass, name, null, durationUnit, rateUnit);
}

代码示例来源:origin: com.yammer.metrics/metrics-core

/**
 * Creates a new {@link Timer} and registers it under the given class, name, and scope,
 * measuring elapsed time in milliseconds and invocations per second.
 *
 * @param klass the class which owns the metric
 * @param name  the name of the metric
 * @param scope the scope of the metric
 * @return a new {@link Timer}
 */
public Timer newTimer(Class<?> klass,
           String name,
           String scope) {
  return newTimer(klass, name, scope, TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
}

代码示例来源:origin: com.yammer.metrics/metrics-core

/**
 * Creates a new {@link com.yammer.metrics.core.Timer} and registers it under the given class,
 * name, and scope, measuring elapsed time in milliseconds and invocations per second.
 *
 * @param klass the class which owns the metric
 * @param name  the name of the metric
 * @param scope the scope of the metric
 * @return a new {@link com.yammer.metrics.core.Timer}
 */
public static Timer newTimer(Class<?> klass,
               String name,
               String scope) {
  return DEFAULT_REGISTRY.newTimer(klass, name, scope);
}

代码示例来源:origin: com.yammer.metrics/metrics-core

/**
 * Creates a new {@link com.yammer.metrics.core.Timer} and registers it under the given metric
 * name.
 *
 * @param metricName   the name of the metric
 * @param durationUnit the duration scale unit of the new timer
 * @param rateUnit     the rate scale unit of the new timer
 * @return a new {@link com.yammer.metrics.core.Timer}
 */
public static Timer newTimer(MetricName metricName,
               TimeUnit durationUnit,
               TimeUnit rateUnit) {
  return DEFAULT_REGISTRY.newTimer(metricName, durationUnit, rateUnit);
}

代码示例来源:origin: com.yammer.metrics/metrics-core

/**
 * Creates a new {@link com.yammer.metrics.core.Timer} and registers it under the given class
 * and name.
 *
 * @param klass        the class which owns the metric
 * @param name         the name of the metric
 * @param durationUnit the duration scale unit of the new timer
 * @param rateUnit     the rate scale unit of the new timer
 * @return a new {@link com.yammer.metrics.core.Timer}
 */
public static Timer newTimer(Class<?> klass,
               String name,
               TimeUnit durationUnit,
               TimeUnit rateUnit) {
  return DEFAULT_REGISTRY.newTimer(klass, name, durationUnit, rateUnit);
}

代码示例来源:origin: com.yammer.metrics/metrics-core

/**
 * Creates a new {@link com.yammer.metrics.core.Timer} and registers it under the given class,
 * name, and scope.
 *
 * @param klass        the class which owns the metric
 * @param name         the name of the metric
 * @param scope        the scope of the metric
 * @param durationUnit the duration scale unit of the new timer
 * @param rateUnit     the rate scale unit of the new timer
 * @return a new {@link com.yammer.metrics.core.Timer}
 */
public static Timer newTimer(Class<?> klass,
               String name,
               String scope,
               TimeUnit durationUnit,
               TimeUnit rateUnit) {
  return DEFAULT_REGISTRY.newTimer(klass, name, scope, durationUnit, rateUnit);
}

代码示例来源:origin: org.apache.giraph/giraph-core

/**
 * Creates a new {@link Timer} and registers it under the given
 * group and name.
 *
 * @param name         the name of the metric
 * @param durationUnit the duration scale unit of the new timer
 * @param rateUnit     the rate scale unit of the new timer
 * @return a new {@link Timer}
 */
public Timer getTimer(String name, TimeUnit durationUnit, TimeUnit rateUnit) {
 return registry.newTimer(makeMetricName(name), durationUnit, rateUnit);
}

代码示例来源:origin: com.yammer.metrics/metrics-jdbi

private Timer getTimer(StatementContext ctx) {
    return registry.newTimer(statementNameStrategy.getStatementName(ctx),
                 durationUnit,
                 rateUnit);
  }
}

代码示例来源:origin: harbby/presto-connectors

private CallTracker(MetricsRegistry registry, String name, String subName, String scope) {
 StringBuilder sb = new StringBuilder(CLIENT_SVC).append("_").append(name);
 if (subName != null) {
  sb.append("(").append(subName).append(")");
 }
 this.name = sb.toString();
 this.callTimer = registry.newTimer(MetricsConnection.class, DRTN_BASE + this.name, scope);
 this.reqHist = registry.newHistogram(MetricsConnection.class, REQ_BASE + this.name, scope);
 this.respHist = registry.newHistogram(MetricsConnection.class, RESP_BASE + this.name, scope);
}

代码示例来源:origin: com.yammer.dropwizard/dropwizard-views

protected View(String templateName, Charset charset) {
  this.templateName = resolveName(templateName);
  this.charset = charset;
  this.renderingTimer = Metrics.defaultRegistry().newTimer(getClass(), "rendering");
}

代码示例来源:origin: org.hectorclient/hector-core

@Override
public Object start(final String tagName) {
 final Timer timer = metricsRegistry.newTimer(new MetricName(clusterName, TIMER_TYPE, tagName),
   durationUnit, rateUnit);
 return timer.time();
}

代码示例来源:origin: com.yammer.metrics/metrics-aop

public static MethodInterceptor forMethod(MetricsRegistry metricsRegistry, Class<?> klass, Method method) {
  final Timed annotation = method.getAnnotation(Timed.class);
  if (annotation != null) {
    final String name = annotation.name().isEmpty() ? method.getName() : annotation.name();
    final TimerMetric timer = metricsRegistry.newTimer(klass,
                              name,
                              annotation.durationUnit(),
                              annotation.rateUnit());
    return new TimedInterceptor(timer);
  }
  return null;
}

代码示例来源:origin: com.yammer.metrics/metrics-spring

@Override
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
  final Timed timed = method.getAnnotation(Timed.class);
  final String group = MetricName.chooseGroup(timed.group(), targetClass);
  final String type = MetricName.chooseType(timed.type(), targetClass);
  final String name = MetricName.chooseName(timed.name(), method);
  final MetricName metricName = new MetricName(group, type, name, scope);
  final Timer timer = metrics.newTimer(metricName, timed.durationUnit(), timed.rateUnit());
  timers.put(method.getName(), timer);
  if (log.isDebugEnabled()) {
    log.debug("Created metric " + metricName + " for method " + method.getName());
  }
}

代码示例来源:origin: com.ning.jdbi/jdbi-metrics

@Override
  public void collect(long elapsedTime, StatementContext ctx)
  {
    StatementName statementName = jdbiGroupStrategy.getStatementName(ctx);
    TimerMetric timer = metricsRegistry.newTimer(new MetricName(statementName.getGroupName(), statementName.getTypeName(), statementName.getStatementName()),
                           durationUnit,
                           rateUnit);

    timer.update(elapsedTime, TimeUnit.NANOSECONDS);
  }
}

代码示例来源:origin: com.yammer.metrics/metrics-guice

static MethodInterceptor forMethod(MetricsRegistry metricsRegistry, Class<?> klass, Method method) {
  final Timed annotation = method.getAnnotation(Timed.class);
  if (annotation != null) {
    final String group = MetricName.chooseGroup(annotation.group(), klass);
    final String type = MetricName.chooseType(annotation.type(), klass);
    final String name = MetricName.chooseName(annotation.name(), method);
    final MetricName metricName = new MetricName(group, type, name);
    final Timer timer = metricsRegistry.newTimer(metricName,
                              annotation.durationUnit(),
                              annotation.rateUnit());
    return new TimedInterceptor(timer);
  }
  return null;
}

相关文章