io.micrometer.core.instrument.Measurement.getStatistic()方法的使用及代码示例

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

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

Measurement.getStatistic介绍

暂无

代码示例

代码示例来源:origin: line/armeria

private static String measurementName(Meter.Id id, Measurement measurement) {
  final StringBuilder buf = new StringBuilder();
  // Append name.
  buf.append(id.getName());
  // Append statistic.
  buf.append('#');
  buf.append(measurement.getStatistic().getTagValueRepresentation());
  // Append tags if there are any.
  final Iterator<Tag> tagsIterator = id.getTags().iterator();
  if (tagsIterator.hasNext()) {
    buf.append('{');
    tagsIterator.forEachRemaining(tag -> buf.append(tag.getKey()).append('=')
                        .append(tag.getValue()).append(','));
    buf.setCharAt(buf.length() - 1, '}');
  }
  return buf.toString();
}

代码示例来源:origin: org.springframework.boot/spring-boot-actuator

private void mergeMeasurements(Map<Statistic, Double> samples, Meter meter) {
  meter.measure().forEach((measurement) -> samples.merge(measurement.getStatistic(),
      measurement.getValue(), mergeFunction(measurement.getStatistic())));
}

代码示例来源:origin: io.micrometer/micrometer-registry-elastic

Optional<String> writeMeter(Meter meter) {
  return Optional.of(writeDocument(meter, builder -> {
    for (Measurement measurement : meter.measure()) {
      builder.append(",\"").append(measurement.getStatistic().getTagValueRepresentation()).append("\":\"").append(measurement.getValue()).append("\"");
    }
  }));
}

代码示例来源:origin: io.micrometer/micrometer-registry-cloudwatch

private Stream<MetricDatum> metricData(Meter m) {
  return stream(m.measure().spliterator(), false)
      .map(ms -> metricDatum(m.getId().withTag(ms.getStatistic()), ms.getValue()))
      .filter(Objects::nonNull);
}

代码示例来源:origin: io.micrometer/micrometer-registry-stackdriver

private Stream<TimeSeries> createMeter(Batch batch, Meter m) {
  return stream(m.measure().spliterator(), false)
      .map(ms -> batch.createTimeSeries(m, ms.getValue(), ms.getStatistic().getTagValueRepresentation()));
}

代码示例来源:origin: io.micrometer/micrometer-registry-new-relic

private Stream<String> writeMeter(Meter meter) {
  return Stream.of(
      event(meter.getId(),
          stream(meter.measure().spliterator(), false)
              .map(measure -> new Attribute(measure.getStatistic().getTagValueRepresentation(), measure.getValue()))
              .toArray(Attribute[]::new)
      )
  );
}

代码示例来源:origin: io.micrometer/micrometer-registry-datadog

private Stream<String> writeMeter(Meter m, Map<String, DatadogMetricMetadata> metadata) {
  long wallTime = clock.wallTime();
  return stream(m.measure().spliterator(), false)
      .map(ms -> {
        Meter.Id id = m.getId().withTag(ms.getStatistic());
        addToMetadataList(metadata, id, null, ms.getStatistic(), null);
        return writeMetric(id, null, wallTime, ms.getValue());
      });
}

代码示例来源:origin: io.micrometer/micrometer-registry-appoptics

private Optional<String> writeMeter(Meter meter) {
  return Optional.of(StreamSupport.stream(meter.measure().spliterator(), false)
      .map(ms -> write(meter.getId().withTag(ms.getStatistic()), null, Fields.Value.tag(), decimal(ms.getValue())))
      .collect(joining(",")));
}

代码示例来源:origin: io.micrometer/micrometer-registry-signalfx

private Stream<SignalFxProtocolBuffers.DataPoint.Builder> addMeter(Meter meter) {
  return stream(meter.measure().spliterator(), false).flatMap(measurement -> {
    String statSuffix = NamingConvention.camelCase.tagKey(measurement.getStatistic().toString());
    switch (measurement.getStatistic()) {
      case TOTAL:
      case TOTAL_TIME:
      case COUNT:
      case DURATION:
        return Stream.of(addDatapoint(meter, COUNTER, statSuffix, measurement.getValue()));
      case MAX:
      case VALUE:
      case UNKNOWN:
      case ACTIVE_TASKS:
        return Stream.of(addDatapoint(meter, GAUGE, statSuffix, measurement.getValue()));
    }
    return Stream.empty();
  });
}

代码示例来源:origin: Netflix/spectator

/** Helper for converting Micrometer measurements to Spectator measurements. */
 Iterable<Measurement> convert(Iterable<io.micrometer.core.instrument.Measurement> ms) {
  long now = Clock.SYSTEM.wallTime();
  List<Measurement> measurements = new ArrayList<>();
  for (io.micrometer.core.instrument.Measurement m : ms) {
   Id measurementId = id.withTag("statistic", m.getStatistic().getTagValueRepresentation());
   measurements.add(new Measurement(measurementId, now, m.getValue()));
  }
  return measurements;
 }
}

代码示例来源:origin: io.micrometer/micrometer-registry-ganglia

