io.micrometer.core.instrument.MeterRegistry Java Examples

The following examples show how to use io.micrometer.core.instrument.MeterRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompositeDistributionSummary.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("ConstantConditions")
@Override
DistributionSummary registerNewMeter(MeterRegistry registry) {
    return DistributionSummary.builder(getId().getName())
            .tags(getId().getTagsAsIterable())
            .description(getId().getDescription())
            .baseUnit(getId().getBaseUnit())
            .publishPercentiles(distributionStatisticConfig.getPercentiles())
            .publishPercentileHistogram(distributionStatisticConfig.isPercentileHistogram())
            .maximumExpectedValue(distributionStatisticConfig.getMaximumExpectedValueAsDouble())
            .minimumExpectedValue(distributionStatisticConfig.getMinimumExpectedValueAsDouble())
            .distributionStatisticBufferLength(distributionStatisticConfig.getBufferLength())
            .distributionStatisticExpiry(distributionStatisticConfig.getExpiry())
            .percentilePrecision(distributionStatisticConfig.getPercentilePrecision())
            .serviceLevelObjectives(distributionStatisticConfig.getServiceLevelObjectiveBoundaries())
            .scale(scale)
            .register(registry);
}
 
Example #2
Source File: CountedThreadFactory.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Wraps a {@link ThreadFactory} with an explicit name and records the number of created, running
 * and terminated threads.
 *
 * @param delegate {@link ThreadFactory} to wrap.
 * @param registry {@link MeterRegistry} that will contain the metrics.
 * @param name name for this delegate.
 * @param tags tags that can provide additional context.
 */
public CountedThreadFactory(
    ThreadFactory delegate, MeterRegistry registry, String name, Iterable<Tag> tags) {
  this.delegate = delegate;
  this.created =
      Counter.builder("thread.factory.created")
          .tags(Tags.concat(tags, "name", name))
          .description(
              "The approximate number of threads which were created with a thread factory")
          .baseUnit(BaseUnits.THREADS)
          .register(registry);
  this.terminated =
      Counter.builder("thread.factory.terminated")
          .tags(Tags.concat(tags, "name", name))
          .description("The approximate number of threads which have finished execution")
          .baseUnit(BaseUnits.THREADS)
          .register(registry);
  Gauge.builder("thread.factory.running", running, AtomicInteger::get)
      .tags(Tags.concat(tags, "name", name))
      .description(
          "The approximate number of threads which have started to execute, but have not terminated")
      .baseUnit(BaseUnits.THREADS)
      .register(registry);
}
 
Example #3
Source File: MicrometerBasedMetricsTest.java    From hono with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Verifies that the payload size is calculated based on the configured minimum message size 
 * when reporting command messages.
 *
 * @param registry The registry that the tests should be run against.
 */
@ParameterizedTest
@MethodSource("registries")
public void testPayloadSizeForCommandMessages(final MeterRegistry registry) {

    final Metrics metrics = new MicrometerBasedMetrics(registry, mock(Vertx.class));
    final TenantObject tenantObject = TenantObject.from("TEST_TENANT", true)
            .setMinimumMessageSize(4 * 1024);

    metrics.reportCommand(
            MetricsTags.Direction.REQUEST,
            "tenant",
            tenantObject,
            MetricsTags.ProcessingOutcome.FORWARDED,
            1 * 1024,
            metrics.startTimer());

    assertEquals(4 * 1024,
            registry.find(MicrometerBasedMetrics.METER_COMMANDS_PAYLOAD).summary().totalAmount());
}
 
Example #4
Source File: KafkaMetricsTest.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Issue("#1968")
@Test
void shouldRemoveOlderMeterWithLessTagsWhenCommonTagsConfigured() {
    //Given
    Map<String, String> tags = new LinkedHashMap<>();
    Supplier<Map<MetricName, ? extends Metric>> supplier = () -> {
        MetricName metricName = new MetricName("a", "b", "c", tags);
        KafkaMetric metric = new KafkaMetric(this, metricName, new Value(), new MetricConfig(), Time.SYSTEM);
        return Collections.singletonMap(metricName, metric);
    };

    kafkaMetrics = new KafkaMetrics(supplier);
    MeterRegistry registry = new SimpleMeterRegistry();
    registry.config().commonTags("common", "value");

    kafkaMetrics.bindTo(registry);
    assertThat(registry.getMeters()).hasSize(1);
    assertThat(registry.getMeters().get(0).getId().getTags()).containsExactlyInAnyOrder(Tag.of("kafka-version", "unknown"), Tag.of("common", "value")); // only version

    tags.put("key0", "value0");
    kafkaMetrics.checkAndBindMetrics(registry);
    assertThat(registry.getMeters()).hasSize(1);
    assertThat(registry.getMeters().get(0).getId().getTags()).containsExactlyInAnyOrder(Tag.of("kafka-version", "unknown"), Tag.of("key0", "value0"), Tag.of("common", "value"));
}
 
