本文整理了Java中com.yammer.metrics.core.Metric
类的一些代码示例,展示了Metric
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metric
类的具体详情如下:
包路径:com.yammer.metrics.core.Metric
类名称:Metric
[英]A tag interface to indicate that a class is a metric.
[中]
代码示例来源:origin: apache/incubator-pinot
@Override
public <T2> void processWith(MetricProcessor<T2> processor, MetricName name, T2 context)
throws Exception {
for (T h : _histograms) {
if (h instanceof Metric) {
((Metric) h).processWith(processor, name, context);
}
}
}
}
代码示例来源:origin: apache/incubator-pinot
@Override
public <T> void processWith(MetricProcessor<T> processor, MetricName name, T context)
throws Exception {
for (Metric c : _counters) {
c.processWith(processor, name, context);
}
}
代码示例来源: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: com.yammer.metrics/metrics-core
@Override
public void onMetricAdded(MetricName name, Metric metric) {
if (metric != null) {
try {
metric.processWith(this, name, new Context(name, new ObjectName(name.getMBeanName())));
} catch (Exception e) {
LOGGER.warn("Error processing {}", name, e);
}
}
}
代码示例来源:origin: addthis/hydra
private void printRegularMetrics() {
for (Map.Entry<String, SortedMap<MetricName, Metric>> entry :
getMetricsRegistry().groupedMetrics().entrySet()) {
for (Map.Entry<MetricName, Metric> subEntry : entry.getValue().entrySet()) {
final Metric metric = subEntry.getValue();
if (metric != null) {
try {
metric.processWith(this, subEntry.getKey(), null);
} catch (Exception suppressed) {
log.error("Error printing regular metrics:", suppressed);
}
}
}
}
}
代码示例来源:origin: com.readytalk/metrics2-statsd
protected void printRegularMetrics(long epoch) {
for (Map.Entry<String, SortedMap<MetricName, Metric>> entry : getMetricsRegistry().groupedMetrics(predicate).entrySet()) {
for (Map.Entry<MetricName, Metric> subEntry : entry.getValue().entrySet()) {
final Metric metric = subEntry.getValue();
if (metric != null) {
try {
metric.processWith(this, subEntry.getKey(), epoch);
} catch (Exception ignored) {
LOG.error("Error printing regular metrics:", ignored);
}
}
}
}
}
代码示例来源:origin: com.yammer.metrics/metrics-graphite
protected void printRegularMetrics(final Long epoch) {
for (Entry<String,SortedMap<MetricName,Metric>> entry : getMetricsRegistry().groupedMetrics(
predicate).entrySet()) {
for (Entry<MetricName, Metric> subEntry : entry.getValue().entrySet()) {
final Metric metric = subEntry.getValue();
if (metric != null) {
try {
metric.processWith(this, subEntry.getKey(), epoch);
} catch (Exception ignored) {
LOG.error("Error printing regular metrics:", ignored);
}
}
}
}
}
代码示例来源:origin: com.linkedin.cruisecontrol/cruise-control-metrics-reporter
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: vistarmedia/metrics-datadog
protected void pushRegularMetrics(long epoch) {
for (Entry<String, SortedMap<MetricName, Metric>> entry : getMetricsRegistry()
.groupedMetrics(predicate).entrySet()) {
for (Entry<MetricName, Metric> subEntry : entry.getValue().entrySet()) {
final Metric metric = subEntry.getValue();
if (metric != null) {
try {
metric.processWith(this, subEntry.getKey(), epoch);
} catch (Exception e) {
LOG.error("Error pushing metric", e);
}
}
}
}
}
代码示例来源:origin: harbby/presto-connectors
@Override
public void run() {
for (Map.Entry<String, SortedMap<MetricName, Metric>> entry : getMetricsRegistry().groupedMetrics(
MetricPredicate.ALL).entrySet()) {
try {
for (Map.Entry<MetricName, Metric> subEntry : entry.getValue().entrySet()) {
out.print(" " + subEntry.getKey().getName());
out.println(':');
subEntry.getValue().processWith(this, subEntry.getKey(), out);
}
} catch (Exception e) {
e.printStackTrace(out);
}
}
}
代码示例来源:origin: wavefrontHQ/java
private void processEntry(Map.Entry<MetricName, Metric> entry) {
try {
MetricName metricName = entry.getKey();
Metric metric = entry.getValue();
if (metricTranslator != null) {
Pair<MetricName, Metric> pair = metricTranslator.apply(Pair.of(metricName, metric));
if (pair == null) return;
metricName = pair._1;
metric = pair._2;
}
metric.processWith(socketMetricProcessor, metricName, null);
metricsGeneratedLastPass.incrementAndGet();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: com.yammer.metrics/metrics-servlet
public void writeRegularMetrics(JsonGenerator json, String classPrefix, boolean showFullSamples) throws IOException {
for (Map.Entry<String, SortedMap<MetricName, Metric>> entry : registry.groupedMetrics().entrySet()) {
if (classPrefix == null || entry.getKey().startsWith(classPrefix)) {
json.writeFieldName(entry.getKey());
json.writeStartObject();
{
for (Map.Entry<MetricName, Metric> subEntry : entry.getValue().entrySet()) {
json.writeFieldName(subEntry.getKey().getName());
try {
subEntry.getValue()
.processWith(this,
subEntry.getKey(),
new Context(json, showFullSamples));
} catch (Exception e) {
LOGGER.warn("Error writing out {}", subEntry.getKey(), e);
}
}
}
json.writeEndObject();
}
}
}
代码示例来源:origin: damienclaveau/kafka-graphite
/**
* Filter gauges that should have been deleted, ugly workaround for KAFKA-1866 with Kafka 0.8.x
* @return {@code false} if gauge is not cleaned.
*/
private boolean cleanInvalidGauge(MetricName name, Metric metric, String metricName) {
try {
metric.processWith(metricProcessor, name, null);
} catch (InvalidGaugeException ex) {
LOGGER.info("Deleting metric {} from registry", metricName);
Metrics.defaultRegistry().removeMetric(name);
return true;
} catch (Exception ex) {
LOGGER.error("Caught an Exception while processing metric " + metricName, ex);
}
return false;
}
代码示例来源:origin: com.wavefront/proxy
@Override
public void run() {
for (Map.Entry<String, SortedMap<MetricName, Metric>> group : getMetricsRegistry().groupedMetrics().entrySet()) {
for (Map.Entry<MetricName, Metric> entry : group.getValue().entrySet()) {
if (entry.getValue() == null || entry.getKey() == null) {
logger.severe("Application Error! Pulled null value from metrics registry.");
}
MetricName metricName = entry.getKey();
Metric metric = entry.getValue();
try {
TimeSeries timeSeries = TimeSeriesUtils.fromMetricName(metricName);
metric.processWith(flushProcessor, metricName, new FlushProcessorContext(timeSeries, prefix, pointHandler));
} catch (Exception e) {
logger.log(Level.SEVERE, "Uncaught exception in MetricsReporter", e);
}
}
}
}
代码示例来源:origin: wavefrontHQ/java
@Override
public void run() {
for (Map.Entry<String, SortedMap<MetricName, Metric>> group : getMetricsRegistry().groupedMetrics().entrySet()) {
for (Map.Entry<MetricName, Metric> entry : group.getValue().entrySet()) {
if (entry.getValue() == null || entry.getKey() == null) {
logger.severe("Application Error! Pulled null value from metrics registry.");
}
MetricName metricName = entry.getKey();
Metric metric = entry.getValue();
try {
TimeSeries timeSeries = TimeSeriesUtils.fromMetricName(metricName);
metric.processWith(flushProcessor, metricName, new FlushProcessorContext(timeSeries, prefix, pointHandler));
} catch (Exception e) {
logger.log(Level.SEVERE, "Uncaught exception in MetricsReporter", e);
}
}
}
}
代码示例来源:origin: com.yammer.metrics/metrics-core
out.print(subEntry.getKey().getName());
out.println(':');
subEntry.getValue().processWith(this, subEntry.getKey(), out);
out.println();
代码示例来源:origin: com.yammer.metrics/metrics-core
@Override
public void run() {
final long time = TimeUnit.MILLISECONDS.toSeconds(clock.time() - startTime);
final Set<Entry<MetricName, Metric>> metrics = getMetricsRegistry().allMetrics().entrySet();
try {
for (Entry<MetricName, Metric> entry : metrics) {
final MetricName metricName = entry.getKey();
final Metric metric = entry.getValue();
if (predicate.matches(metricName, metric)) {
final Context context = new Context() {
@Override
public PrintStream getStream(String header) throws IOException {
final PrintStream stream = getPrintStream(metricName, header);
stream.print(time);
stream.print(',');
return stream;
}
};
metric.processWith(this, entry.getKey(), context);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: com.wavefront/proxy
private boolean maybeIngestLog(
BiFunction<MetricName, MetricMatcher, Metric> metricLoader, MetricMatcher metricMatcher,
LogsMessage logsMessage) {
Double[] output = {null};
TimeSeries timeSeries = metricMatcher.timeSeries(logsMessage, output);
if (timeSeries == null) return false;
MetricName metricName = TimeSeriesUtils.toMetricName(timeSeries);
Metric metric = metricLoader.apply(metricName, metricMatcher);
try {
metric.processWith(readProcessor, metricName, new ReadProcessorContext(output[0]));
} catch (Exception e) {
logger.log(Level.SEVERE, "Could not process metric " + metricName.toString(), e);
}
return true;
}
}
代码示例来源:origin: wavefrontHQ/java
private boolean maybeIngestLog(
BiFunction<MetricName, MetricMatcher, Metric> metricLoader, MetricMatcher metricMatcher,
LogsMessage logsMessage) {
Double[] output = {null};
TimeSeries timeSeries = metricMatcher.timeSeries(logsMessage, output);
if (timeSeries == null) return false;
MetricName metricName = TimeSeriesUtils.toMetricName(timeSeries);
Metric metric = metricLoader.apply(metricName, metricMatcher);
try {
metric.processWith(readProcessor, metricName, new ReadProcessorContext(output[0]));
} catch (Exception e) {
logger.log(Level.SEVERE, "Could not process metric " + metricName.toString(), e);
}
return true;
}
}
代码示例来源:origin: wavefrontHQ/java
value.processWith(processor, key, new Context(json, showFullSamples));
} catch (Exception e) {
e.printStackTrace();
内容来源于网络,如有侵权,请联系作者删除!