use of io.opentelemetry.api.metrics.DoubleHistogram in project opentelemetry-java by open-telemetry.
the class SdkDoubleHistogramTest method collectMetrics_WithEmptyAttributes.
@Test
void collectMetrics_WithEmptyAttributes() {
DoubleHistogram doubleRecorder = sdkMeter.histogramBuilder("testRecorder").setDescription("description").setUnit("ms").build();
testClock.advance(Duration.ofNanos(SECOND_NANOS));
doubleRecorder.record(12d, Attributes.empty());
doubleRecorder.record(12d);
assertThat(sdkMeterReader.collectAllMetrics()).satisfiesExactly(metric -> assertThat(metric).hasResource(RESOURCE).hasInstrumentationLibrary(INSTRUMENTATION_LIBRARY_INFO).hasName("testRecorder").hasDescription("description").hasUnit("ms").hasDoubleHistogram().isCumulative().points().satisfiesExactly(point -> assertThat(point).hasStartEpochNanos(testClock.now() - SECOND_NANOS).hasEpochNanos(testClock.now()).hasAttributes(Attributes.empty()).hasCount(2).hasSum(24).hasBucketBoundaries(5, 10, 25, 50, 75, 100, 250, 500, 750, 1_000, 2_500, 5_000, 7_500, 10_000).hasBucketCounts(0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)));
}
use of io.opentelemetry.api.metrics.DoubleHistogram in project opentelemetry-java by open-telemetry.
the class SdkDoubleHistogramTest method stressTest.
@Test
void stressTest() {
DoubleHistogram doubleRecorder = sdkMeter.histogramBuilder("testRecorder").build();
StressTestRunner.Builder stressTestBuilder = StressTestRunner.builder().setInstrument((SdkDoubleHistogram) doubleRecorder).setCollectionIntervalMs(100);
for (int i = 0; i < 4; i++) {
stressTestBuilder.addOperation(StressTestRunner.Operation.create(1_000, 2, new SdkDoubleHistogramTest.OperationUpdaterDirectCall(doubleRecorder, "K", "V")));
stressTestBuilder.addOperation(StressTestRunner.Operation.create(1_000, 2, new OperationUpdaterWithBinding(((SdkDoubleHistogram) doubleRecorder).bind(Attributes.builder().put("K", "V").build()))));
}
stressTestBuilder.build().run();
assertThat(sdkMeterReader.collectAllMetrics()).satisfiesExactly(metric -> assertThat(metric).hasResource(RESOURCE).hasInstrumentationLibrary(INSTRUMENTATION_LIBRARY_INFO).hasName("testRecorder").hasDoubleHistogram().points().satisfiesExactly(point -> assertThat(point).hasStartEpochNanos(testClock.now()).hasEpochNanos(testClock.now()).hasAttributes(Attributes.of(stringKey("K"), "V")).hasCount(8_000).hasSum(80_000)));
}
Aggregations