class AbstractMetricsHandler extends
	AbstractRestHandler<RestfulGateway, EmptyRequestBody, MetricCollectionResponseBody, M> {

	@Override
	protected final CompletableFuture<MetricCollectionResponseBody> handleRequest(
			@Nonnull HandlerRequest<EmptyRequestBody, M> request,
			@Nonnull RestfulGateway gateway) throws RestHandlerException {
		metricFetcher.update();

		final MetricStore.ComponentMetricStore componentMetricStore = getComponentMetricStore(
			request,
			metricFetcher.getMetricStore());

		if (componentMetricStore == null || componentMetricStore.metrics == null) {
			return CompletableFuture.completedFuture(
				new MetricCollectionResponseBody(Collections.emptyList()));
		}

		final Set<String> requestedMetrics = new HashSet<>(request.getQueryParameter(
			MetricsFilterParameter.class));

		if (requestedMetrics.isEmpty()) {
			return CompletableFuture.completedFuture(
				new MetricCollectionResponseBody(getAvailableMetrics(componentMetricStore)));
		} else {
			final List<Metric> metrics = getRequestedMetrics(componentMetricStore, requestedMetrics);
			return CompletableFuture.completedFuture(new MetricCollectionResponseBody(metrics));
		}
	}

	public  AbstractMetricsHandler(
			GatewayRetriever<? extends RestfulGateway> leaderRetriever,
			Time timeout,
			Map<String, String> headers,
			MessageHeaders<EmptyRequestBody, MetricCollectionResponseBody, M> messageHeaders,
			MetricFetcher metricFetcher);

}