io.prometheus.client.Gauge.setChild()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(240)

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

Gauge.setChild介绍

暂无

代码示例

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

@SuppressWarnings("unchecked")
@Override
protected <T> io.micrometer.core.instrument.Gauge newGauge(Meter.Id id, T obj, ToDoubleFunction<T> f) {
  final WeakReference<T> ref = new WeakReference<>(obj);
  io.prometheus.client.Gauge gauge = collectorByName(Gauge.class, id.getConventionName(),
    i -> buildCollector(id, io.prometheus.client.Gauge.build()));
  String[] labelValues = id.getConventionTags().stream()
    .map(Tag::getValue)
    .collect(Collectors.toList())
    .toArray(new String[]{});
  Gauge.Child child = new Gauge.Child() {
    @Override
    public double get() {
      final T obj2 = ref.get();
      return (obj2 == null) ? Double.NaN : f.applyAsDouble(obj2);
    }
  };
  gauge.setChild(child, labelValues);
  return new PrometheusGauge(id, child);
}

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

@SuppressWarnings("unchecked")
@Override
public <T> T gauge(String name, Iterable<Tag> tags, T obj, ToDoubleFunction<T> f) {
  final WeakReference<T> ref = new WeakReference<>(obj);
  MeterId id = new MeterId(name, tags);
  io.prometheus.client.Gauge gauge = collectorByName(Gauge.class, name,
      i -> buildCollector(id, io.prometheus.client.Gauge.build()));
  computeIfAbsent(meterMap, id, g -> {
    String[] labelValues = id.getTags().stream()
        .map(Tag::getValue)
        .collect(Collectors.toList())
        .toArray(new String[]{});
    Gauge.Child child = new Gauge.Child() {
      @Override
      public double get() {
        final T obj = ref.get();
        return (obj == null) ? Double.NaN : f.applyAsDouble(obj);
      }
    };
    gauge.setChild(child, labelValues);
    return new PrometheusGauge(id, child);
  });
  return obj;
}

代码示例来源:origin: org.apache.bookkeeper.stats/prometheus-metrics-provider

registerMetrics(Gauge.build("jvm_memory_direct_bytes_used", "-").create().setChild(new Child() {
  @Override
  public double get() {
registerMetrics(Gauge.build("jvm_memory_direct_bytes_max", "-").create().setChild(new Child() {
  @Override
  public double get() {

代码示例来源:origin: com.yahoo.pulsar/pulsar-zookeeper

.setChild(new Gauge.Child() {
  @Override
  public double get() {
.setChild(new Gauge.Child() {
  @Override
  public double get() {
.setChild(new Gauge.Child() {
  @Override
  public double get() {
.setChild(new Gauge.Child() {
  @Override
  public double get() {
.setChild(new Gauge.Child() {
  @Override
  public double get() {

代码示例来源:origin: org.apache.pulsar/pulsar-zookeeper

.setChild(new Gauge.Child() {
  @Override
  public double get() {
.setChild(new Gauge.Child() {
  @Override
  public double get() {
.setChild(new Gauge.Child() {
  @Override
  public double get() {
.setChild(new Gauge.Child() {
  @Override
  public double get() {
.setChild(new Gauge.Child() {
  @Override
  public double get() {

相关文章