Add metric description and base unit to metrics endpoint
See gh-13813
This commit is contained in:
parent
a7b13dbe45
commit
ab1f8cf77b
|
@ -54,6 +54,8 @@ 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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue