当前位置: 首页>>代码示例>>Java>>正文


Java Meter.measure方法代码示例

本文整理汇总了Java中com.netflix.spectator.api.Meter.measure方法的典型用法代码示例。如果您正苦于以下问题:Java Meter.measure方法的具体用法?Java Meter.measure怎么用?Java Meter.measure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.netflix.spectator.api.Meter的用法示例。


在下文中一共展示了Meter.measure方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addMeterToTimeSeries

import com.netflix.spectator.api.Meter; //导入方法依赖的package包/类
/**
 * Add a TimeSeries for each appropriate meter measurement.
 */
void addMeterToTimeSeries(
      Registry registry, Meter meter, List<TimeSeries> tsList) {
  Iterable<Measurement> measurements = meter.measure();
  boolean applyFilter = true;

  if (cache.meterIsTimer(registry, meter)) {
     measurements = transformTimerMeasurements(measurements);
     applyFilter = false;
  }
  for (Measurement measurement : measurements) {
    if (applyFilter && !measurementFilter.test(measurement)) {
      continue;
    }

    String descriptorType = cache.idToDescriptorType(measurement.id());
    tsList.add(measurementToTimeSeries(descriptorType, registry, meter, measurement));
  }
}
 
开发者ID:spinnaker,项目名称:kork,代码行数:22,代码来源:StackdriverWriter.java

示例2: measure

import com.netflix.spectator.api.Meter; //导入方法依赖的package包/类
private Iterable<Measurement> measure() {
  Map<Id, Measurement> measurements = new HashMap<>();
  Iterator<Meter> iter = queue.iterator();
  while (iter.hasNext()) {
    Meter meter = iter.next();
    if (meter.hasExpired()) {
      iter.remove();
    } else {
      for (Measurement m : meter.measure()) {
        Measurement prev = measurements.get(m.id());
        if (prev == null) {
          measurements.put(m.id(), m);
        } else {
          double v = prev.value() + m.value();
          measurements.put(prev.id(), new Measurement(prev.id(), prev.timestamp(), v));
        }
      }
    }
  }
  return measurements.values();
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:22,代码来源:PolledMeter.java

示例3: run

import com.netflix.spectator.api.Meter; //导入方法依赖的package包/类
public static Collection<String> run() throws Exception {
  ManualClock clock = new ManualClock();
  clock.setWallTime(1234567890L);
  Registry r = new DefaultRegistry(clock);
  checkDistributionSummary(r);
  checkTimer(r);
  checkLongTaskTimer(r);
  checkCounter(r);
  checkGauge(r);

  // Histogram utilities
  checkBucketCounter(r, "age");
  checkBucketCounter(r, "ageBiasOld");
  checkBucketCounter(r, "latency");
  checkBucketCounter(r, "latencyBiasSlow");
  checkBucketCounter(r, "bytes");
  checkBucketCounter(r, "decimal");
  checkBucketDistributionSummary(r);
  checkBucketTimer(r);
  checkPercentileDistributionSummary(r);
  checkPercentileTimer(r);

  List<String> ms = new ArrayList<>();
  for (Meter meter : r) {
    for (Measurement m : meter.measure()) {
      ms.add(m.toString());
    }
  }
  Collections.sort(ms);
  return ms.stream()
      .filter(s -> !s.contains("non-deterministic"))
      .collect(Collectors.toList());
}
 
开发者ID:brharrington,项目名称:spectator-examples,代码行数:34,代码来源:Main.java

示例4: checkIdTagValue

import com.netflix.spectator.api.Meter; //导入方法依赖的package包/类
private void checkIdTagValue(Meter meter, String expectedIdValue) {
  final Iterable<Measurement> measurements = meter.measure();
  final Iterator<Measurement> measurementIterator = measurements.iterator();
  assertTrue(measurementIterator.hasNext());

  final Iterator<Tag> tags = measurementIterator.next().id().tags().iterator();
  assertTrue(tags.hasNext());
  Tag tag = tags.next();
  assertEquals(ThreadPoolMonitor.ID_TAG_NAME, tag.key());
  assertEquals(expectedIdValue, tag.value());
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:12,代码来源:ThreadPoolMonitorTest.java

示例5: encodeRegistry

import com.netflix.spectator.api.Meter; //导入方法依赖的package包/类
/**
 * Internal API for encoding a registry that can be encoded as JSON.
 * This is a helper function for the REST endpoint and to test against.
 */
Map<String, MetricValues> encodeRegistry(
      Registry sourceRegistry, Predicate<Measurement> filter) {
  Map<String, MetricValues> metricMap = new HashMap<String, MetricValues>();

  /**
   * Flatten the meter measurements into a map of measurements keyed by
   * the name and mapped to the different tag variants.
   */
  for (Meter meter : sourceRegistry) {
    String kind = knownMeterKinds.computeIfAbsent(
                       meter.id(), k -> meterToKind(sourceRegistry, meter));

    for (Measurement measurement : meter.measure()) {
      if (!filter.test(measurement)) {
        continue;
      }

      String measurementName = measurement.id().name();
      MetricValues have = metricMap.get(measurementName);
      if (have == null) {
        metricMap.put(measurementName, new MetricValues(kind, measurement));
      } else {
        have.addMeasurement(measurement);
      }
    }
  }
  return metricMap;
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:33,代码来源:MetricsController.java

示例6: start

import com.netflix.spectator.api.Meter; //导入方法依赖的package包/类
/**
 * Start sending data to the sidecar.
 *
 * @param url
 *     Location of the sidecar endpoint.
 * @param pollPeriod
 *     How frequently to poll the data and send to the sidecar.
 * @param pollUnit
 *     Unit for the {@code pollPeriod}.
 */
public void start(final URL url, long pollPeriod, TimeUnit pollUnit) {
  logger.info("starting sidecar registry with url {} and poll period {} {}",
      url, pollPeriod, pollUnit);
  executor = Executors.newSingleThreadScheduledExecutor(
      r -> {
        final Thread t = new Thread(r, "spectator-sidecar");
        t.setDaemon(true);
        return t;
      }
  );

  final SidecarRegistry self = this;
  Runnable task = () -> {
    try {
      List<Measurement> ms = new ArrayList<>();
      for (Meter meter : self) {
        for (Measurement m : meter.measure()) {
          ms.add(m);
        }
      }
      postJson(url, ms);
    } catch (Exception e) {
      logger.error("failed to send data to sidecar", e);
    }
  };
  executor.scheduleWithFixedDelay(task, pollPeriod, pollPeriod, pollUnit);
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:38,代码来源:SidecarRegistry.java

示例7: getValue

import com.netflix.spectator.api.Meter; //导入方法依赖的package包/类
private long getValue(String name) {
  Meter meter = registry.get(registry.createId(name));
  if (meter != null) {
    for (Measurement m : meter.measure()) {
      return (long) m.value();
    }
  }
  return Long.MAX_VALUE;
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:10,代码来源:SpectatorReporterTest.java


注:本文中的com.netflix.spectator.api.Meter.measure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。