當前位置: 首頁>>代碼示例>>Java>>正文


Java MetricName類代碼示例

本文整理匯總了Java中com.yammer.metrics.core.MetricName的典型用法代碼示例。如果您正苦於以下問題:Java MetricName類的具體用法?Java MetricName怎麽用?Java MetricName使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MetricName類屬於com.yammer.metrics.core包,在下文中一共展示了MetricName類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processMeter

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
@Override
public void processMeter(MetricName metricName, Metered metered, Context context) throws Exception {
  if (MetricsUtils.isInterested(metricName)) {
    double value;
    if (context.reportingInterval() <= 60000L) {
      value = metered.oneMinuteRate();
    } else if (context.reportingInterval() <= 300000) {
      value = metered.fiveMinuteRate();
    } else {
      value = metered.fifteenMinuteRate();
    }
    CruiseControlMetric ccm = MetricsUtils.toCruiseControlMetric(context.time(),
                                                                 context.brokerId(),
                                                                 metricName,
                                                                 value);
    context.reporter().sendCruiseControlMetric(ccm);
  }
}
 
開發者ID:linkedin,項目名稱:cruise-control,代碼行數:19,代碼來源:YammerMetricProcessor.java

示例2: run

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
@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);
    }
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:17,代碼來源:HFilePrettyPrinter.java

示例3: processHistogram

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
@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());
}
 
開發者ID:wuyinxian124,項目名稱:netty4.0.27Learn,代碼行數:23,代碼來源:CustomReporter.java

示例4: FileCacheMetrics

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
public FileCacheMetrics()
{
    hits = Metrics.newMeter(new MetricName(FileCacheService.class, "Hits"), "hits", TimeUnit.SECONDS);
    requests = Metrics.newMeter(new MetricName(FileCacheService.class, "Requests"), "requests", TimeUnit.SECONDS);
    hitRate = Metrics.newGauge(new MetricName(FileCacheService.class, "HitRate"), new RatioGauge()
    {
        protected double getNumerator()
        {
            return hits.count();
        }

        protected double getDenominator()
        {
            return requests.count();
        }
    });
    size = Metrics.newGauge(new MetricName(FileCacheService.class, "Size"), new Gauge<Long>()
    {
        public Long value()
        {
            return FileCacheService.instance.sizeInBytes();
        }
    });
}
 
開發者ID:pgaref,項目名稱:ACaZoo,代碼行數:25,代碼來源:FileCacheMetrics.java

示例5: testMetricsHelperRegistration

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
@Test
public void testMetricsHelperRegistration() {
  listenerOneOkay = false;
  listenerTwoOkay = false;

  Map<String, String> configKeys = new HashMap<String, String>();
  configKeys.put("pinot.broker.metrics.metricsRegistryRegistrationListeners",
      ListenerOne.class.getName() + "," + ListenerTwo.class.getName());
  Configuration configuration = new MapConfiguration(configKeys);

  MetricsRegistry registry = new MetricsRegistry();

  // Initialize the MetricsHelper and create a new timer
  MetricsHelper.initializeMetrics(configuration.subset("pinot.broker.metrics"));
  MetricsHelper.registerMetricsRegistry(registry);
  MetricsHelper.newTimer(registry, new MetricName(MetricsHelperTest.class, "dummy"), TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS);

  // Check that the two listeners fired
  assertTrue(listenerOneOkay);
  assertTrue(listenerTwoOkay);
}
 
開發者ID:Hanmourang,項目名稱:Pinot,代碼行數:22,代碼來源:MetricsHelperTest.java

示例6: init

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
@Override
public void init(Configuration queryExecutorConfig, DataManager dataManager, ServerMetrics serverMetrics)
    throws ConfigurationException {
  _serverMetrics = serverMetrics;
  _queryExecutorConfig = new QueryExecutorConfig(queryExecutorConfig);
  _instanceDataManager = (InstanceDataManager) dataManager;
  if (_queryExecutorConfig.getTimeOut() > 0) {
    _defaultTimeOutMs = _queryExecutorConfig.getTimeOut();
  }
  LOGGER.info("Default timeout for query executor : {}", _defaultTimeOutMs);
  LOGGER.info("Trying to build SegmentPrunerService");
  if (_segmentPrunerService == null) {
    _segmentPrunerService = new SegmentPrunerServiceImpl(_queryExecutorConfig.getPrunerConfig());
  }
  LOGGER.info("Trying to build QueryPlanMaker");
  _planMaker = new InstancePlanMakerImplV2();
  LOGGER.info("Trying to build QueryExecutorTimer");
  if (_queryExecutorTimer == null) {
    _queryExecutorTimer =
        Metrics.newTimer(new MetricName(Domain, "timer", "query-executor-time-"), TimeUnit.MILLISECONDS,
            TimeUnit.SECONDS);
  }
}
 