Example #5
Source File: InfinispanCacheMeterBinder.java    From infinispan-spring-boot with Apache License 2.0 6 votes vote down vote up
@Override
protected void bindImplementationSpecificMetrics(MeterRegistry registry) {
   if (cache == null) return;

   Gauge.builder("cache.start", cache, cache -> cache.getAdvancedCache().getStats().getTimeSinceStart())
         .baseUnit(TimeUnit.SECONDS.name())
         .tags(getTagsWithCacheName())
         .description("Time elapsed since start")
         .register(registry);

   Gauge.builder("cache.reset", cache, cache -> cache.getAdvancedCache().getStats().getTimeSinceReset())
         .baseUnit(TimeUnit.SECONDS.name())
         .tags(getTagsWithCacheName())
         .description("Time elapsed since the last statistics reset")
         .register(registry);

   memory(registry);
   averages(registry);
}
 
Example #6
Source File: RequestMetricSupportTest.java    From armeria with Apache License 2.0 6 votes vote down vote up
@Test
void httpFailure() {
    final MeterRegistry registry = PrometheusMeterRegistries.newRegistry();
    final ClientRequestContext ctx = setupClientRequestCtx(registry);

    ctx.logBuilder().requestFirstBytesTransferred();
    ctx.logBuilder().responseHeaders(ResponseHeaders.of(500));
    ctx.logBuilder().responseFirstBytesTransferred();
    ctx.logBuilder().responseLength(456);
    ctx.logBuilder().endRequest();
    ctx.logBuilder().endResponse();

    final Map<String, Double> measurements = measureAll(registry);
    assertThat(measurements)
            .containsEntry("foo.active.requests#value{method=POST}", 0.0)
            .containsEntry("foo.requests#count{http.status=500,method=POST,result=success}", 0.0)
            .containsEntry("foo.requests#count{http.status=500,method=POST,result=failure}", 1.0)
            .containsEntry("foo.response.duration#count{http.status=500,method=POST}", 1.0)
            .containsEntry("foo.response.length#count{http.status=500,method=POST}", 1.0)
            .containsEntry("foo.total.duration#count{http.status=500,method=POST}", 1.0);
}
 
Example #7
Source File: TimedAspectTest.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Test
void timeMethodFailureWithLongTaskTimer() {
    MeterRegistry failingRegistry = new FailingMeterRegistry();

    AspectJProxyFactory pf = new AspectJProxyFactory(new TimedService());
    pf.addAspect(new TimedAspect(failingRegistry));

    TimedService service = pf.getProxy();

    service.longCall();

    assertThatExceptionOfType(MeterNotFoundException.class).isThrownBy(() -> {
        failingRegistry.get("longCall")
                .tag("class", "io.micrometer.core.aop.TimedAspectTest$TimedService")
                .tag("method", "longCall")
                .tag("extra", "tag")
                .longTaskTimer();
    });
}
 
Example #8
Source File: LdapSearchMetrics.java    From hesperides with GNU General Public License v3.0 6 votes vote down vote up
public LdapSearchMetrics(MeterRegistry meterRegistry) {
    Gauge.builder("totalCallsCounter", this,
            LdapSearchMetrics::getTotalCallsCounterAndReset)
            .tags("class", this.getClass().getSimpleName())
            .register(meterRegistry);
    Gauge.builder("failedCallsCounter", this,
            LdapSearchMetrics::getFailedCallsCounterAndReset)
            .tags("class", this.getClass().getSimpleName())
            .register(meterRegistry);
    Gauge.builder("unexpectedExceptionCounter", this,
            LdapSearchMetrics::getUnexpectedExceptionCounterAndReset)
            .tags("class", this.getClass().getSimpleName())
            .register(meterRegistry);
    Gauge.builder("retriesExhaustedExceptionCounter", this,
            LdapSearchMetrics::getRetriesExhaustedExceptionCounterAndReset)
            .tags("class", this.getClass().getSimpleName())
            .register(meterRegistry);
}
 
