io.micrometer.core.instrument.Gauge类的使用及代码示例

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

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

Gauge介绍

暂无

代码示例

代码示例来源:origin: resilience4j/resilience4j

@Override
  public void bindTo(MeterRegistry registry) {
    for (RateLimiter rateLimiter : rateLimiters) {
      final String name = rateLimiter.getName();
      Gauge.builder(getName(prefix, name, AVAILABLE_PERMISSIONS), rateLimiter, (cb) -> cb.getMetrics().getAvailablePermissions())
          .register(registry);
      Gauge.builder(getName(prefix, name, WAITING_THREADS), rateLimiter, (cb) -> cb.getMetrics().getNumberOfWaitingThreads())
          .register(registry);
    }
  }
}

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

private Stream<MetricDatum> gaugeData(Gauge gauge) {
  double value = gauge.value();
  if (!Double.isFinite(value))
    return Stream.empty();
  return Stream.of(metricDatum(gauge.getId(), "value", value));
}

代码示例来源:origin: org.ballerinalang/ballerina-micrometer-extension

@Override
  public double get() {
    return gauge.value();
  }
}

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

@Test
  @DisplayName("strong reference gauges")
  default void strongReferenceGauges(MeterRegistry registry) {
    Gauge.builder("weak.ref", 1.0, n -> n).register(registry);
    Gauge.builder("strong.ref", 1.0, n -> n)
        .strongReference(true)
        .register(registry);

    System.gc();

    assertThat(registry.get("weak.ref").gauge().value()).isEqualTo(Double.NaN);
    assertThat(registry.get("strong.ref").gauge().value()).isEqualTo(1.0);
  }
}

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

public synchronized T get(String... values) {
  // This method is synchronized to make sure the "T" built via supplier will match the one passed to Gauge
  //  since it is stored as WeakReference in Micrometer DefaultGauge, it must not be lost.
  T t = tSupplier.get();
  // Register this gauge if necessary
  // Note: we need here to go through the process of Gauge creation, even if it already exists,
  //  in order to get the Gauge ID. This ID generation is not trivial since it may involves attached MetricFilters.
  //  Micrometer will not register the gauge twice if it was already created.
  Gauge g = Gauge.builder(name, t, dGetter)
   .description(description)
   .tags(Labels.toTags(keys, values))
   .register(registry);
  return gauges.computeIfAbsent(g.getId(), v -> t);
 }
}

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

private Stream<String> writeGauge(Gauge gauge) {
  Double value = gauge.value();
  return value.isNaN() ? Stream.empty() : Stream.of(event(gauge.getId(), new Attribute("value", value)));
}

代码示例来源:origin: com.expedia.www/haystack-client-micrometer

@Override
  public double value() {
    return delegate.value();
  }
}

代码示例来源:origin: resilience4j/resilience4j

@Override
  public void bindTo(MeterRegistry registry) {
    for (Bulkhead bulkhead : bulkheads) {
      final String name = bulkhead.getName();
      Gauge.builder(getName(prefix, name, AVAILABLE_CONCURRENT_CALLS), bulkhead, (cb) -> cb.getMetrics().getAvailableConcurrentCalls())
          .register(registry);
    }
  }
}

代码示例来源:origin: de.codecentric/batch-web-spring-boot-autoconfigure

@Override
public String format(Collection<Gauge> gauges, Collection<Timer> timers) {
  StringBuilder builder = new StringBuilder("\n########## Metrics Start ##########\n");
  gauges.stream().forEach(gauge -> {
    builder.append("Gauge [" + gauge.getId() + "]: ");
    builder.append(gauge.value() + "\n");
  });
  timers.stream().forEach(timer -> {
    builder.append("Timer [" + timer.getId() + "]: ");
    builder.append(
        "totalTime=" + timer.totalTime(timer.baseTimeUnit()) + " " + timer.baseTimeUnit() + "\n");
  });
  builder.append("########## Metrics End ############");
  return builder.toString();
}

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

@Override public double value() {
 return impl.value();
}

代码示例来源:origin: resilience4j/resilience4j

@Override
  public void bindTo(MeterRegistry registry) {
    for (Retry retry : retries) {
      final String name = retry.getName();
      Gauge.builder(getName(prefix, name, SUCCESSFUL_CALLS_WITHOUT_RETRY), retry, (cb) -> cb.getMetrics().getNumberOfSuccessfulCallsWithoutRetryAttempt())
          .register(registry);
      Gauge.builder(getName(prefix, name, SUCCESSFUL_CALLS_WITH_RETRY), retry, (cb) -> cb.getMetrics().getNumberOfSuccessfulCallsWithRetryAttempt())
          .register(registry);
      Gauge.builder(getName(prefix, name, FAILED_CALLS_WITHOUT_RETRY), retry, (cb) -> cb.getMetrics().getNumberOfFailedCallsWithoutRetryAttempt())
          .register(registry);
      Gauge.builder(getName(prefix, name, FAILED_CALLS_WITH_RETRY), retry, (cb) -> cb.getMetrics().getNumberOfFailedCallsWithRetryAttempt())
          .register(registry);
    }
  }
}

