io.micrometer.core.instrument.DistributionSummary Java Examples

The following examples show how to use io.micrometer.core.instrument.DistributionSummary. 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: MicrometerAtlasIntegrationTest.java    From tutorials with MIT License 7 votes vote down vote up
@Test
public void givenDistributionSummary_whenEnrichWithHistograms_thenDataAggregated() {
    SimpleMeterRegistry registry = new SimpleMeterRegistry();
    DistributionSummary hist = DistributionSummary
      .builder("summary")
      .histogram(Histogram.linear(0, 10, 5))
      .register(registry);

    hist.record(3);
    hist.record(8);
    hist.record(20);
    hist.record(40);
    hist.record(13);
    hist.record(26);

    Map<String, Integer> histograms = extractTagValueMap(registry, Type.Counter, 1.0);

    assertThat(histograms, allOf(hasEntry("bucket=0.0", 0), hasEntry("bucket=10.0", 2), hasEntry("bucket=20.0", 2), hasEntry("bucket=30.0", 1), hasEntry("bucket=40.0", 1), hasEntry("bucket=Infinity", 0)));
}
 
Example #2
Source File: FluxMetricsFuseableTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void requestTrackingHasMeterForNamedSequenceFuseable() {
	Flux<Integer> source = Flux.range(1, 10)
	    .name("foo");
	new FluxMetricsFuseable<>(source, registry)
	    .blockLast();

	DistributionSummary meter = registry.find(METER_REQUESTED)
	                                    .summary();

	assertThat(meter).as("global find").isNotNull();

	meter = registry.find(METER_REQUESTED)
	                .tag(TAG_SEQUENCE_NAME, "foo")
	                .summary();

	assertThat(meter).as("tagged find").isNotNull();
}
 
Example #3
Source File: DefaultDestinationPublishingMeterRegistry.java    From spring-cloud-stream with Apache License 2.0 6 votes vote down vote up
protected void publish() {
	List<Metric<Number>> aggregatedMeters = new ArrayList<>();
	for (Meter meter : this.getMeters()) {
		if (meter instanceof Timer) {
			aggregatedMeters.add(toTimerMetric((Timer) meter));
		}
		else if (meter instanceof DistributionSummary) {
			aggregatedMeters.add(toSummaryMetric((DistributionSummary) meter));
		}
	}
	if (!aggregatedMeters.isEmpty()) {
		ApplicationMetrics metrics = new ApplicationMetrics(
				this.applicationProperties.getKey(), aggregatedMeters);
		metrics.setInterval(this.metricsPublisherConfig.step().toMillis());
		metrics.setProperties(this.applicationProperties.getExportProperties());
		try {
			String jsonString = this.objectMapper.writeValueAsString(metrics);
			this.metricsConsumer.accept(jsonString);
		}
		catch (JsonProcessingException e) {
			logger.warn("Error producing JSON String representation metric data", e);
		}
	}
}
 
Example #4
Source File: SkywalkingDistributionSummaryTest.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimple() {
    // Creating a simplify distribution summary
    final SkywalkingMeterRegistry registry = new SkywalkingMeterRegistry();
    final DistributionSummary summary = registry.summary("test_simple_distribution_summary", "skywalking", "test");

    // Check Skywalking type
    Assert.assertTrue(summary instanceof SkywalkingDistributionSummary);
    final List<MeterId.Tag> tags = Arrays.asList(new MeterId.Tag("skywalking", "test"));

    // Multiple record data
    summary.record(10d);
    summary.record(13d);
    summary.record(2d);

    // Check micrometer data
    Assert.assertEquals(3, summary.count());
    Assert.assertEquals(25d, summary.totalAmount(), 0.0);
    Assert.assertEquals(13d, summary.max(), 0.0);

    // Check Skywalking data
    assertCounter(Whitebox.getInternalState(summary, "counter"), "test_simple_distribution_summary_count", tags, 3d);
    assertCounter(Whitebox.getInternalState(summary, "sum"), "test_simple_distribution_summary_sum", tags, 25d);
    assertGauge(Whitebox.getInternalState(summary, "max"), "test_simple_distribution_summary_max", tags, 13d);
    assertHistogramNull(Whitebox.getInternalState(summary, "histogram"));
}
 