開發者ID:Hanmourang,項目名稱:Pinot,代碼行數:24,代碼來源:ServerQueryExecutorV1Impl.java

示例7: onMetricAdded

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
/**
 * New metric added to the Yammer Metrics registry.
 *
 * Note that Kafka uses the default registry, so there can be non-Kafka metrics there
 * as well. This function ignores any metric whose group does not start with {@code 'kafka'}.
 *
 * @param metricName
 * @param metric
 */
public void onMetricAdded(MetricName metricName, Metric metric) {
	// The default registry can have non-Kafka metrics. Filter those out.
	if (!metricName.getGroup().startsWith("kafka")) {
		return;
	}

	MetricInfo mi = process(metric, metricName);
	if (mi != null) {
		synchronized (listeners) {
			for (KafkaMetricsListener listener : listeners) {
				listener.onKafkaMetricAdded(mi);
			}
		}
	} else {
		// metric not recognized
		System.err.println("Unrecognized Kafka metric: " + metricName.toString()
						+ "\n group: " + metricName.getGroup()
						+ "\n type: " + metricName.getType()
						+ "\n name: " + metricName.getName()
						+ "\n scope: " + metricName.getScope()
		);
	}
}
 
開發者ID:turn,項目名稱:kafka-metrics,代碼行數:33,代碼來源:KafkaClientMetricSet.java

示例8: onMetricRemoved

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
/**
 * Metric removed from the Yammer Metrics registry.
 *
 * Note that Kafka uses the default registry, so there can be non-Kafka metrics there
 * as well. This function ignores any metric whose group does not start with {@code 'kafka'}.
 *
 * @param metricName
 */
public void onMetricRemoved(MetricName metricName) {
	// The default registry can have non-Kafka metrics. Filter those out.
	if (!metricName.getGroup().startsWith("kafka")) {
		return;
	}

	MetricInfo mi = removeMetric(metricName);
	if (mi != null) {
		synchronized (listeners) {
			for (KafkaMetricsListener listener : listeners) {
				listener.onKafkaMetricRemoved(mi);
			}
		}
	}
}
 
開發者ID:turn,項目名稱:kafka-metrics,代碼行數:24,代碼來源:KafkaClientMetricSet.java

示例9: extractKafkaTsdbName

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
/**
 * Create a TSDB-compatible name from the Kafka Yammer name.
 *
 * Basically, join {@code group}, {@code type}, and {@code name} with {@code '.'}.
 *
 * @param originalName
 * @return a string representing the TSDB metric name for this Yammer metric name.
 */
private static String extractKafkaTsdbName(MetricName originalName) {
	String ret = "";

	String[] components = new String[] {originalName.getGroup(), originalName.getType(), originalName.getName()};

	String delimiter = "";
	for (String s : components) {
		if (s != null && s.length() > 0) {
			ret += delimiter + s;
			delimiter = ".";
		}
	}

	return ret;
}
 
開發者ID:turn,項目名稱:kafka-metrics,代碼行數:24,代碼來源:MetricInfo.java

示例10: getStats

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
@ManagedAttribute
public Map<String, Object> getStats() {
    Map<String, Object> stats = new HashMap<String, Object>();
    
    MetricsRegistry registry = Metrics.defaultRegistry();
    for (Entry<MetricName, Metric> e : registry.allMetrics().entrySet()) {
        MetricName name = e.getKey();
        Metric metric = e.getValue();
        
        if (metric instanceof Meter) {
            Meter m = (Meter) metric;
            stats.put(name.toString(), new MeterPOJO(m));
        } else if (metric instanceof Gauge) {
            Gauge<?> g = (Gauge<?>) metric;
            stats.put(name.toString(), g.value());
        }
    }
    
    return stats;
}
 
