use of io.opentelemetry.api.metrics.LongCounter in project opentelemetry-java by open-telemetry.
the class SdkMeterRegistryTest method metricProducer_GetAllMetrics.
@Test
void metricProducer_GetAllMetrics() {
Meter sdkMeter1 = meterProvider.get("io.opentelemetry.sdk.metrics.MeterSdkRegistryTest_1");
LongCounter longCounter1 = sdkMeter1.counterBuilder("testLongCounter").build();
longCounter1.add(10, Attributes.empty());
Meter sdkMeter2 = meterProvider.get("io.opentelemetry.sdk.metrics.MeterSdkRegistryTest_2");
LongCounter longCounter2 = sdkMeter2.counterBuilder("testLongCounter").build();
longCounter2.add(10, Attributes.empty());
assertThat(sdkMeterReader.collectAllMetrics()).allSatisfy(metric -> assertThat(metric).hasName("testLongCounter").hasLongSum().isCumulative().isMonotonic().points().satisfiesExactlyInAnyOrder(point -> assertThat(point).hasValue(10).hasStartEpochNanos(testClock.now()).hasEpochNanos(testClock.now()))).extracting(MetricData::getInstrumentationLibraryInfo).containsExactlyInAnyOrder(toInstrumentationLibraryInfo(((SdkMeter) sdkMeter1).getInstrumentationScopeInfo()), toInstrumentationLibraryInfo(((SdkMeter) sdkMeter2).getInstrumentationScopeInfo()));
}
Aggregations