private void announceMeter(Meter meter) {
  for (Measurement measurement : meter.measure()) {
    announce(meter, measurement.getValue(), measurement.getStatistic().toString().toLowerCase());
  }
}

代码示例来源:origin: io.micrometer/micrometer-registry-wavefront

private Stream<String> writeMeter(Meter meter) {
  long wallTime = clock.wallTime();
  Stream.Builder<String> metrics = Stream.builder();
  stream(meter.measure().spliterator(), false)
      .forEach(measurement -> {
        Meter.Id id = meter.getId().withTag(measurement.getStatistic());
        addMetric(metrics, id, null, wallTime, measurement.getValue());
      });
  return metrics.build();
}

代码示例来源:origin: io.micrometer/micrometer-test

@Test
@DisplayName("function timers respect the base unit of an underlying registry")
void functionTimerUnits(MeterRegistry registry) {
  Object o = new Object();
  registry.more().timer("function.timer", emptyList(),
    o, o2 -> 1, o2 -> 1, TimeUnit.MILLISECONDS);
  FunctionTimer ft = registry.get("function.timer").functionTimer();
  clock(registry).add(step());
  assertThat(ft.measure())
    .anySatisfy(ms -> {
      TimeUnit baseUnit = TimeUnit.valueOf(requireNonNull(ft.getId().getBaseUnit()).toUpperCase());
      assertThat(ms.getStatistic()).isEqualTo(Statistic.TOTAL_TIME);
      assertThat(TimeUtils.convert(ms.getValue(), baseUnit, TimeUnit.MILLISECONDS)).isEqualTo(1);
    });
}

代码示例来源:origin: io.micrometer/micrometer-registry-kairos

private Stream<String> writeCustomMetric(Meter meter) {
  long wallTime = config().clock().wallTime();
  List<Tag> tags = getConventionTags(meter.getId());
  return StreamSupport.stream(meter.measure().spliterator(), false)
      .map(ms -> new KairosMetricBuilder()
          .field("name", ms.getStatistic().getTagValueRepresentation())
          .datapoints(wallTime, ms.getValue())
          .tags(tags)
          .build());
}

代码示例来源:origin: io.micrometer/micrometer-registry-statsd

@Override
protected Meter newMeter(Meter.Id id, Meter.Type type, Iterable<Measurement> measurements) {
  measurements.forEach(ms -> {
    StatsdLineBuilder line = lineBuilder(id);
    Statistic stat = ms.getStatistic();
    switch (stat) {
      case COUNT:
      case TOTAL:
      case TOTAL_TIME:
        pollableMeters.put(id.withTag(stat), () -> processor.onNext(line.count((long) ms.getValue(), stat)));
        break;
      case VALUE:
      case ACTIVE_TASKS:
      case DURATION:
      case UNKNOWN:
        pollableMeters.put(id.withTag(stat), () -> processor.onNext(line.gauge(ms.getValue(), stat)));
        break;
    }
  });
  return new DefaultMeter(id, type, measurements);
}

代码示例来源:origin: io.vertx/vertx-micrometer-metrics

public static List<Datapoint> listDatapoints(String regName, Predicate<Meter> predicate) {
 List<Datapoint> result = new ArrayList<>();
 MeterRegistry registry = BackendRegistries.getNow(regName);
 if (registry == null) {
  throw new NoRegistryException(regName);
 }
 registry.forEachMeter(m -> {
  if (predicate.test(m)) {
   String id = id(m);
   m.measure().forEach(measurement -> {
    result.add(new Datapoint(id + "$" + measurement.getStatistic().name(), measurement.getValue()));
   });
  }
 });
 return result;
}

代码示例来源:origin: io.micrometer/micrometer-registry-statsd

m -> {
  for (Measurement measurement : m.measure()) {
    pollableMeters.remove(m.getId().withTag(measurement.getStatistic()));

代码示例来源:origin: io.rsocket.rpc/rsocket-rpc-core

private Meter convert(io.micrometer.core.instrument.Meter meter) {
 Meter.Builder meterBuilder = Meter.newBuilder();
 MeterId.Builder idBuilder = MeterId.newBuilder();
 io.micrometer.core.instrument.Meter.Id id = meter.getId();
 io.micrometer.core.instrument.Meter.Type type = id.getType();
 for (Tag tag : id.getTags()) {
  idBuilder.addTag(MeterTag.newBuilder().setKey(tag.getKey()).setValue(tag.getValue()));
 }
 idBuilder.setName(id.getName());
 idBuilder.setType(convert(type));
 if (id.getDescription() != null) {
  idBuilder.setDescription(id.getDescription());
 }
 if (id.getBaseUnit() != null) {
  idBuilder.setBaseUnit(id.getBaseUnit());
 }
 meterBuilder.setId(idBuilder);
 for (Measurement measurement : meter.measure()) {
  meterBuilder.addMeasure(
    MeterMeasurement.newBuilder()
      .setValue(measurement.getValue())
      .setStatistic(convert(measurement.getStatistic())));
 }
 return meterBuilder.build();
}

相关文章