use of io.opentelemetry.sdk.metrics.data.PointData in project opentelemetry-java by open-telemetry.
the class SdkDoubleHistogramTest method stressTest_WithDifferentLabelSet.
@Test
void stressTest_WithDifferentLabelSet() {
String[] keys = { "Key_1", "Key_2", "Key_3", "Key_4" };
String[] values = { "Value_1", "Value_2", "Value_3", "Value_4" };
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(2_000, 1, new SdkDoubleHistogramTest.OperationUpdaterDirectCall(doubleRecorder, keys[i], values[i])));
stressTestBuilder.addOperation(StressTestRunner.Operation.create(2_000, 1, new OperationUpdaterWithBinding(((SdkDoubleHistogram) doubleRecorder).bind(Attributes.builder().put(keys[i], values[i]).build()))));
}
stressTestBuilder.build().run();
assertThat(sdkMeterReader.collectAllMetrics()).satisfiesExactly(metric -> assertThat(metric).hasResource(RESOURCE).hasInstrumentationLibrary(INSTRUMENTATION_LIBRARY_INFO).hasName("testRecorder").hasDoubleHistogram().points().allSatisfy(point -> assertThat(point).hasStartEpochNanos(testClock.now()).hasEpochNanos(testClock.now()).hasCount(4_000).hasSum(40_000).hasBucketCounts(0, 2000, 2000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)).extracting(PointData::getAttributes).containsExactlyInAnyOrder(Attributes.of(stringKey(keys[0]), values[0]), Attributes.of(stringKey(keys[1]), values[1]), Attributes.of(stringKey(keys[2]), values[2]), Attributes.of(stringKey(keys[3]), values[3])));
}
use of io.opentelemetry.sdk.metrics.data.PointData in project opentelemetry-java by open-telemetry.
the class SdkLongCounterTest method stressTest_WithDifferentLabelSet.
@Test
void stressTest_WithDifferentLabelSet() {
String[] keys = { "Key_1", "Key_2", "Key_3", "Key_4" };
String[] values = { "Value_1", "Value_2", "Value_3", "Value_4" };
LongCounter longCounter = sdkMeter.counterBuilder("testCounter").build();
StressTestRunner.Builder stressTestBuilder = StressTestRunner.builder().setInstrument((SdkLongCounter) longCounter).setCollectionIntervalMs(100);
for (int i = 0; i < 4; i++) {
stressTestBuilder.addOperation(StressTestRunner.Operation.create(1_000, 2, new OperationUpdaterDirectCall(longCounter, keys[i], values[i])));
stressTestBuilder.addOperation(StressTestRunner.Operation.create(1_000, 2, new OperationUpdaterWithBinding(((SdkLongCounter) longCounter).bind(Attributes.builder().put(keys[i], values[i]).build()))));
}
stressTestBuilder.build().run();
assertThat(sdkMeterReader.collectAllMetrics()).satisfiesExactly(metric -> assertThat(metric).hasResource(RESOURCE).hasInstrumentationLibrary(INSTRUMENTATION_LIBRARY_INFO).hasName("testCounter").hasLongSum().isCumulative().isMonotonic().points().allSatisfy(point -> assertThat(point).hasStartEpochNanos(testClock.now()).hasEpochNanos(testClock.now()).hasValue(20_000)).extracting(PointData::getAttributes).containsExactlyInAnyOrder(Attributes.of(stringKey(keys[0]), values[0]), Attributes.of(stringKey(keys[1]), values[1]), Attributes.of(stringKey(keys[2]), values[2]), Attributes.of(stringKey(keys[3]), values[3])));
}
use of io.opentelemetry.sdk.metrics.data.PointData in project opentelemetry-java by open-telemetry.
the class SdkLongHistogramTest method stressTest_WithDifferentLabelSet.
@Test
void stressTest_WithDifferentLabelSet() {
String[] keys = { "Key_1", "Key_2", "Key_3", "Key_4" };
String[] values = { "Value_1", "Value_2", "Value_3", "Value_4" };
LongHistogram longRecorder = sdkMeter.histogramBuilder("testRecorder").ofLongs().build();
StressTestRunner.Builder stressTestBuilder = StressTestRunner.builder().setInstrument((SdkLongHistogram) longRecorder).setCollectionIntervalMs(100);
for (int i = 0; i < 4; i++) {
stressTestBuilder.addOperation(StressTestRunner.Operation.create(1_000, 2, new SdkLongHistogramTest.OperationUpdaterDirectCall(longRecorder, keys[i], values[i])));
stressTestBuilder.addOperation(StressTestRunner.Operation.create(1_000, 2, new SdkLongHistogramTest.OperationUpdaterWithBinding(((SdkLongHistogram) longRecorder).bind(Attributes.builder().put(keys[i], values[i]).build()))));
}
stressTestBuilder.build().run();
assertThat(sdkMeterReader.collectAllMetrics()).satisfiesExactly(metric -> assertThat(metric).hasResource(RESOURCE).hasInstrumentationLibrary(INSTRUMENTATION_LIBRARY_INFO).hasName("testRecorder").hasDoubleHistogram().points().allSatisfy(point -> assertThat(point).hasStartEpochNanos(testClock.now()).hasEpochNanos(testClock.now()).hasCount(2_000).hasSum(20_000).hasBucketCounts(0, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)).extracting(PointData::getAttributes).containsExactlyInAnyOrder(Attributes.of(stringKey(keys[0]), values[0]), Attributes.of(stringKey(keys[1]), values[1]), Attributes.of(stringKey(keys[2]), values[2]), Attributes.of(stringKey(keys[3]), values[3])));
}
use of io.opentelemetry.sdk.metrics.data.PointData in project opentelemetry-java by open-telemetry.
the class SdkDoubleUpDownCounterTest method stressTest_WithDifferentLabelSet.
@Test
void stressTest_WithDifferentLabelSet() {
String[] keys = { "Key_1", "Key_2", "Key_3", "Key_4" };
String[] values = { "Value_1", "Value_2", "Value_3", "Value_4" };
DoubleUpDownCounter doubleUpDownCounter = sdkMeter.upDownCounterBuilder("testUpDownCounter").ofDoubles().build();
StressTestRunner.Builder stressTestBuilder = StressTestRunner.builder().setInstrument((SdkDoubleUpDownCounter) doubleUpDownCounter).setCollectionIntervalMs(100);
for (int i = 0; i < 4; i++) {
stressTestBuilder.addOperation(StressTestRunner.Operation.create(2_000, 1, new OperationUpdaterDirectCall(doubleUpDownCounter, keys[i], values[i])));
stressTestBuilder.addOperation(StressTestRunner.Operation.create(2_000, 1, new OperationUpdaterWithBinding(((SdkDoubleUpDownCounter) doubleUpDownCounter).bind(Attributes.builder().put(keys[i], values[i]).build()))));
}
stressTestBuilder.build().run();
assertThat(sdkMeterReader.collectAllMetrics()).satisfiesExactly(metric -> assertThat(metric).hasResource(RESOURCE).hasInstrumentationLibrary(INSTRUMENTATION_LIBRARY_INFO).hasName("testUpDownCounter").hasDoubleSum().isCumulative().isNotMonotonic().points().allSatisfy(point -> assertThat(point).hasStartEpochNanos(testClock.now()).hasEpochNanos(testClock.now()).hasValue(40_000)).extracting(PointData::getAttributes).containsExactlyInAnyOrder(Attributes.of(stringKey(keys[0]), values[0]), Attributes.of(stringKey(keys[1]), values[1]), Attributes.of(stringKey(keys[2]), values[2]), Attributes.of(stringKey(keys[3]), values[3])));
}
use of io.opentelemetry.sdk.metrics.data.PointData in project opentelemetry-java by open-telemetry.
the class SdkDoubleCounterTest method stressTest_WithDifferentLabelSet.
@Test
void stressTest_WithDifferentLabelSet() {
String[] keys = { "Key_1", "Key_2", "Key_3", "Key_4" };
String[] values = { "Value_1", "Value_2", "Value_3", "Value_4" };
DoubleCounter doubleCounter = sdkMeter.counterBuilder("testCounter").ofDoubles().build();
StressTestRunner.Builder stressTestBuilder = StressTestRunner.builder().setInstrument((SdkDoubleCounter) doubleCounter).setCollectionIntervalMs(100);
for (int i = 0; i < 4; i++) {
stressTestBuilder.addOperation(StressTestRunner.Operation.create(2_000, 1, new OperationUpdaterDirectCall(doubleCounter, keys[i], values[i])));
stressTestBuilder.addOperation(StressTestRunner.Operation.create(2_000, 1, new OperationUpdaterWithBinding(((SdkDoubleCounter) doubleCounter).bind(Attributes.builder().put(keys[i], values[i]).build()))));
}
stressTestBuilder.build().run();
assertThat(sdkMeterReader.collectAllMetrics()).satisfiesExactly(metric -> assertThat(metric).hasResource(RESOURCE).hasInstrumentationLibrary(INSTRUMENTATION_LIBRARY_INFO).hasDoubleSum().isCumulative().isMonotonic().points().allSatisfy(point -> assertThat(point).hasStartEpochNanos(testClock.now()).hasEpochNanos(testClock.now()).hasValue(40_000)).extracting(PointData::getAttributes).containsExactlyInAnyOrder(Attributes.of(stringKey(keys[0]), values[0]), Attributes.of(stringKey(keys[1]), values[1]), Attributes.of(stringKey(keys[2]), values[2]), Attributes.of(stringKey(keys[3]), values[3])));
}
Aggregations