use of com.spotify.metrics.core.MetricId in project apollo by spotify.
the class SemanticServiceMetrics method metersForEndpoint.
private CachedMeters metersForEndpoint(String endpoint) {
MetricId id = metricId.tagged("endpoint", endpoint);
// precreate meters for defined status codes to ensure that they start out at value 0 on restart
for (Integer code : precreateCodes) {
requestRateMeter(id, code);
}
Meter sentReplies = new Meter();
Meter sentErrors = new Meter();
if (enabledMetrics.test(ERROR_RATIO)) {
registerRatioGauge(id, "1m", errorRatioSupplier(sentErrors::getOneMinuteRate, sentReplies::getOneMinuteRate), metricRegistry);
registerRatioGauge(id, "5m", errorRatioSupplier(sentErrors::getFiveMinuteRate, sentReplies::getFiveMinuteRate), metricRegistry);
registerRatioGauge(id, "15m", errorRatioSupplier(sentErrors::getFifteenMinuteRate, sentReplies::getFifteenMinuteRate), metricRegistry);
}
return new CachedMeters(requestRateCounter(id), fanoutHistogram(id), responseSizeHistogram(id), requestSizeHistogram(id), requestDurationTimer(id), droppedRequests(id), sentReplies, sentErrors);
}
use of com.spotify.metrics.core.MetricId in project apollo by spotify.
the class RouteTransformMetricsExampleTest method responsePayloadSizeHistogram.
/**
* Middleware to track response payload size in a Histogram,
* tagged with an endpoint tag set to the given endpoint name.
*/
public Middleware<AsyncHandler<Response<ByteString>>, AsyncHandler<Response<ByteString>>> responsePayloadSizeHistogram(String endpointName) {
final MetricId histogramId = MetricId.build().tagged("service", serviceName).tagged("endpoint", endpointName).tagged("what", "endpoint-response-size");
final Histogram histogram = registry.histogram(histogramId);
return (inner) -> (requestContext) -> inner.invoke(requestContext).whenComplete((response, t) -> {
if (response != null) {
histogram.update(response.payload().map(ByteString::size).orElse(0));
}
});
}
use of com.spotify.metrics.core.MetricId in project simple-bigtable by spotify.
the class BigtableSemanticMetricsRegistry method meter.
@Override
public Meter meter(final String name) {
final MetricId tagged = baseMetricId.tagged("what", name);
final com.codahale.metrics.Meter meter = registry.meter(tagged);
return new Meter() {
@Override
public void mark() {
meter.mark();
}
@Override
public void mark(long size) {
meter.mark(size);
}
};
}
use of com.spotify.metrics.core.MetricId in project simple-bigtable by spotify.
the class BigtableSemanticMetricsRegistry method timer.
@Override
public Timer timer(final String name) {
final MetricId tagged = baseMetricId.tagged("what", name);
final com.codahale.metrics.Timer timer = registry.timer(tagged);
return new Timer() {
@Override
public Context time() {
final com.codahale.metrics.Timer.Context context = timer.time();
return context::close;
}
@Override
public void update(final long duration, final TimeUnit timeUnit) {
timer.update(duration, timeUnit);
}
};
}
use of com.spotify.metrics.core.MetricId in project simple-bigtable by spotify.
the class BigtableSemanticMetricsRegistry method counter.
@Override
public Counter counter(final String name) {
final MetricId tagged = baseMetricId.tagged("what", name);
final com.codahale.metrics.Counter counter = registry.counter(tagged);
return new Counter() {
@Override
public void inc() {
counter.inc();
}
@Override
public void dec() {
counter.dec();
}
};
}
Aggregations