use of io.pravega.shared.metrics.StatsProvider in project pravega by pravega.
the class ExtendedS3StorageTest method setUp.
@Before
public void setUp() throws Exception {
this.setup = new ExtendedS3TestContext();
MetricsConfig metricsConfig = MetricsConfig.builder().with(MetricsConfig.ENABLE_STATISTICS, true).build();
MetricsProvider.initialize(metricsConfig);
StatsProvider statsProvider = MetricsProvider.getMetricsProvider();
statsProvider.startWithoutExporting();
}
use of io.pravega.shared.metrics.StatsProvider in project pravega by pravega.
the class ChunkedSegmentStorageMockTests method testReport.
@Test
public void testReport() throws Exception {
MetricsConfig metricsConfig = MetricsConfig.builder().with(MetricsConfig.ENABLE_STATISTICS, true).build();
MetricsProvider.initialize(metricsConfig);
@Cleanup StatsProvider statsProvider = MetricsProvider.getMetricsProvider();
statsProvider.startWithoutExporting();
val config = ChunkedSegmentStorageConfig.DEFAULT_CONFIG.toBuilder().safeStorageSizeCheckFrequencyInSeconds(100).maxSafeStorageSize(1000).build();
@Cleanup BaseMetadataStore spyMetadataStore = spy(new InMemoryMetadataStore(config, executorService()));
@Cleanup BaseChunkStorage spyChunkStorage = spy(new NoOpChunkStorage(executorService()));
@Cleanup ChunkedSegmentStorage chunkedSegmentStorage = new ChunkedSegmentStorage(CONTAINER_ID, spyChunkStorage, spyMetadataStore, executorService(), config);
chunkedSegmentStorage.initialize(1);
when(spyChunkStorage.doGetUsedSpace(any())).thenReturn(123L);
chunkedSegmentStorage.updateStorageStats().get();
chunkedSegmentStorage.report();
// Not possible to mock any other reporter except metadata store.
verify(spyMetadataStore).report();
Assert.assertEquals(123, MetricRegistryUtils.getGauge(SLTS_STORAGE_USED_BYTES).value(), 0);
Assert.assertEquals(12.3, MetricRegistryUtils.getGauge(SLTS_STORAGE_USED_PERCENTAGE).value(), 0);
}
Aggregations