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);
}
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);
}
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;
}
Aggregations