Search in sources :

Example 11 with Reservoir

use of com.codahale.metrics.Reservoir in project riposte by Nike-Inc.

the class SignalFxEndpointMetricsHandlerTest method RollingWindowHistogramBuilder_newMetric_creates_new_histogram_with_SlidingTimeWindowArrayReservoir_with_expected_values.

@DataProvider(value = { "42     |   DAYS", "123    |   SECONDS", "999    |   MILLISECONDS", "3      |   HOURS" }, splitBy = "\\|")
@Test
public void RollingWindowHistogramBuilder_newMetric_creates_new_histogram_with_SlidingTimeWindowArrayReservoir_with_expected_values(long amount, TimeUnit timeUnit) {
    // given
    RollingWindowHistogramBuilder rwhb = new RollingWindowHistogramBuilder(amount, timeUnit);
    // when
    Histogram histogram = rwhb.newMetric();
    // then
    Reservoir reservoir = (Reservoir) getInternalState(histogram, "reservoir");
    assertThat(reservoir).isInstanceOf(SlidingTimeWindowArrayReservoir.class);
    // The expected value here comes from logic in the SlidingTimeWindowArrayReservoir constructor.
    assertThat(getInternalState(reservoir, "window")).isEqualTo(timeUnit.toNanos(amount) * 256);
}
Also used : Histogram(com.codahale.metrics.Histogram) RollingWindowHistogramBuilder(com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowHistogramBuilder) Reservoir(com.codahale.metrics.Reservoir) SlidingTimeWindowArrayReservoir(com.codahale.metrics.SlidingTimeWindowArrayReservoir) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Test(org.junit.Test)

Example 12 with Reservoir

use of com.codahale.metrics.Reservoir in project ambry by linkedin.

the class CryptoJobMetricsTracker method createHistogram.

/**
 * Create a histogram with parameters specified by the provided {@link RouterConfig} that stores cached values for use
 * by {@link OperationTracker}.
 * @param routerConfig the {@link RouterConfig} containing the histogram parameters.
 * @param useDefaultReservoirParams {@code true} to use the default {@link ExponentiallyDecayingReservoir} constructor
 *                                  instead of the parameters from the config.
 * @return a configured {@link CachedHistogram}.
 */
static CachedHistogram createHistogram(RouterConfig routerConfig, boolean useDefaultReservoirParams) {
    Reservoir reservoir;
    long cacheTimeoutMs;
    double quantile;
    if (routerConfig != null) {
        if (useDefaultReservoirParams) {
            reservoir = new ExponentiallyDecayingReservoir();
        } else {
            reservoir = new ExponentiallyDecayingReservoir(routerConfig.routerOperationTrackerReservoirSize, routerConfig.routerOperationTrackerReservoirDecayFactor);
        }
        cacheTimeoutMs = routerConfig.routerOperationTrackerHistogramCacheTimeoutMs;
        quantile = routerConfig.routerLatencyToleranceQuantile;
    } else {
        reservoir = new ExponentiallyDecayingReservoir();
        cacheTimeoutMs = RouterConfig.DEFAULT_OPERATION_TRACKER_HISTOGRAM_CACHE_TIMEOUT_MS;
        quantile = RouterConfig.DEFAULT_LATENCY_TOLERANCE_QUANTILE;
    }
    return new CachedHistogram(reservoir, cacheTimeoutMs, quantile);
}
Also used : ExponentiallyDecayingReservoir(com.codahale.metrics.ExponentiallyDecayingReservoir) Reservoir(com.codahale.metrics.Reservoir) ExponentiallyDecayingReservoir(com.codahale.metrics.ExponentiallyDecayingReservoir) CachedHistogram(com.github.ambry.utils.CachedHistogram)

Example 13 with Reservoir

use of com.codahale.metrics.Reservoir in project cassandra by apache.

the class ClientMetrics method init.

public synchronized void init(Collection<Server> servers) {
    if (initialized)
        return;
    this.servers = servers;
    // deprecated the lower-cased initial letter metric names in 4.0
    registerGauge("ConnectedNativeClients", "connectedNativeClients", this::countConnectedClients);
    registerGauge("ConnectedNativeClientsByUser", "connectedNativeClientsByUser", this::countConnectedClientsByUser);
    registerGauge("Connections", "connections", this::connectedClients);
    registerGauge("ClientsByProtocolVersion", "clientsByProtocolVersion", this::recentClientStats);
    registerGauge("RequestsSize", ClientResourceLimits::getCurrentGlobalUsage);
    Reservoir ipUsageReservoir = ClientResourceLimits.ipUsageReservoir();
    Metrics.register(factory.createMetricName("RequestsSizeByIpDistribution"), new Histogram(ipUsageReservoir) {

        public long getCount() {
            return ipUsageReservoir.size();
        }
    });
    authSuccess = registerMeter("AuthSuccess");
    authFailure = registerMeter("AuthFailure");
    pausedConnections = new AtomicInteger();
    pausedConnectionsGauge = registerGauge("PausedConnections", pausedConnections::get);
    requestDiscarded = registerMeter("RequestDiscarded");
    protocolException = registerMeter("ProtocolException");
    unknownException = registerMeter("UnknownException");
    initialized = true;
}
Also used : Histogram(com.codahale.metrics.Histogram) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Reservoir(com.codahale.metrics.Reservoir)

Aggregations

Reservoir (com.codahale.metrics.Reservoir)13 Test (org.junit.Test)7 Histogram (com.codahale.metrics.Histogram)6 ExponentiallyDecayingReservoir (com.codahale.metrics.ExponentiallyDecayingReservoir)5 SlidingTimeWindowReservoir (com.codahale.metrics.SlidingTimeWindowReservoir)5 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)4 Timer (com.codahale.metrics.Timer)3 UniformReservoir (com.codahale.metrics.UniformReservoir)3 Clock (com.codahale.metrics.Clock)2 SlidingTimeWindowArrayReservoir (com.codahale.metrics.SlidingTimeWindowArrayReservoir)2 RollingWindowHistogramBuilder (com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowHistogramBuilder)2 RollingWindowTimerBuilder (com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 NodeConfig (org.apache.solr.core.NodeConfig)2 HdrHistogramReservoir (org.mpierce.metrics.reservoir.hdrhistogram.HdrHistogramReservoir)2 HdrHistogramResetOnSnapshotReservoir (org.mpierce.metrics.reservoir.hdrhistogram.HdrHistogramResetOnSnapshotReservoir)2 Metric (com.codahale.metrics.Metric)1 SlidingWindowReservoir (com.codahale.metrics.SlidingWindowReservoir)1 CachedHistogram (com.github.ambry.utils.CachedHistogram)1 PluginInfoInitialized (org.apache.solr.util.plugin.PluginInfoInitialized)1