Search in sources :

Example 6 with StatsProvider

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();
}
Also used : StatsProvider(io.pravega.shared.metrics.StatsProvider) MetricsConfig(io.pravega.shared.metrics.MetricsConfig) Before(org.junit.Before)

Example 7 with StatsProvider

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);
}
Also used : lombok.val(lombok.val) BaseMetadataStore(io.pravega.segmentstore.storage.metadata.BaseMetadataStore) StatsProvider(io.pravega.shared.metrics.StatsProvider) InMemoryMetadataStore(io.pravega.segmentstore.storage.mocks.InMemoryMetadataStore) Cleanup(lombok.Cleanup) MetricsConfig(io.pravega.shared.metrics.MetricsConfig) NoOpChunkStorage(io.pravega.segmentstore.storage.noop.NoOpChunkStorage) Test(org.junit.Test)

Aggregations

StatsProvider (io.pravega.shared.metrics.StatsProvider)7 MetricsConfig (io.pravega.shared.metrics.MetricsConfig)5 Cleanup (lombok.Cleanup)3 Test (org.junit.Test)3 StoreClientConfig (io.pravega.controller.store.client.StoreClientConfig)2 HostMonitorConfig (io.pravega.controller.store.host.HostMonitorConfig)2 TimeoutServiceConfig (io.pravega.controller.timeout.TimeoutServiceConfig)2 Counter (io.pravega.shared.metrics.Counter)2 MetricsProvider (io.pravega.shared.metrics.MetricsProvider)2 SerializedClassRunner (io.pravega.test.common.SerializedClassRunner)2 TestUtils (io.pravega.test.common.TestUtils)2 URI (java.net.URI)2 HttpClient (java.net.http.HttpClient)2 HttpRequest (java.net.http.HttpRequest)2 HttpResponse (java.net.http.HttpResponse)2 Duration (java.time.Duration)2 Pattern (java.util.regex.Pattern)2 lombok.val (lombok.val)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Before (org.junit.Before)2