Example #9
Source File: KafkaConsumerMetricsTest.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Test
void verifyConsumerMetricsWithExpectedTags() {
    try (Consumer<Long, String> consumer = createConsumer()) {

        MeterRegistry registry = new SimpleMeterRegistry();
        kafkaConsumerMetrics.bindTo(registry);

        // consumer coordinator metrics
        Gauge assignedPartitions = registry.get("kafka.consumer.assigned.partitions").tags(tags).gauge();
        assertThat(assignedPartitions.getId().getTag("client.id")).isEqualTo("consumer-" + consumerCount);

        // global connection metrics
        Gauge connectionCount = registry.get("kafka.consumer.connection.count").tags(tags).gauge();
        assertThat(connectionCount.getId().getTag("client.id")).startsWith("consumer-" + consumerCount);
    }
}
 
Example #10
Source File: FileDescriptorMetrics.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Override
public void bindTo(MeterRegistry registry) {
    if (openFilesMethod != null) {
        Gauge.builder("process.files.open", osBean, x -> invoke(openFilesMethod))
                .tags(tags)
                .description("The open file descriptor count")
                .baseUnit(BaseUnits.FILES)
                .register(registry);
    }

    if (maxFilesMethod != null) {
        Gauge.builder("process.files.max", osBean, x -> invoke(maxFilesMethod))
                .tags(tags)
                .description("The maximum file descriptor count")
                .baseUnit(BaseUnits.FILES)
                .register(registry);
    }
}
 
Example #11
Source File: MatchersTest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFilterMetric() {
  MeterRegistry registry = new SimpleMeterRegistry();
  BackendRegistries.registerMatchers(registry, EnumSet.allOf(Label.class), Collections.singletonList(new Match()
    .setLabel("address")
    .setType(MatchType.EQUALS)
    .setValue("addr1")));
  Counters counters = new Counters("my_counter", "", registry, Label.EB_ADDRESS);
  counters.get("addr1").increment();
  counters.get("addr2").increment();

  Counter c = registry.find("my_counter").tags("address", "addr1").counter();
  assertThat(c.count()).isEqualTo(1d);
  c = registry.find("my_counter").tags("address", "addr2").counter();
  assertThat(c).isNull();
}
 
Example #12
Source File: GaugesTest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldIgnoreGaugeLabel() {
  MeterRegistry registry = new SimpleMeterRegistry();
  BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match()
    .setLabel("address")
    .setType(MatchType.REGEX)
    .setValue(".*")
    .setAlias("_")));
  Gauges<LongAdder> gauges = new Gauges<>("my_gauge", "", LongAdder::new, LongAdder::doubleValue, registry, Label.EB_ADDRESS);
  gauges.get("addr1").increment();
  gauges.get("addr1").increment();
  gauges.get("addr2").increment();

  Gauge g = registry.find("my_gauge").tags("address", "_").gauge();
  assertThat(g.value()).isEqualTo(3d);
  g = registry.find("my_gauge").tags("address", "addr1").gauge();
  assertThat(g).isNull();
  g = registry.find("my_gauge").tags("address", "addr2").gauge();
  assertThat(g).isNull();
}
 
Example #13
Source File: TimerTest.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Test
@DisplayName("callable task that throws exception is still recorded")
default void recordCallableException(MeterRegistry registry) {
    Timer t = registry.timer("myTimer");

    assertThrows(Exception.class, () -> {
        t.recordCallable(() -> {
            clock(registry).add(10, TimeUnit.NANOSECONDS);
            throw new Exception("uh oh");
        });
    });

    clock(registry).add(step());

    assertAll(() -> assertEquals(1L, t.count()),
            () -> assertEquals(10, t.totalTime(TimeUnit.NANOSECONDS), 1.0e-12));
}
 
Example #14
Source File: GRpcAgentFileStreamServiceImpl.java    From genie with Apache License 2.0 6 votes vote down vote up
private TransferManager(
    final ControlStreamManager controlStreamsManager,
    final TaskScheduler taskScheduler,
    final AgentFileStreamProperties properties,
    final MeterRegistry registry
) {
    this.controlStreamsManager = controlStreamsManager;
    this.taskScheduler = taskScheduler;
    this.properties = properties;
    this.registry = registry;
    this.transferTimeOutCounter = registry.counter(TRANSFER_TIMEOUT_COUNTER);
    this.transferSizeDistribution = registry.summary(TRANSFER_SIZE_DISTRIBUTION);

    this.taskScheduler.scheduleAtFixedRate(
        this::reapStalledTransfers,
        this.properties.getStalledTransferCheckInterval()
    );
}
 
