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 ...@@ -54,6 +54,9 @@ public class MetricsEndpointDocumentationTests extends MockMvcEndpointDocumentat
.andExpect(status().isOk()) .andExpect(status().isOk())
.andDo(document("metrics/metric", responseFields( .andDo(document("metrics/metric", responseFields(
fieldWithPath("name").description("Name of the metric"), fieldWithPath("name").description("Name of the metric"),
fieldWithPath("description")
.description("Description of the metric"),
fieldWithPath("baseUnit").description("Base unit of the metric"),
fieldWithPath("measurements") fieldWithPath("measurements")
.description("Measurements of the metric"), .description("Measurements of the metric"),
fieldWithPath("measurements[].statistic") fieldWithPath("measurements[].statistic")
......
...@@ -91,7 +91,9 @@ public class MetricsEndpoint { ...@@ -91,7 +91,9 @@ public class MetricsEndpoint {
Map<Statistic, Double> samples = getSamples(meters); Map<Statistic, Double> samples = getSamples(meters);
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, 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)); asList(availableTags, AvailableTag::new));
} }
...@@ -183,13 +185,19 @@ public class MetricsEndpoint { ...@@ -183,13 +185,19 @@ public class MetricsEndpoint {
private final String name; private final String name;
private final String description;
private final String baseUnit;
private final List<Sample> measurements; private final List<Sample> measurements;
private final List<AvailableTag> availableTags; private final List<AvailableTag> availableTags;
MetricResponse(String name, List<Sample> measurements, MetricResponse(String name, String description, String baseUnit,
List<AvailableTag> availableTags) { List<Sample> measurements, List<AvailableTag> availableTags) {
this.name = name; this.name = name;
this.description = description;
this.baseUnit = baseUnit;
this.measurements = measurements; this.measurements = measurements;
this.availableTags = availableTags; this.availableTags = availableTags;
} }
...@@ -198,6 +206,14 @@ public class MetricsEndpoint { ...@@ -198,6 +206,14 @@ public class MetricsEndpoint {
return this.name; return this.name;
} }
public String getDescription() {
return this.description;
}
public String getBaseUnit() {
return this.baseUnit;
}
public List<Sample> getMeasurements() { public List<Sample> getMeasurements() {
return this.measurements; 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