Example #5
Source File: SummariesTest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldAliasSummaryLabel() {
  MeterRegistry registry = new SimpleMeterRegistry();
  BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match()
    .setLabel("address")
    .setType(MatchType.REGEX)
    .setValue("addr1")
    .setAlias("1")));
  Summaries summaries = new Summaries("my_summary", "", registry, Label.EB_ADDRESS);
  summaries.get("addr1").record(5);
  summaries.get("addr1").record(8);
  summaries.get("addr2").record(10);

  DistributionSummary s = registry.find("my_summary").tags("address", "1").summary();
  assertThat(s.count()).isEqualTo(2);
  assertThat(s.totalAmount()).isEqualTo(13);
  s = registry.find("my_summary").tags("address", "addr1").summary();
  assertThat(s).isNull();
  s = registry.find("my_summary").tags("address", "addr2").summary();
  assertThat(s.count()).isEqualTo(1);
  assertThat(s.totalAmount()).isEqualTo(10);
}
 
Example #6
Source File: SummariesTest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldIgnoreSummaryLabel() {
  MeterRegistry registry = new SimpleMeterRegistry();
  BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match()
    .setLabel("address")
    .setType(MatchType.REGEX)
    .setValue(".*")
    .setAlias("_")));
  Summaries summaries = new Summaries("my_summary", "", registry, Label.EB_ADDRESS);
  summaries.get("addr1").record(5);
  summaries.get("addr1").record(8);
  summaries.get("addr2").record(10);

  DistributionSummary s = registry.find("my_summary").tags("address", "_").summary();
  assertThat(s.count()).isEqualTo(3);
  assertThat(s.totalAmount()).isEqualTo(23);
  s = registry.find("my_summary").tags("address", "addr1").summary();
  assertThat(s).isNull();
  s = registry.find("my_summary").tags("address", "addr2").summary();
  assertThat(s).isNull();
}
 
Example #7
Source File: DropwizardMeterRegistriesTest.java    From armeria with Apache License 2.0 6 votes vote down vote up
@Test
void filteredGaugesDoNotAffectOthers() {
    final CompositeMeterRegistry micrometer = new CompositeMeterRegistry();
    final PrometheusMeterRegistry prometheus = PrometheusMeterRegistries.newRegistry();
    final DropwizardMeterRegistry dropwizard = DropwizardMeterRegistries.newRegistry();
    micrometer.add(prometheus).add(dropwizard);
    final DistributionSummary summary = DistributionSummary.builder("summary")
                                                           .publishPercentiles(0.5, 0.99)
                                                           .register(micrometer);
    summary.record(42);

    // Make sure Dropwizard registry does not have unwanted gauges.
    assertThat(dropwizard.getDropwizardRegistry().getMetrics()).containsOnlyKeys("summary");

    // Make sure Prometheus registry collects all samples.
    final MetricFamilySamples prometheusSamples = findPrometheusSample(prometheus, "summary");
    assertThat(prometheusSamples.samples).containsExactly(
            new Sample("summary", ImmutableList.of("quantile"), ImmutableList.of("0.5"), 42),
            new Sample("summary", ImmutableList.of("quantile"), ImmutableList.of("0.99"), 42),
            new Sample("summary_count", ImmutableList.of(), ImmutableList.of(), 1),
            new Sample("summary_sum", ImmutableList.of(), ImmutableList.of(), 42));
}
 
Example #8
Source File: JettyClientMetrics.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Override
public void onQueued(Request request) {
    Timer.Sample sample = Timer.start(registry);

    request.onComplete(result -> {
        long requestLength = result.getRequest().getContent().getLength();
        Iterable<Tag> httpRequestTags = tagsProvider.httpRequestTags(result);
        if (requestLength >= 0) {
            DistributionSummary.builder(contentSizeMetricName)
                    .description("Content sizes for Jetty HTTP client requests")
                    .tags(httpRequestTags)
                    .register(registry)
                    .record(requestLength);
        }

        sample.stop(Timer.builder(timingMetricName)
                .description("Jetty HTTP client request timing")
                .tags(httpRequestTags)
                .register(registry));
    });
}
 