Example #15
Source File: NotificationsAutoConfiguration.java    From genie with Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link JobFinishedSNSPublisher} unless one exists in the context already.
 *
 * @param properties   configuration properties
 * @param registry     the metrics registry
 * @param snsClient    the Amazon SNS client
 * @param dataServices The {@link DataServices} instance to use
 * @return a {@link JobFinishedSNSPublisher}
 */
@Bean
@ConditionalOnProperty(value = SNSNotificationsProperties.ENABLED_PROPERTY, havingValue = "true")
@ConditionalOnMissingBean(JobFinishedSNSPublisher.class)
public JobFinishedSNSPublisher jobFinishedSNSPublisher(
    final SNSNotificationsProperties properties,
    final MeterRegistry registry,
    final AmazonSNS snsClient,
    final DataServices dataServices
) {
    return new JobFinishedSNSPublisher(
        snsClient,
        properties,
        dataServices,
        registry,
        GenieObjectMapper.getMapper()
    );
}
 
Example #16
Source File: TimedAspectTest.java    From micrometer with Apache License 2.0 5 votes vote down vote up
@Test
void timeMethodWithLongTaskTimerWhenCompleted() {
    MeterRegistry registry = new SimpleMeterRegistry();

    AspectJProxyFactory pf = new AspectJProxyFactory(new AsyncTimedService());
    pf.addAspect(new TimedAspect(registry));

    AsyncTimedService service = pf.getProxy();

    GuardedResult guardedResult = new GuardedResult();
    CompletableFuture<?> completableFuture = service.longCall(guardedResult);

    assertThat(registry.find("longCall")
            .tag("class", "io.micrometer.core.aop.TimedAspectTest$AsyncTimedService")
            .tag("method", "longCall")
            .tag("extra", "tag")
            .longTaskTimer().activeTasks()).isEqualTo(1);

    guardedResult.complete();
    completableFuture.join();

    assertThat(registry.get("longCall")
            .tag("class", "io.micrometer.core.aop.TimedAspectTest$AsyncTimedService")
            .tag("method", "longCall")
            .tag("extra", "tag")
            .longTaskTimer().activeTasks()).isEqualTo(0);
}
 
Example #17
Source File: CircuitBreakerMetricsAutoConfiguration.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnBean(MeterRegistry.class)
@ConditionalOnProperty(value = "resilience4j.circuitbreaker.metrics.legacy.enabled", havingValue = "false", matchIfMissing = true)
@ConditionalOnMissingBean
public TaggedCircuitBreakerMetricsPublisher taggedCircuitBreakerMetricsPublisher(
    MeterRegistry meterRegistry) {
    return new TaggedCircuitBreakerMetricsPublisher(meterRegistry);
}
 
Example #18
Source File: MetricCollectingClientCall.java    From grpc-spring-boot-starter with MIT License 5 votes vote down vote up
/**
 * Creates a new delegating ClientCall that will wrap the given client call to collect metrics.
 *
 * @param delegate The original call to wrap.
 * @param registry The registry to save the metrics to.
 * @param requestCounter The counter for outgoing requests.
 * @param responseCounter The counter for incoming responses.
 * @param timerFunction A function that will return a timer for a given status code.
 */
public MetricCollectingClientCall(final ClientCall<Q, A> delegate, final MeterRegistry registry,
        final Counter requestCounter, final Counter responseCounter,
        final Function<Code, Timer> timerFunction) {
    super(delegate);
    this.registry = registry;
    this.requestCounter = requestCounter;
    this.responseCounter = responseCounter;
    this.timerFunction = timerFunction;
}
 
Example #19
Source File: IPCTracingAndMetricsAwareRequestResponseFunction.java    From rsocket-rpc-java with Apache License 2.0 5 votes vote down vote up
public IPCTracingAndMetricsAwareRequestResponseFunction(
    String route,
    Unmarshaller unmarshaller,
    Marshaller marshaller,
    Functions.RequestResponse rr,
    Tracer tracer,
    MeterRegistry meterRegistry) {
  this.route = route;
  this.unmarshaller = unmarshaller;
  this.marshaller = marshaller;
  this.rr = rr;
  this.tracer = tracer;
  this.meterRegistry = meterRegistry;
}
 
