Commit 1ec16923 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #13813 from joshiste:issue-13791

* pr/13813:
  Polish "Add metric description and base unit to metrics endpoint"
  Add metric description and base unit to metrics endpoint
parents a7b13dbe 7176c54f
......@@ -54,6 +54,9 @@ public class MetricsEndpointDocumentationTests extends MockMvcEndpointDocumentat
.andExpect(status().isOk())
.andDo(document("metrics/metric", responseFields(
fieldWithPath("name").description("Name of the metric"),
fieldWithPath("description")
.description("Description of the metric"),
fieldWithPath("baseUnit").description("Base unit of the metric"),
fieldWithPath("measurements")
.description("Measurements of the metric"),
fieldWithPath("measurements[].statistic")
......
......@@ -91,7 +91,9 @@ public class MetricsEndpoint {
Map<Statistic, Double> samples = getSamples(meters);
Map<String, Set<String>> availableTags = getAvailableTags(meters);
tags.forEach((t) -> availableTags.remove(t.getKey()));
return new MetricResponse(requiredMetricName, asList(samples, Sample::new),
Meter.Id meterId = meters.get(0).getId();
return new MetricResponse(requiredMetricName, meterId.getDescription(),
meterId.getBaseUnit(), asList(samples, Sample::new),
asList(availableTags, AvailableTag::new));
}
......@@ -183,13 +185,19 @@ public class MetricsEndpoint {
private final String name;
private final String description;
private final String baseUnit;
private final List<Sample> measurements;
private final List<AvailableTag> availableTags;
MetricResponse(String name, List<Sample> measurements,
List<AvailableTag> availableTags) {
MetricResponse(String name, String description, String baseUnit,
List<Sample> measurements, List<AvailableTag> availableTags) {
this.name = name;
this.description = description;
this.baseUnit = baseUnit;
this.measurements = measurements;
this.availableTags = availableTags;
}
......@@ -198,6 +206,14 @@ public class MetricsEndpoint {
return this.name;
}
public String getDescription() {
return this.description;
}
public String getBaseUnit() {
return this.baseUnit;
}
public List<Sample> getMeasurements() {
return this.measurements;
}
......
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