Example #9
Source File: MonoMetricsTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void noRequestTrackingEvenForNamedSequence() {
	Mono<Integer> source = Mono.just(10)
	                           .name("foo")
	                           .hide();
	new MonoMetrics<>(source, registry)
			.block();

	DistributionSummary meter = registry.find(METER_REQUESTED)
	                                    .summary();

	assertThat(meter).as("global find").isNull();

	meter = registry.find(METER_REQUESTED)
	                .tag(TAG_SEQUENCE_NAME, "foo")
	                .summary();

	assertThat(meter).as("tagged find").isNull();
}
 
Example #10
Source File: HistogramGaugesTest.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Test
void histogramsContainLongMaxValue() {
    MeterRegistry registry = new SimpleMeterRegistry();

    Timer timer = Timer.builder("my.timer")
            .serviceLevelObjectives(Duration.ofNanos(Long.MAX_VALUE))
            .register(registry);

    DistributionSummary distributionSummary = DistributionSummary.builder("my.distribution")
            .serviceLevelObjectives(Double.POSITIVE_INFINITY)
            .register(registry);

    HistogramGauges distributionGauges = HistogramGauges.registerWithCommonFormat(distributionSummary, registry);

    HistogramGauges timerGauges = HistogramGauges.registerWithCommonFormat(timer, registry);

    assertThat(registry.get("my.distribution.histogram").tag("le", "+Inf").gauge()).isNotNull();
    assertThat(registry.get("my.timer.histogram").tag("le", "+Inf").gauge()).isNotNull();
}
 
Example #11
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 #12
Source File: SimpleMeterRegistryTest.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Issue("#370")
@Test
void serviceLevelObjectivesOnlyNoPercentileHistogram() {
    DistributionSummary summary = DistributionSummary.builder("my.summary")
            .serviceLevelObjectives(1.0, 2)
            .register(registry);

    summary.record(1);

    Timer timer = Timer.builder("my.timer").serviceLevelObjectives(Duration.ofMillis(1)).register(registry);
    timer.record(1, TimeUnit.MILLISECONDS);

    Gauge summaryHist1 = registry.get("my.summary.histogram").tags("le", "1").gauge();
    Gauge summaryHist2 = registry.get("my.summary.histogram").tags("le", "2").gauge();
    Gauge timerHist = registry.get("my.timer.histogram").tags("le", "0.001").gauge();

    assertThat(summaryHist1.value()).isEqualTo(1);
    assertThat(summaryHist2.value()).isEqualTo(1);
    assertThat(timerHist.value()).isEqualTo(1);

    clock.add(SimpleConfig.DEFAULT.step());

    assertThat(summaryHist1.value()).isEqualTo(0);
    assertThat(summaryHist2.value()).isEqualTo(0);
    assertThat(timerHist.value()).isEqualTo(0);
}
 
Example #13
Source File: DistributionSummaryTest.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Test
@DisplayName("multiple recordings are maintained")
default void record(MeterRegistry registry) {
    DistributionSummary ds = registry.summary("my.summary");

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

    ds.count();

    assertAll(() -> assertEquals(1L, ds.count()),
            () -> assertEquals(10L, ds.totalAmount()));

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

    assertAll(() -> assertTrue(ds.count() >= 2L),
            () -> assertTrue(ds.totalAmount() >= 20L));
}
 
Example #14
Source File: FluxMetricsTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void requestTrackingHasMeterForNamedSequence() {
	Flux<Integer> source = Flux.range(1, 10)
	                           .name("foo")
	                           .hide();
	new FluxMetrics<>(source, registry)
			.blockLast();

	DistributionSummary meter = registry.find(METER_REQUESTED)
	                                    .summary();

	assertThat(meter).as("global find").isNotNull();

	meter = registry.find(METER_REQUESTED)
	                .tag(TAG_SEQUENCE_NAME, "foo")
	                .summary();

	assertThat(meter).as("tagged find").isNotNull();
}
 
Example #15
Source File: MonoMetricsFuseableTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void noRequestTrackingEvenForNamedSequence() {
	Mono<Integer> source = Mono.just(10)
	                           .name("foo");
	new MonoMetricsFuseable<>(source, registry)
			.block();

	DistributionSummary meter = registry.find(METER_REQUESTED)
	                                    .summary();

	assertThat(meter).as("global find").isNull();

	meter = registry.find(METER_REQUESTED)
	                .tag(TAG_SEQUENCE_NAME, "foo")
	                .summary();

	assertThat(meter).as("tagged find").isNull();
}
 
Example #16
Source File: OnrampController.java    From data-highway with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Sends a given array of messages to a road")
@ApiResponses({
    @ApiResponse(code = 200, message = "Messages have been sent successfully.", response = StandardResponse.class),
    @ApiResponse(code = 400, message = "Bad Request.", response = StandardResponse.class),
    @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class),
    @ApiResponse(code = 422, message = "Road not enabled.", response = StandardResponse.class) })
@PreAuthorize("@onrampAuthorisation.isAuthorised(authentication,#roadName)")
@PostMapping(path = "/roads/{roadName}/messages")
public Iterable<StandardResponse> produce(@PathVariable String roadName, @RequestBody ArrayNode json)
  throws UnknownRoadException, InterruptedException {
  Timer.Sample sample = Timer.start(registry);
  DistributionSummary.builder("onramp.request").tag("road", roadName).register(registry).record(json.size());
  Onramp onramp = service.getOnramp(roadName).orElseThrow(() -> new UnknownRoadException(roadName));
  if (!onramp.isAvailable()) {
    throw new RoadUnavailableException(String.format("Road '%s' is disabled, could not send events.", roadName));
  }
  Iterable<StandardResponse> responses = sendMessages(onramp, json);
  sample.stop(registry.timer("onramp.request.timer", "road", roadName));
  return responses;
}
 
Example #17
Source File: GenieCpuHealthIndicator.java    From genie with Apache License 2.0 5 votes vote down vote up
GenieCpuHealthIndicator(
    final double maxCpuLoadPercent,
    final int maxCpuLoadConsecutiveOccurrences,
    final OperatingSystemMXBean operatingSystemMXBean,
    final DistributionSummary summaryCpuMetric,
    final TaskScheduler taskScheduler
) {
    this.maxCpuLoadPercent = maxCpuLoadPercent;
    this.maxCpuLoadConsecutiveOccurrences = maxCpuLoadConsecutiveOccurrences;
    this.operatingSystemMXBean = operatingSystemMXBean;
    this.summaryCpuMetric = summaryCpuMetric;
    this.summaryCpuMetric.record((long) (operatingSystemMXBean.getSystemCpuLoad() * 100));
    taskScheduler.scheduleAtFixedRate(() -> this.summaryCpuMetric
        .record((long) (operatingSystemMXBean.getSystemCpuLoad() * 100)), 5000);
}
 
Example #18
Source File: FluxMetricsFuseableTest.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Test
public void requestTrackingFuseable() {
	BaseSubscriber<Integer> bs = new BaseSubscriber<Integer>() {
		@Override
		protected void hookOnSubscribe(Subscription subscription) {
			subscription.request(1);
		}
	};
	Flux<Integer> source = Flux.range(1, 10)
	    .name("foo");
	new FluxMetricsFuseable<>(source, registry)
	    .subscribe(bs);

	DistributionSummary meter = registry.find(METER_REQUESTED)
	                                    .tag(TAG_SEQUENCE_NAME, "foo")
	                                    .summary();

	assertThat(meter).as("meter").isNotNull();
	assertThat(meter.totalAmount()).isEqualTo(1);

	bs.request(7);
	assertThat(meter.totalAmount()).isEqualTo(8);
	assertThat(meter.max()).isEqualTo(7);

	bs.request(100);
	assertThat(meter.totalAmount()).isEqualTo(108);
	assertThat(meter.max()).isEqualTo(100);
}
 
Example #19
Source File: MicrometerAtlasIntegrationTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenDistributionSummary_whenRecord_thenSummarized() {
    SimpleMeterRegistry registry = new SimpleMeterRegistry();
    DistributionSummary distributionSummary = DistributionSummary
      .builder("request.size")
      .baseUnit("bytes")
      .register(registry);
    distributionSummary.record(3);
    distributionSummary.record(4);
    distributionSummary.record(5);

    assertTrue(3 == distributionSummary.count());
    assertTrue(12 == distributionSummary.totalAmount());
}
 