Example #20
Source File: MicroMeterMetricCollector.java    From secor with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(SecorConfig config) {
    if (config.getMicroMeterCollectorStatsdEnabled()) {
        MeterRegistry statsdRegistry =
            new StatsdMeterRegistry(StatsdConfig.DEFAULT, Clock.SYSTEM);
        Metrics.addRegistry(statsdRegistry);
    }

    if (config.getMicroMeterCollectorJmxEnabled()) {
        MeterRegistry jmxRegistry = new JmxMeterRegistry(JmxConfig.DEFAULT, Clock.SYSTEM);
        Metrics.addRegistry(jmxRegistry);
    }
}
 
Example #21
Source File: StateRepositoryMetricsReporter.java    From synapse with Apache License 2.0 5 votes vote down vote up
public StateRepositoryMetricsReporter(MeterRegistry registry,
                                      @Value("${spring.profiles.active}") String profile,
                                      List<StateRepository<?>> stateRepositories) {
    stateRepositories.forEach(stateRepository -> {
        Gauge.builder("state_repository_size", stateRepository, StateRepository::size)
                .tag("profile", profile)
                .tag("state_repository", stateRepository.getName())
                .register(registry);
    });
}
 
Example #22
Source File: OperatorMetricsTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
/**
 * Created new MetricsProvider and makes sure it doesn't contain any metrics from previous tests.
 *
 * @return  Clean MetricsProvider
 */
public MetricsProvider createCleanMetricsProvider() {
    MetricsProvider metrics = new MicrometerMetricsProvider();
    MeterRegistry registry = metrics.meterRegistry();

    registry.forEachMeter(meter -> {
        registry.remove(meter);
    });

    return metrics;
}
 
Example #23
Source File: IPCMetricsAwareRequestChannelFunction.java    From rsocket-rpc-java with Apache License 2.0 5 votes vote down vote up
public IPCMetricsAwareRequestChannelFunction(
    String route,
    Unmarshaller unmarshaller,
    Marshaller marshaller,
    Functions.HandleRequestHandle rc,
    MeterRegistry meterRegistry) {
  this.route = route;
  this.unmarshaller = unmarshaller;
  this.marshaller = marshaller;
  this.rc = rc;
  this.meterRegistry = meterRegistry;
}
 
Example #24
Source File: MetricsConfiguration.java    From enmasse with Apache License 2.0 5 votes vote down vote up
/**
 * Customizer for meter registry.
 *
 * @return The new meter registry customizer.
 */
@Bean
@Profile({PROFILE_REGISTRY_ADAPTER, PROFILE_REGISTRY_MANAGEMENT})
public MeterRegistryCustomizer<MeterRegistry> commonTagsRegistry() {
    return r -> r
            .config()
            .commonTags(forService(Constants.SERVICE_NAME_DEVICE_REGISTRY));
}
 
Example #25
Source File: DistributionSummaryTest.java    From micrometer with Apache License 2.0 5 votes vote down vote up
@Test
@DisplayName("record zero")
default void recordZero(MeterRegistry registry) {
    DistributionSummary ds = registry.summary("my.summary");

    ds.record(0);
    clock(registry).add(step());

    assertAll(() -> assertEquals(1L, ds.count()),
            () -> assertEquals(0L, ds.totalAmount()));
}
 
Example #26
Source File: TimeLimiterMetricsAutoConfiguration.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnBean(MeterRegistry.class)
@ConditionalOnProperty(value = "resilience4j.timelimiter.metrics.legacy.enabled", havingValue = "false", matchIfMissing = true)
@ConditionalOnMissingBean
public TaggedTimeLimiterMetricsPublisher taggedTimeLimiterMetricsPublisher(MeterRegistry meterRegistry) {
    return new TaggedTimeLimiterMetricsPublisher(meterRegistry);
}
 
Example #27
Source File: LongTaskTimerTest.java    From micrometer with Apache License 2.0 5 votes vote down vote up
@Test
@DisplayName("supports sending histograms of active task duration")
default void histogram(MeterRegistry registry) {
    LongTaskTimer t = LongTaskTimer.builder("my.timer")
            .serviceLevelObjectives(Duration.ofSeconds(10), Duration.ofSeconds(40), Duration.ofMinutes(1))
            .register(registry);

    List<Integer> samples = Arrays.asList(48, 42, 40, 35, 22, 16, 13, 8, 6, 4, 2);
    int prior = samples.get(0);
    for (Integer value : samples) {
        clock(registry).add(prior - value, TimeUnit.SECONDS);
        t.start();
        prior = value;
    }
    clock(registry).add(samples.get(samples.size() - 1), TimeUnit.SECONDS);

    CountAtBucket[] countAtBuckets = t.takeSnapshot().histogramCounts();

    assertThat(countAtBuckets[0].bucket(TimeUnit.SECONDS)).isEqualTo(10);
    assertThat(countAtBuckets[0].count()).isEqualTo(4);

    assertThat(countAtBuckets[1].bucket(TimeUnit.SECONDS)).isEqualTo(40);
    assertThat(countAtBuckets[1].count()).isEqualTo(9);

    assertThat(countAtBuckets[2].bucket(TimeUnit.MINUTES)).isEqualTo(1);
    assertThat(countAtBuckets[2].count()).isEqualTo(11);
}
 
Example #28
Source File: VertxEventBusMetrics.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
VertxEventBusMetrics(MeterRegistry registry) {
  super(registry, MetricsDomain.EVENT_BUS);
  handlers = longGauges("handlers", "Number of event bus handlers in use", Label.EB_ADDRESS);
  pending = longGauges("pending", "Number of messages not processed yet", Label.EB_ADDRESS, Label.EB_SIDE);
  processed = counters("processed", "Number of processed messages", Label.EB_ADDRESS, Label.EB_SIDE);
  published = counters("published", "Number of messages published (publish / subscribe)", Label.EB_ADDRESS, Label.EB_SIDE);
  sent = counters("sent", "Number of messages sent (point-to-point)", Label.EB_ADDRESS, Label.EB_SIDE);
  received = counters("received", "Number of messages received", Label.EB_ADDRESS, Label.EB_SIDE);
  delivered = counters("delivered", "Number of messages delivered to handlers", Label.EB_ADDRESS, Label.EB_SIDE);
  discarded = counters("discarded", "Number of discarded messages", Label.EB_ADDRESS, Label.EB_SIDE);
  replyFailures = counters("replyFailures", "Number of message reply failures", Label.EB_ADDRESS, Label.EB_FAILURE);
  bytesRead = summaries("bytesRead", "Number of bytes received while reading messages from event bus cluster peers", Label.EB_ADDRESS);
  bytesWritten = summaries("bytesWritten", "Number of bytes sent while sending messages to event bus cluster peers", Label.EB_ADDRESS);
}
 
Example #29
Source File: TimerTest.java    From micrometer with Apache License 2.0 5 votes vote down vote up
@Test
default void recordMax(MeterRegistry registry) {
    Timer timer = registry.timer("my.timer");
    timer.record(10, TimeUnit.MILLISECONDS);
    timer.record(1, TimeUnit.SECONDS);

    clock(registry).add(step()); // for Atlas, which is step rather than ring-buffer based
    assertThat(timer.max(TimeUnit.SECONDS)).isEqualTo(1);
    assertThat(timer.max(TimeUnit.MILLISECONDS)).isEqualTo(1000);

    //noinspection ConstantConditions
    clock(registry).add(Duration.ofMillis(step().toMillis() * DistributionStatisticConfig.DEFAULT.getBufferLength()));
    assertThat(timer.max(TimeUnit.SECONDS)).isEqualTo(0);
}
 
Example #30
Source File: MetricCollectingClientInterceptorTest.java    From grpc-spring-boot-starter with MIT License 5 votes vote down vote up
@Test
public void testClientPreRegistration() {
    log.info("--- Starting tests with client pre-registration ---");
    final MeterRegistry meterRegistry = new SimpleMeterRegistry();
    assertEquals(0, meterRegistry.getMeters().size());
    final MetricCollectingClientInterceptor mcci = new MetricCollectingClientInterceptor(meterRegistry);
    mcci.preregisterService(TestServiceGrpc.getServiceDescriptor());

    MetricTestHelper.logMeters(meterRegistry.getMeters());
    assertEquals(METHOD_COUNT * 3, meterRegistry.getMeters().size());
    log.info("--- Test completed ---");
}