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

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

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

Gauge.builder介绍

暂无

代码示例

代码示例来源: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: 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: 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: 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: 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: 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)

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

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

代码示例来源:origin: zalando/riptide

private void gauge(final MeterRegistry registry, final String name, final Supplier<PoolStats> stats,
    final Function<PoolStats, Number> function) {
  Gauge.builder(metricName + "." + name, () -> function.apply(stats.get()))
      .tags(defaultTags)
      .register(registry);
}

代码示例来源:origin: org.molgenis/molgenis-security

@Override
public void bindTo(@Nonnull MeterRegistry meterRegistry) {
 Gauge.builder("spring.sessions", sessions, SessionMetrics::getSessions)
   .description("The number of sessions, including expired sessions")
   .register(meterRegistry);
}

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

@Override
  public void bindTo(MeterRegistry registry) {
    if (registry instanceof StatsdMeterRegistry) {
      StatsdMeterRegistry statsdRegistry = (StatsdMeterRegistry) registry;

      Gauge.builder("statsd.queue.size", statsdRegistry, StatsdMeterRegistry::queueSize)
          .description("The total number of StatsD events queued for transmission over UDP")
          .register(statsdRegistry);

      Gauge.builder("statsd.queue.capacity", statsdRegistry, StatsdMeterRegistry::queueCapacity)
          .description("The maximum number of StatsD events that can be queued for transmission")
          .register(statsdRegistry);
    }
  }
}

代码示例来源: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: org.ballerinalang/ballerina-micrometer-extension

public MicrometerGauge(MeterRegistry meterRegistry, MetricId id) {
  super(id);
  io.micrometer.core.instrument.Gauge.builder(id.getName(), value, DoubleAdder::sum)
      .description(id.getDescription())
      .tags(id.getTags().stream().map(tag -> Tag.of(tag.getKey(), tag.getValue()))
          .collect(Collectors.toList())).register(meterRegistry);
}

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

@Override
protected void doStart() throws Exception {
  super.doStart();
  Gauge.builder(namingStrategy.getRouteAddedName(), routesAdded, value -> Long.valueOf(value.get()).doubleValue())
      .baseUnit("routes")
      .tags(namingStrategy.getTags(getCamelContext()))
      .register(getMeterRegistry());
  Gauge.builder(namingStrategy.getRouteRunningName(), routesRunning, value -> Long.valueOf(value.get()).doubleValue())
      .baseUnit("routes")
      .tags(namingStrategy.getTags(getCamelContext()))
      .register(getMeterRegistry());
}

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

public <T> MicrometerCallbackGauge(MeterRegistry meterRegistry, MetricId id, T obj,
                  ToDoubleFunction<T> toDoubleFunction) {
  super(id);
  gauge = io.micrometer.core.instrument.Gauge.builder(id.getName(), obj, toDoubleFunction)
      .description(id.getDescription())
      .tags(id.getTags().stream().map(tag -> Tag.of(tag.getKey(), tag.getValue()))
          .collect(Collectors.toList())).register(meterRegistry);
}

代码示例来源: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: com.expedia.www/haystack-client-micrometer

@Override
public <T> Gauge gauge(String name, Collection<Tag> tags, T obj, ToDoubleFunction<T> f) {
  return new MicrometerGauge<T>(io.micrometer.core.instrument.Gauge.builder(name, obj, f).tags(toTags(tags)).register(registry));
}

代码示例来源:origin: infinispan/infinispan-spring-boot

private void averages(MeterRegistry registry) {
 Gauge.builder("cache.puts.latency", cache, cache -> cache.clientStatistics().getAverageRemoteStoreTime())
    .tags(getTagsWithCacheName())
    .description("Cache puts")
    .register(registry);
 Gauge.builder("cache.gets.latency", cache, cache -> cache.clientStatistics().getAverageRemoteReadTime())
    .tags(getTagsWithCacheName())
    .description("Cache gets")
    .register(registry);
 Gauge.builder("cache.removes.latency", cache, cache -> cache.clientStatistics().getAverageRemoteRemovesTime())
    .tags(getTagsWithCacheName())
    .description("Cache removes")
    .register(registry);
}

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

@Override public Gauge gauge(Id id) {
 AtomicDouble value = new AtomicDouble(Double.NaN);
 io.micrometer.core.instrument.Gauge gauge = io.micrometer.core.instrument.Gauge
   .builder(id.name(), value, AtomicDouble::get)
   .tags(convert(id.tags()))
   .register(impl);
 return new MicrometerGauge(id, value::set, gauge);
}

代码示例来源:origin: infinispan/infinispan-spring-boot

@Override
protected void bindImplementationSpecificMetrics(MeterRegistry registry) {
 if (cache == null) return;
 Gauge.builder("cache.reset", cache, cache -> cache.clientStatistics().getTimeSinceReset())
    .tags(getTagsWithCacheName()).tag("ownership", "backup")
    .description("Time elapsed in seconds since the last statistics reset")
    .register(registry);
 averages(registry);
 nearCacheMetrics(registry);
}

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

@Override public Gauge maxGauge(Id id) {
 // Note: micrometer doesn't support this type directly so it uses an arbitrary
 // window of 1m
 StepDouble value = new StepDouble(Double.NaN, clock(), 60000L);
 io.micrometer.core.instrument.Gauge gauge = io.micrometer.core.instrument.Gauge
   .builder(id.name(), value, StepDouble::poll)
   .tags(convert(id.tags()))
   .register(impl);
 return new MicrometerGauge(id, v -> value.getCurrent().max(v), gauge);
}

相关文章