Example #20
Source File: FluxMetricsTest.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Test
public void requestTracking() {
	BaseSubscriber<Integer> bs = new BaseSubscriber<Integer>() {
		@Override
		protected void hookOnSubscribe(Subscription subscription) {
			subscription.request(1);
		}
	};
	Flux<Integer> source = Flux.range(1, 10)
	                           .name("foo")
	                           .hide();
	new FluxMetrics<>(source, registry)
			.subscribe(bs);

	DistributionSummary meter = registry.find(METER_REQUESTED)
	                                    .tag(TAG_SEQUENCE_NAME, "foo")
	                                    .summary();

	assertThat(meter).as("meter").isNotNull();
	assertThat(meter.totalAmount()).isEqualTo(1);

	bs.request(7);
	assertThat(meter.totalAmount()).isEqualTo(8);
	assertThat(meter.max()).isEqualTo(7);

	bs.request(100);
	assertThat(meter.totalAmount()).isEqualTo(108);
	assertThat(meter.max()).isEqualTo(100);
}
 
Example #21
Source File: MoreMeters.java    From armeria with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a newly-registered {@link DistributionSummary} configured by
 * {@link #distributionStatisticConfig()}.
 */
public static DistributionSummary newDistributionSummary(MeterRegistry registry,
                                                         String name, Iterable<Tag> tags) {
    requireNonNull(registry, "registry");
    requireNonNull(name, "name");
    requireNonNull(tags, "tags");

    final Builder builder =
            DistributionSummary.builder(name)
                               .tags(tags)
                               .publishPercentiles(distStatCfg.getPercentiles())
                               .publishPercentileHistogram(distStatCfg.isPercentileHistogram())
                               .distributionStatisticBufferLength(distStatCfg.getBufferLength())
                               .distributionStatisticExpiry(distStatCfg.getExpiry());

    if (MICROMETER_1_5) {
        builder.maximumExpectedValue(distStatCfg.getMaximumExpectedValueAsDouble())
               .minimumExpectedValue(distStatCfg.getMinimumExpectedValueAsDouble())
               .serviceLevelObjectives(distStatCfg.getServiceLevelObjectiveBoundaries());
    } else {
        final Double maxExpectedValueNanos = distStatCfg.getMaximumExpectedValueAsDouble();
        final Double minExpectedValueNanos = distStatCfg.getMinimumExpectedValueAsDouble();
        final Long maxExpectedValue =
                maxExpectedValueNanos != null ? maxExpectedValueNanos.longValue() : null;
        final Long minExpectedValue =
                minExpectedValueNanos != null ? minExpectedValueNanos.longValue() : null;
        builder.maximumExpectedValue(maxExpectedValue);
        builder.minimumExpectedValue(minExpectedValue);
        final double[] slas = distStatCfg.getServiceLevelObjectiveBoundaries();
        if (slas != null) {
            builder.sla(Arrays.stream(slas).mapToLong(sla -> (long) sla).toArray());
        }
    }
    return builder.register(registry);
}
 
Example #22
Source File: FluxMetricsTest.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Test
public void requestTrackingDisabledIfNotNamed() {
	Flux<Integer> source = Flux.range(1, 10)
	                           .hide();
	new FluxMetrics<>(source, registry)
			.blockLast();

	DistributionSummary meter = registry.find(METER_REQUESTED)
	                                    .summary();

	if (meter != null) { //meter could be null in some tests
		assertThat(meter.count()).isZero();
	}
}
 
Example #23
Source File: FluxMetrics.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
MetricsSubscriber(CoreSubscriber<? super T> actual,
		MeterRegistry registry,
		Clock clock,
		String sequenceName,
		Tags commonTags) {
	this.actual = actual;
	this.clock = clock;
	this.commonTags = commonTags;
	this.registry = registry;


	this.onNextIntervalTimer = Timer.builder(METER_ON_NEXT_DELAY)
	                                .tags(commonTags)
	                                .description(
			                                "Measures delays between onNext signals (or between onSubscribe and first onNext)")
	                                .register(registry);

	if (!REACTOR_DEFAULT_NAME.equals(sequenceName)) {
		this.requestedCounter = DistributionSummary.builder(METER_REQUESTED)
		                                           .tags(commonTags)
		                                           .description(
				                                           "Counts the amount requested to a named Flux by all subscribers, until at least one requests an unbounded amount")
		                                           .baseUnit("requested amount")
		                                           .register(registry);
	}
	else {
		requestedCounter = null;
	}
}
 
Example #24
Source File: TcpMetricsTests.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
void checkDistributionSummary(String name, String[] tags, long expectedCount, int expectedAmount, boolean exists) {
	DistributionSummary summary = registry.find(name).tags(tags).summary();
	if (exists) {
		assertNotNull(summary);
		assertEquals(expectedCount, summary.count());
		assertTrue(summary.totalAmount() >= expectedAmount);
	}
	else {
		assertNull(summary);
	}
}
 
Example #25
Source File: MicrometerHttpServerMetricsRecorder.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Override
public void recordDataSent(SocketAddress remoteAddress, String uri, long bytes) {
	DistributionSummary dataSent = dataSentCache.computeIfAbsent(new MeterKey(uri, null, null, null),
			key -> filter(dataSentBuilder.tags(URI, uri)
			                             .register(REGISTRY)));
	if (dataSent != null) {
		dataSent.record(bytes);
	}
}
 
Example #26
Source File: MicrometerHttpServerMetricsRecorder.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Override
public void recordDataReceived(SocketAddress remoteAddress, String uri, long bytes) {
	DistributionSummary dataReceived = dataReceivedCache.computeIfAbsent(new MeterKey(uri, null, null, null),
			key -> filter(dataReceivedBuilder.tags(URI, uri)
			                                 .register(REGISTRY)));
	if (dataReceived != null) {
		dataReceived.record(bytes);
	}
}
 
Example #27
Source File: MicrometerHttpMetricsRecorder.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Override
public void recordDataSent(SocketAddress remoteAddress, String uri, long bytes) {
	String address = Metrics.formatSocketAddress(remoteAddress);
	DistributionSummary dataSent = dataSentCache.computeIfAbsent(new MeterKey(uri, address, null, null),
			key -> filter(dataSentBuilder.tags(REMOTE_ADDRESS, address, URI, uri)
			                             .register(REGISTRY)));
	if (dataSent != null) {
		dataSent.record(bytes);
	}
}
 
Example #28
Source File: MicrometerHttpMetricsRecorder.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Override
public void recordDataReceived(SocketAddress remoteAddress, String uri, long bytes) {
	String address = Metrics.formatSocketAddress(remoteAddress);
	DistributionSummary dataReceived = dataReceivedCache.computeIfAbsent(new MeterKey(uri, address, null, null),
			key -> filter(dataReceivedBuilder.tags(REMOTE_ADDRESS, address, URI, uri)
			                                 .register(REGISTRY)));
	if (dataReceived != null) {
		dataReceived.record(bytes);
	}
}
 
Example #29
Source File: MicrometerHttpMetricsRecorder.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
protected MicrometerHttpMetricsRecorder(String name, String protocol) {
	super(name, protocol);
	this.dataReceivedTimeBuilder =
			Timer.builder(name + DATA_RECEIVED_TIME)
			     .description("Time spent in consuming incoming data");

	this.dataSentTimeBuilder =
			Timer.builder(name + DATA_SENT_TIME)
			     .description("Time spent in sending outgoing data");

	this.responseTimeBuilder =
			Timer.builder(name + RESPONSE_TIME)
			     .description("Total time for the request/response");

	this.dataReceivedBuilder =
			DistributionSummary.builder(name + DATA_RECEIVED)
			                   .baseUnit("bytes")
			                   .description("Amount of the data received, in bytes");

	this.dataSentBuilder =
			DistributionSummary.builder(name + DATA_SENT)
			                   .baseUnit("bytes")
			                   .description("Amount of the data sent, in bytes");

	this.errorsBuilder =
			Counter.builder(name + ERRORS)
			       .description("Number of errors that occurred");
}
 
Example #30
Source File: OnrampMetrics.java    From data-highway with Apache License 2.0 5 votes vote down vote up
public void markSuccessMetrics(String roadName, long avroBytes) {
  Iterable<Tag> tags = singleton(Tag.of(ROAD, roadName));
  registry.counter("onramp.send-success", tags).increment();
  DistributionSummary
      .builder("onramp.message-size")
      .tags(tags)
      .publishPercentileHistogram()
      .register(registry)
      .record(avroBytes);
}