代码示例来源:origin: codecentric/spring-boot-starter-batch-web

@Override
public String format(Collection<Gauge> gauges, Collection<Timer> timers) {
  StringBuilder builder = new StringBuilder("\n########## Metrics Start ##########\n");
  gauges.stream().forEach(gauge -> {
    builder.append("Gauge [" + gauge.getId() + "]: ");
    builder.append(gauge.value() + "\n");
  });
  timers.stream().forEach(timer -> {
    builder.append("Timer [" + timer.getId() + "]: ");
    builder.append(
        "totalTime=" + timer.totalTime(timer.baseTimeUnit()) + " " + timer.baseTimeUnit() + "\n");
  });
  builder.append("########## Metrics End ############");
  return builder.toString();
}

代码示例来源:origin: org.apache.camel/camel-micrometer

@Override
  protected void serializeStatistics(Gauge gauge, JsonGenerator json, SerializerProvider provider) throws IOException {
    json.writeNumberField("value", gauge.value());
  }
}

代码示例来源:origin: resilience4j/resilience4j

@Override
  public void bindTo(MeterRegistry registry) {
    for (CircuitBreaker circuitBreaker : circuitBreakers) {
      final String name = circuitBreaker.getName();
      Gauge.builder(getName(prefix, name, STATE), circuitBreaker, (cb) -> cb.getState().getOrder())
          .register(registry);
      Gauge.builder(getName(prefix, name, BUFFERED_MAX), circuitBreaker, (cb) -> cb.getMetrics().getMaxNumberOfBufferedCalls())
          .register(registry);
      Gauge.builder(getName(prefix, name, BUFFERED), circuitBreaker, (cb) -> cb.getMetrics().getNumberOfBufferedCalls())
          .register(registry);
      Gauge.builder(getName(prefix, name, FAILED), circuitBreaker, (cb) -> cb.getMetrics().getNumberOfFailedCalls())
          .register(registry);
      Gauge.builder(getName(prefix, name, NOT_PERMITTED), circuitBreaker, (cb) -> cb.getMetrics().getNumberOfNotPermittedCalls())
          .register(registry);
      Gauge.builder(getName(prefix, name, SUCCESSFUL), circuitBreaker, (cb) -> cb.getMetrics().getNumberOfSuccessfulCalls())
          .register(registry);
    }
  }
}

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

Optional<String> writeGauge(Gauge gauge) {
  double value = gauge.value();
  if (!Double.isFinite(value)) {
    return Optional.empty();
  }
  return Optional.of(write(gauge.getId(), "gauge", Fields.Value.tag(), decimal(value)));
}

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

private static JsonObject gaugeToJson(JsonObject obj, Gauge gauge) {
 return obj.put("type", "gauge")
  .put("value", gauge.value());
}

代码示例来源:origin: spring-projects/spring-integration

protected MicroGaugeBuilder(MeterRegistry meterRegistry, String name, Object obj, ToDoubleFunction<Object> f) {
  this.meterRegistry = meterRegistry;
  this.builder = Gauge.builder(name, obj, f);
}

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

Stream<String> writeGauge(Gauge gauge) {
  Double value = gauge.value();
  if (Double.isFinite(value)) {
    return Stream.of(writeMetric(gauge.getId(), config().clock().wallTime(), value));
  }
  return Stream.empty();
}

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

private void announceGauge(Gauge gauge) {
  announce(gauge, gauge.value());
}

代码示例来源:origin: com.zaxxer/HikariCP

this.totalConnectionGauge = Gauge.builder(METRIC_NAME_TOTAL_CONNECTIONS, poolStats, PoolStats::getTotalConnections)
  .description("Total connections")
  .tags(METRIC_CATEGORY, poolName)
  .register(meterRegistry);
this.idleConnectionGauge = Gauge.builder(METRIC_NAME_IDLE_CONNECTIONS, poolStats, PoolStats::getIdleConnections)
  .description("Idle connections")
  .tags(METRIC_CATEGORY, poolName)
  .register(meterRegistry);
this.activeConnectionGauge = Gauge.builder(METRIC_NAME_ACTIVE_CONNECTIONS, poolStats, PoolStats::getActiveConnections)
  .description("Active connections")
  .tags(METRIC_CATEGORY, poolName)
  .register(meterRegistry);
this.pendingConnectionGauge = Gauge.builder(METRIC_NAME_PENDING_CONNECTIONS, poolStats, PoolStats::getPendingThreads)
  .description("Pending threads")
  .tags(METRIC_CATEGORY, poolName)
  .register(meterRegistry);
this.maxConnectionGauge = Gauge.builder(METRIC_NAME_MAX_CONNECTIONS, poolStats, PoolStats::getMaxConnections)
  .description("Max connections")
  .tags(METRIC_CATEGORY, poolName)
  .register(meterRegistry);
this.minConnectionGauge = Gauge.builder(METRIC_NAME_MIN_CONNECTIONS, poolStats, PoolStats::getMinConnections)
  .description("Min connections")
  .tags(METRIC_CATEGORY, poolName)

相关文章