com.yammer.metrics.core.MetricName Java Examples
The following examples show how to use
com.yammer.metrics.core.MetricName.
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: HdfsDirectory.java From incubator-retired-blur with Apache License 2.0 | 6 votes |
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 #2
Source File: CustomReporter.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Override public void processHistogram(final MetricName name, final Histogram histogram, final PrintStream stream) { final Snapshot snapshot = histogram.getSnapshot(); stream.printf(locale, " min = %,2.2f\n", histogram.min()); stream.printf(locale, " max = %,2.2f\n", histogram.max()); stream.printf(locale, " mean = %,2.2f\n", histogram.mean()); stream.printf(locale, " stddev = %,2.2f\n", histogram.stdDev()); stream.printf(locale, " median = %,2.2f\n", snapshot.getMedian()); stream.printf(locale, " 75%% <= %,2.2f\n", snapshot.get75thPercentile()); stream.printf(locale, " 95%% <= %,2.2f\n", snapshot.get95thPercentile()); stream.printf(locale, " 98%% <= %,2.2f\n", snapshot.get98thPercentile()); stream.printf(locale, " 99%% <= %,2.2f\n", snapshot.get99thPercentile()); stream.printf(locale, " 99.9%% <= %,2.2f\n", snapshot.get999thPercentile()); }
Example #3
Source File: FilterMetricPredicate.java From kafka-graphite with Apache License 2.0 | 6 votes |
@Override public boolean matches(MetricName name, Metric metric) { String metricName = sanitizeName(name); boolean isVersionMetric = APPVERSION_PATTERN.matcher(metricName).matches(); if (isVersionMetric || cleanInvalidGauge(name, metric, metricName)) { return false; } if (pattern != null) { return !pattern.matcher(metricName).matches(); } return true; }
Example #4
Source File: MemoryReporter.java From incubator-retired-blur with Apache License 2.0 | 6 votes |
@Override public void processTimer(MetricName name, Timer timer, ConcurrentMap<String, org.apache.blur.thrift.generated.Metric> context) throws Exception { org.apache.blur.thrift.generated.Metric metric = getMetric(name, context); addMeter(metric, timer, context); metric.putToStrMap("unit", timer.durationUnit().toString()); metric.putToDoubleMap("min", timer.min()); metric.putToDoubleMap("max", timer.max()); metric.putToDoubleMap("mean", timer.mean()); metric.putToDoubleMap("stdDev", timer.stdDev()); Snapshot snapshot = timer.getSnapshot(); metric.putToDoubleMap("median", snapshot.getMedian()); metric.putToDoubleMap("75%", snapshot.get75thPercentile()); metric.putToDoubleMap("95%", snapshot.get95thPercentile()); metric.putToDoubleMap("98%", snapshot.get98thPercentile()); metric.putToDoubleMap("99%", snapshot.get99thPercentile()); metric.putToDoubleMap("99.9%", snapshot.get999thPercentile()); }
Example #5
Source File: AbstractDistributedIndexServer.java From incubator-retired-blur with Apache License 2.0 | 6 votes |
public AbstractDistributedIndexServer(ClusterStatus clusterStatus, Configuration configuration, String nodeName, String cluster) { _clusterStatus = clusterStatus; _configuration = configuration; _nodeName = nodeName; _cluster = cluster; MetricName tableCount = new MetricName(ORG_APACHE_BLUR, BLUR, TABLE_COUNT, _cluster); MetricName indexCount = new MetricName(ORG_APACHE_BLUR, BLUR, INDEX_COUNT, _cluster); MetricName segmentCount = new MetricName(ORG_APACHE_BLUR, BLUR, SEGMENT_COUNT, _cluster); MetricName indexMemoryUsage = new MetricName(ORG_APACHE_BLUR, BLUR, INDEX_MEMORY_USAGE, _cluster); MetricName recordCount = new MetricName(ORG_APACHE_BLUR, BLUR, RECORD_COUNT, _cluster); Metrics.newGauge(tableCount, new AtomicLongGauge(_tableCount)); Metrics.newGauge(indexCount, new AtomicLongGauge(_indexCount)); Metrics.newGauge(segmentCount, new AtomicLongGauge(_segmentCount)); Metrics.newGauge(indexMemoryUsage, new AtomicLongGauge(_indexMemoryUsage)); Metrics.newGauge(recordCount, new AtomicLongGauge(_recordCount)); }
Example #6
Source File: FilterMetricPredicateTest.java From kafka-graphite with Apache License 2.0 | 6 votes |
@Test public void keepGaugesIfTheyThrowRuntimeExceptions() throws Exception { MetricPredicate predicate = new FilterMetricPredicate(); MetricName metricName = new MetricName("test", "test", "delete", "scope", "mBeanName"); Metric gauge = Metrics.newGauge(metricName, new Gauge<Long>() { @Override public Long value() { throw new RuntimeException("catch me if you can"); } }); assertTrue(predicate.matches(metricName, gauge)); assertTrue("The gauge should be there", Metrics.defaultRegistry().allMetrics().containsKey(metricName)); assertEquals(Metrics.defaultRegistry().allMetrics().get(metricName), gauge); }
Example #7
Source File: CustomReporter.java From netty4.0.27Learn with Apache License 2.0 | 6 votes |
@Override public void processHistogram(final MetricName name, final Histogram histogram, final PrintStream stream) { final Snapshot snapshot = histogram.getSnapshot(); stream.printf(locale, " min = %,2.2f\n", histogram.min()); stream.printf(locale, " max = %,2.2f\n", histogram.max()); stream.printf(locale, " mean = %,2.2f\n", histogram.mean()); stream.printf(locale, " stddev = %,2.2f\n", histogram.stdDev()); stream.printf(locale, " median = %,2.2f\n", snapshot.getMedian()); stream.printf(locale, " 75%% <= %,2.2f\n", snapshot.get75thPercentile()); stream.printf(locale, " 95%% <= %,2.2f\n", snapshot.get95thPercentile()); stream.printf(locale, " 98%% <= %,2.2f\n", snapshot.get98thPercentile()); stream.printf(locale, " 99%% <= %,2.2f\n", snapshot.get99thPercentile()); stream.printf(locale, " 99.9%% <= %,2.2f\n", snapshot.get999thPercentile()); }
Example #8
Source File: AbstractMetrics.java From incubator-pinot with Apache License 2.0 | 6 votes |
/** * Adds a new gauge whose values are retrieved from a callback function. * * @param metricName The name of the metric * @param valueCallback The callback function used to retrieve the value of the gauge */ public void addCallbackGauge(final String metricName, final Callable<Long> valueCallback) { MetricsHelper.newGauge(_metricsRegistry, new MetricName(_clazz, _metricPrefix + metricName), new com.yammer.metrics.core.Gauge<Long>() { @Override public Long value() { try { return valueCallback.call(); } catch (Exception e) { LOGGER.error("Caught exception", e); Utils.rethrowException(e); throw new AssertionError("Should not reach this"); } } }); }
Example #9
Source File: YammerFacadeMetric.java From storm-metrics-reporter with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public void processMeter(final MetricName name, final Metered meter, final Map context) throws Exception { final Map subMetrics = ImmutableMap .builder() .put("count", meter.count()) .put("meanRate", meter.meanRate()) .put("1MinuteRate", meter.oneMinuteRate()) .put("5MinuteRate", meter.fiveMinuteRate()) .put("15MinuteRate", meter.fifteenMinuteRate()) .build(); context.put(toString(name), subMetrics); }
Example #10
Source File: ParserForTagInMBeanName.java From kafka-statsd-metrics2 with Apache License 2.0 | 6 votes |
private String[] parseTags(MetricName metricName) { String[] tags = EMPTY_TAG; if (metricName.hasScope()) { final String name = metricName.getName(); final String mBeanName = metricName.getMBeanName(); final int idx = mBeanName.indexOf(name); if (idx < 0) { log.error("Cannot find name[{}] in MBeanName[{}]", name, mBeanName); } else { String tagStr = mBeanName.substring(idx + name.length() + 1); if ("kafka.producer".equals(metricName.getGroup()) && !tagStr.contains("clientId")) { tagStr = "clientId=unknown,".concat(tagStr); } if (tagStr.length() > 0) { tags = tagStr.replace('=', ':').split(","); } } } else if ("kafka.producer".equals(metricName.getGroup())) { tags = UNKNOWN_TAG; } return tags; }
Example #11
Source File: YammerFacadeMetric.java From storm-metrics-reporter with Apache License 2.0 | 6 votes |
/** * Returns a Map representing all the Yammer metrics managed by this facade metric. * * @return A Map which is in fact a snapshot of all the Yammer metrics managed by this facade metric. */ @Override public Object getValueAndReset() { final Map metricsValues = new HashMap(); for (final Map.Entry<MetricName, Metric> entry : metricsRegistry.allMetrics().entrySet()) { try { entry.getValue().processWith(METRIC_SERIALIZER, entry.getKey(), metricsValues); } catch (final Exception e) { // log? } } return metricsValues; }
Example #12
Source File: AbstractMetrics.java From incubator-pinot with Apache License 2.0 | 5 votes |
/** * Logs the timing for a metric * * @param fullTimerName The full name of timer * @param duration The log time duration time value * @param timeUnit The log time duration time unit */ private void addValueToTimer(String fullTimerName, final long duration, final TimeUnit timeUnit) { final MetricName metricName = new MetricName(_clazz, fullTimerName); com.yammer.metrics.core.Timer timer = MetricsHelper.newTimer(_metricsRegistry, metricName, TimeUnit.MILLISECONDS, TimeUnit.SECONDS); MetricsHelper.newTimer(_metricsRegistry, metricName, TimeUnit.MILLISECONDS, TimeUnit.SECONDS) .update(duration, timeUnit); }
Example #13
Source File: ParserForTagInMBeanName.java From kafka-statsd-metrics2 with Apache License 2.0 | 5 votes |
@Override public void parse(MetricName metricName) { Pattern p = tagRegexMap.get(metricName.getType()); if (p != null && !p.matcher(metricName.getMBeanName()).matches()) { name = format(metricName, SUFFIX_FOR_ALL); } else { name = format(metricName); } tags = parseTags(metricName); }
Example #14
Source File: ParserTest.java From kafka-statsd-metrics2 with Apache License 2.0 | 5 votes |
@Test public void testParseNoTag() throws Exception { MetricName name = new MetricName("kafka.producer", "ProducerRequestMetrics", "group7-AllBrokersProducerRequestSize"); Parser p = new ParserForNoTag(); p.parse(name); assertEquals(p.getName(), "kafka.producer.ProducerRequestMetrics.group7-AllBrokersProducerRequestSize"); assertArrayEquals(p.getTags(), new String[]{}); }
Example #15
Source File: ParserTest.java From kafka-statsd-metrics2 with Apache License 2.0 | 5 votes |
@Test public void testParseTagInMBeanNameNoTag() throws Exception { MetricName name = new MetricName("kafka.server", "ReplicaManager", "LeaderCount", null, "kafka.server:type=ReplicaManager,name=LeaderCount"); Parser p = new ParserForTagInMBeanName(); p.parse(name); assertEquals(p.getName(), "kafka.server.ReplicaManager.LeaderCount"); assertArrayEquals(p.getTags(), new String[]{}); }
Example #16
Source File: ParserTest.java From kafka-statsd-metrics2 with Apache License 2.0 | 5 votes |
@Test public void testParseTagInMBeanNameWithoutSuffixForConsumer() throws Exception { MetricName name = new MetricName("kafka.consumer", "ZookeeperConsumerConnector", "ZooKeeperCommitsPerSec", "clientId.group7", "kafka.consumer:type=ZookeeperConsumerConnector,name=ZooKeeperCommitsPerSec,clientId=group7"); Parser p = new ParserForTagInMBeanName(); p.parse(name); assertEquals(p.getName(), "kafka.consumer.ZookeeperConsumerConnector.ZooKeeperCommitsPerSec"); assertArrayEquals(p.getTags(), new String[]{"clientId:group7"}); }
Example #17
Source File: ParserTest.java From kafka-statsd-metrics2 with Apache License 2.0 | 5 votes |
@Test public void testParseTagInMBeanNameWithoutSuffix() throws Exception { MetricName name = new MetricName("kafka.producer", "ProducerRequestMetrics", "ProducerRequestSize", "clientId.group7.brokerPort.9092.brokerHost.10_1_152_206", "kafka.producer:type=ProducerRequestMetrics,name=ProducerRequestSize,clientId=group7,brokerPort=9092,brokerHost=10.1.152.206"); Parser p = new ParserForTagInMBeanName(); p.parse(name); assertEquals(p.getName(), "kafka.producer.ProducerRequestMetrics.ProducerRequestSize"); assertArrayEquals(p.getTags(), new String[]{"clientId:group7", "brokerPort:9092", "brokerHost:10.1.152.206"}); }
Example #18
Source File: ParserTest.java From kafka-statsd-metrics2 with Apache License 2.0 | 5 votes |
@Test public void testParseTagInMBeanNameWithSuffix() throws Exception { MetricName name = new MetricName("kafka.producer", "ProducerRequestMetrics", "ProducerRequestSize", "clientId.group7", "kafka.producer:type=ProducerRequestMetrics,name=ProducerRequestSize,clientId=group7"); Parser p = new ParserForTagInMBeanName(); p.parse(name); assertEquals(p.getName(), "kafka.producer.ProducerRequestMetrics.ProducerRequestSize_all"); assertArrayEquals(p.getTags(), new String[]{"clientId:group7"}); }
Example #19
Source File: MetricNameFormatterTest.java From kafka-statsd-metrics2 with Apache License 2.0 | 5 votes |
@Test public void testFormatWithScope() throws Exception { assertEquals( formatWithScope(new MetricName("kafka.common", "AppInfo", "Version", null, "kafka.common:type=AppInfo,name=Version")), "kafka.common.AppInfo.Version"); assertEquals( formatWithScope(new MetricName("kafka.common", "AppInfo", "Version", "", "kafka.common:type=AppInfo,name=Version")), "kafka.common.AppInfo.Version"); assertEquals( formatWithScope(new MetricName("kafka.common", "AppInfo", "Version", "my_scope", "kafka.common:type=AppInfo,name=Version")), "kafka.common.AppInfo.my_scope.Version"); }
Example #20
Source File: ExcludeMetricPredicateTest.java From kafka-statsd-metrics2 with Apache License 2.0 | 5 votes |
@Test public void exclude() { ExcludeMetricPredicate predicate = new ExcludeMetricPredicate("my\\.package\\.MyClass.*"); // String group, String type, String name, String scope assertFalse(predicate.matches(new MetricName("my.package", "MyClass", "some_name", "some_scope"), null)); assertTrue(predicate.matches(new MetricName("another.package", "MyClass", "some_name", "some_scope"), null)); }
Example #21
Source File: ValidationMetrics.java From incubator-pinot with Apache License 2.0 | 5 votes |
private void makeGauge(final String gaugeName, final MetricName metricName, final GaugeFactory<?> gaugeFactory, final long value) { if (!_gaugeValues.containsKey(gaugeName)) { _gaugeValues.put(gaugeName, value); MetricsHelper.newGauge(_metricsRegistry, metricName, gaugeFactory.buildGauge(gaugeName)); _metricNames.add(metricName); } else { _gaugeValues.put(gaugeName, value); } }
Example #22
Source File: StatsDReporterTest.java From kafka-statsd-metrics2 with Apache License 2.0 | 5 votes |
@Override public Object answer(InvocationOnMock invocation) throws Throwable { @SuppressWarnings("unchecked") final MetricProcessor<Object> processor = (MetricProcessor<Object>) invocation.getArguments()[0]; final MetricName name = (MetricName) invocation.getArguments()[1]; final Object context = invocation.getArguments()[2]; delegateToProcessor(processor, name, context); return null; }
Example #23
Source File: MetricNameFormatter.java From kafka-statsd-metrics2 with Apache License 2.0 | 5 votes |
public static String formatWithScope(MetricName metricName) { StringBuilder sb = new StringBuilder(128) .append(metricName.getGroup()) .append('.') .append(metricName.getType()) .append('.'); if (metricName.hasScope() && !metricName.getScope().isEmpty()) { sb.append(metricName.getScope()) .append("."); } sb.append(sanitizeName(metricName.getName())); return sb.toString(); }
Example #24
Source File: ExcludeMetricPredicate.java From kafka-statsd-metrics2 with Apache License 2.0 | 5 votes |
@Override public boolean matches(MetricName name, Metric metric) { String n = MetricNameFormatter.format(name); boolean excluded = pattern.matcher(n).matches(); if (excluded) { if (logger.isTraceEnabled()) { logger.trace("Metric " + n + " is excluded"); } } return !excluded; }
Example #25
Source File: JSONReporter.java From incubator-retired-blur with Apache License 2.0 | 5 votes |
public MetricInfo getMetricInfo(MetricName name) { MetricInfo info = metricInfoMap.get(name); if (info == null) { info = new MetricInfo(getName(name), typeTable.get(name), numberOfElements); metricInfoMap.put(name, info); } return info; }
Example #26
Source File: ThreadPoolMetricNameFactory.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public MetricName createMetricName(String metricName) { String groupName = ThreadPoolMetrics.class.getPackage().getName(); StringBuilder mbeanName = new StringBuilder(); mbeanName.append(groupName).append(":"); mbeanName.append("type=").append(type); mbeanName.append(",path=").append(path); mbeanName.append(",scope=").append(poolName); mbeanName.append(",name=").append(metricName); return new MetricName(groupName, type, metricName, path + "." + poolName, mbeanName.toString()); }
Example #27
Source File: FilterMetricPredicateTest.java From kafka-graphite with Apache License 2.0 | 5 votes |
@Test public void deleteGaugesIfTheyThrowNoSuchElementException() throws Exception { MetricPredicate predicate = new FilterMetricPredicate(); MetricName metricNameToBeDeleted = new MetricName("test", "test", "delete", "scope", "mBeanName"); Metric gaugeToBeDeleted = Metrics.newGauge(metricNameToBeDeleted, new Gauge<Long>() { @Override public Long value() { throw new NoSuchElementException("catch me if you can - i'm the the same as in KAFKA-1866"); } }); MetricName metricNameToStay = new MetricName("stay", "stay", "stay", "scope", "stay:mBeanName"); Metric gaugeToStay = Metrics.newGauge(metricNameToStay, new Gauge<Long>() { @Override public Long value() { return 42L; } }); assertFalse(predicate.matches(metricNameToBeDeleted, gaugeToBeDeleted)); assertTrue(predicate.matches(metricNameToStay, gaugeToStay)); assertFalse("The gauge should be deleted", Metrics.defaultRegistry().allMetrics().containsKey(metricNameToBeDeleted)); assertTrue("The gauge should be there", Metrics.defaultRegistry().allMetrics().containsKey(metricNameToStay)); assertEquals(Metrics.defaultRegistry().allMetrics().get(metricNameToStay), gaugeToStay); }
Example #28
Source File: FilterMetricPredicateTest.java From kafka-graphite with Apache License 2.0 | 5 votes |
@Test public void alwaysExcludeAppVersion_WithRegEx() { MetricPredicate predicate = new FilterMetricPredicate("group.type.foobar.*"); assertFalse(predicate.matches(new MetricName("kafka.common", "AppInfo", "Version", null, "mBeanName"), metricMock)); assertTrue(predicate.matches(new MetricName("kafka.common", "AppInfo", "SomethingElse", null, "mBeanName"), metricMock)); }
Example #29
Source File: FilterMetricPredicateTest.java From kafka-graphite with Apache License 2.0 | 5 votes |
@Test public void alwaysExcludeAppVersion_NoRegEx() { MetricPredicate predicate = new FilterMetricPredicate(); assertFalse(predicate.matches(new MetricName("kafka.common", "AppInfo", "Version", null, "mBeanName"), metricMock)); assertTrue(predicate.matches(new MetricName("kafka.common", "AppInfo", "SomethingElse", null, "mBeanName"), metricMock)); }
Example #30
Source File: FilterMetricPredicateTest.java From kafka-graphite with Apache License 2.0 | 5 votes |
@Before public void setup() { metricMock = mock(Metric.class); // clean all metrics List<MetricName> metricNames = new ArrayList<MetricName>(Metrics.defaultRegistry().allMetrics().keySet()); for (MetricName metricName : metricNames) { Metrics.defaultRegistry().removeMetric(metricName); } }