開發者ID:pulsarIO,項目名稱:jetstream,代碼行數:21,代碼來源:KafkaMetrics.java

示例11: testFetchGauge

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
@Test
public void testFetchGauge() throws Exception {
  final MetricName name = new MetricName("gr", "t1", "n1");
  metricsRegistry.newGauge(name, new Gauge<Integer>() {
    @Override
    public Integer value() {
      return 123;
    }});

  final MuninDataSourceFactory dataSourceFactory = new MuninDataSourceFactory();
  Map<String, MuninGraph> graphs = new HashMap<String, MuninGraph>() {{
    put("foo", new MuninGraph("foo", "gr", "t", asList(
        dataSourceFactory.forMetric(name, null, null, new MuninDataSourceConfig()))));
  }};

  MetricsCommandProcessor sut = new MetricsCommandProcessor(metricsRegistry, new StaticMuninGraphProvider(graphs), hostname);

  assertEquals(asList(
    "n1__value_gauge.value 123",
    "."
    )
    , sut.processCommand("fetch", asList("foo")));
}
 
開發者ID:spotify,項目名稱:metrics-munin-reporter,代碼行數:24,代碼來源:MetricsCommandProcessorTest.java

示例12: addMetered

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
/**
 * Add Metered metric
 * @param baseName
 * @param metered
 */

void addMetered(MetricName baseName, Metered metered) {
    addMetric(metered, baseName,
            SignalFxReporter.MetricDetails.COUNT,
            SignalFxProtocolBuffers.MetricType.CUMULATIVE_COUNTER, metered.count());
    addMetric(metered, baseName,
            SignalFxReporter.MetricDetails.RATE_15_MIN,
            SignalFxProtocolBuffers.MetricType.GAUGE, metered.fifteenMinuteRate());
    addMetric(metered, baseName,
            SignalFxReporter.MetricDetails.RATE_1_MIN,
            SignalFxProtocolBuffers.MetricType.GAUGE, metered.oneMinuteRate());
    addMetric(metered, baseName,
            SignalFxReporter.MetricDetails.RATE_5_MIN,
            SignalFxProtocolBuffers.MetricType.GAUGE, metered.fiveMinuteRate());

    addMetric(metered, baseName,
            SignalFxReporter.MetricDetails.RATE_MEAN,
            SignalFxProtocolBuffers.MetricType.GAUGE, metered.meanRate());
}
 
開發者ID:signalfx,項目名稱:signalfx-java,代碼行數:25,代碼來源:AggregateMetricSenderSessionWrapper.java

示例13: testFetchHistogram

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
@Test
public void testFetchHistogram() throws Exception {
  final MetricName name = new MetricName("gr", "t1", "h1");
  Histogram histogram = metricsRegistry.newHistogram(name, false);
  histogram.update(1);
  histogram.update(1);
  histogram.update(3);

  final MuninDataSourceFactory dataSourceFactory = new MuninDataSourceFactory();
  Map<String, MuninGraph> graphs = new HashMap<String, MuninGraph>() {{
    put("foo", new MuninGraph("foo", "gr", "t", asList(
        dataSourceFactory.forMetric(name, null, null, new MuninDataSourceConfig()))));
  }};

  MetricsCommandProcessor sut = new MetricsCommandProcessor(metricsRegistry, new StaticMuninGraphProvider(graphs), hostname);

  assertEquals(asList(
    "h1__median.value 1",
    "."
  )
  , sut.processCommand("fetch", asList("foo")));
}
 
開發者ID:spotify,項目名稱:metrics-munin-reporter,代碼行數:23,代碼來源:MetricsCommandProcessorTest.java

示例14: createNewMetricsGroup

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
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);
}
 
開發者ID:apache,項目名稱:incubator-blur,代碼行數:25,代碼來源:HdfsDirectory.java

示例15: getValueAndReset

import com.yammer.metrics.core.MetricName; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:staslev,項目名稱:storm-metrics-reporter,代碼行數:21,代碼來源:YammerFacadeMetric.java


注:本文中的com.yammer.metrics.core.MetricName類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。