Commit f10210f7 authored by Stephane Nicoll's avatar Stephane Nicoll

Make MetricsEndpoint response types public

Closes gh-11602
parent a051e30f
...@@ -92,8 +92,8 @@ public class MetricsEndpoint { ...@@ -92,8 +92,8 @@ public class MetricsEndpoint {
Map<String, Set<String>> availableTags = getAvailableTags(meters); Map<String, Set<String>> availableTags = getAvailableTags(meters);
tags.forEach((t) -> availableTags.remove(t.getKey())); tags.forEach((t) -> availableTags.remove(t.getKey()));
return new MetricResponse(requiredMetricName, return new MetricResponse(requiredMetricName,
asList(samples, MetricResponse.Sample::new), asList(samples, Sample::new),
asList(availableTags, MetricResponse.AvailableTag::new)); asList(availableTags, AvailableTag::new));
} }
private List<Tag> parseTags(List<String> tags) { private List<Tag> parseTags(List<String> tags) {
...@@ -154,7 +154,7 @@ public class MetricsEndpoint { ...@@ -154,7 +154,7 @@ public class MetricsEndpoint {
/** /**
* Response payload for a metric name listing. * Response payload for a metric name listing.
*/ */
static class ListNamesResponse { public static final class ListNamesResponse {
private final Set<String> names; private final Set<String> names;
...@@ -170,7 +170,7 @@ public class MetricsEndpoint { ...@@ -170,7 +170,7 @@ public class MetricsEndpoint {
/** /**
* Response payload for a metric name selector. * Response payload for a metric name selector.
*/ */
static class MetricResponse { public static final class MetricResponse {
private final String name; private final String name;
...@@ -197,58 +197,59 @@ public class MetricsEndpoint { ...@@ -197,58 +197,59 @@ public class MetricsEndpoint {
return this.availableTags; return this.availableTags;
} }
/** }
* A set of tags for further dimensional drilldown and their potential values.
*/
static class AvailableTag {
private final String tag; /**
* A set of tags for further dimensional drilldown and their potential values.
*/
public static final class AvailableTag {
private final Set<String> values; private final String tag;
AvailableTag(String tag, Set<String> values) { private final Set<String> values;
this.tag = tag;
this.values = values;
}
public String getTag() { AvailableTag(String tag, Set<String> values) {
return this.tag; this.tag = tag;
} this.values = values;
}
public Set<String> getValues() { public String getTag() {
return this.values; return this.tag;
}
} }
/** public Set<String> getValues() {
* A measurement sample combining a {@link Statistic statistic} and a value. return this.values;
*/ }
static class Sample { }
private final Statistic statistic; /**
* A measurement sample combining a {@link Statistic statistic} and a value.
*/
public static final class Sample {
private final Double value; private final Statistic statistic;
Sample(Statistic statistic, Double value) { private final Double value;
this.statistic = statistic;
this.value = value;
}
public Statistic getStatistic() { Sample(Statistic statistic, Double value) {
return this.statistic; this.statistic = statistic;
} this.value = value;
}
public Double getValue() { public Statistic getStatistic() {
return this.value; return this.statistic;
} }
@Override public Double getValue() {
public String toString() { return this.value;
return "MeasurementSample{" + "statistic=" + this.statistic + ", value=" }
+ this.value + '}';
}
@Override
public String toString() {
return "MeasurementSample{" + "statistic=" + this.statistic + ", value="
+ this.value + '}';
} }
} }
} }
...@@ -132,12 +132,12 @@ public class MetricsEndpointTests { ...@@ -132,12 +132,12 @@ public class MetricsEndpointTests {
private Optional<Double> getCount(MetricsEndpoint.MetricResponse response) { private Optional<Double> getCount(MetricsEndpoint.MetricResponse response) {
return response.getMeasurements().stream() return response.getMeasurements().stream()
.filter((ms) -> ms.getStatistic().equals(Statistic.Count)).findAny() .filter((ms) -> ms.getStatistic().equals(Statistic.Count)).findAny()
.map(MetricsEndpoint.MetricResponse.Sample::getValue); .map(MetricsEndpoint.Sample::getValue);
} }
private Stream<String> availableTagKeys(MetricsEndpoint.MetricResponse response) { private Stream<String> availableTagKeys(MetricsEndpoint.MetricResponse response) {
return response.getAvailableTags().stream() return response.getAvailableTags().stream()
.map(MetricsEndpoint.MetricResponse.AvailableTag::getTag); .map(MetricsEndpoint.AvailableTag::getTag);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment