support openmetrics symbolic views

This commit is contained in:
Jonathan Shook 2023-09-29 02:01:32 -05:00
parent cf510ddf1a
commit 9de6bad6ff
2 changed files with 14 additions and 0 deletions

View File

@ -120,6 +120,18 @@ public class MapLabels implements NBLabels {
return sb.toString();
}
@Override
public String linearizeAsMetrics() {
StringBuilder sb = new StringBuilder("{");
this.labels.forEach((k,v) -> {
sb.append(k).append(":\"").append(v).append("\",");
});
sb.setLength(sb.length()-",".length());
sb.append("}");
return sb.toString();
}
@Override
public MapLabels and(final Object... labelsAndValues) {
final Map<String,String> childLabels = getStringStringMap(labelsAndValues);

View File

@ -170,6 +170,8 @@ public interface NBLabels {
*/
Map<String, String> asMap();
String linearizeAsMetrics();
/**
* @return a new set of labels which includes only those which are not using per-instance semantics.
*/