Interface NBLabels
- All Known Implementing Classes:
MapLabels
public interface NBLabels
The NBLabels type represents sets of identifying label names and values for any element in the NoSQLBench runtime which needs to be named. This allows for hierarchic naming for instances by including the naming elements of parents as owned objects are created.
The recommended way to use this type is to require a parent element in constructors, and to combine instance data at that time into a cached view. This means that further processing will be minimized, since these elements will be consulted frequently, such as when rendering metrics values.
-
Method Summary
Modifier and TypeMethodDescriptionCreate a new NBLabels value with the additional keys and values appended.Create a new NBLabels value with the additional keys and values appended.andDefault(NBLabels defaults) andDefault(String name, String value) asMap()Return a map representation of the label set, regardless of the underlying form.difference(NBLabels otherLabels) static NBLabelsCreate an NBLabels instance from the given keys and values (even,odd,...)static NBLabelsCreate an NBLabels instance from the given map.intersection(NBLabels labelset) Return a String representation of the metric's labels as you would see it in an openmetrics filter, likebooleanisEmpty()Render a string representation of the label set according to the prometheus exposition naming format.linearize_bare(String... barewords) linearizeValues(char delim, String... included) Create a string representation of the label data, including only the values.default StringlinearizeValues(String... included) This is equivalent to call inglinearizeValues(char, String...)with the '.' character.modifyName(String element, Function<String, String> transform) Return a new NBLabels value with the specified key transformed according to the provided Lambda.modifyValue(String labelName, Function<String, String> transform) Return a new NBLabels value with the specified value transformed according to the provided Lambda.Return the value of the specified label key.valueOfOptional(String name)
-
Method Details
-
linearizeValues
Create a string representation of the label data, including only the values. Each value is concatenated with the others using the delim character. If a specified label name is included in square brackets like , then it is considered optional, and will be skipped over gracefully if it is not present in the label set. Otherwise all names are considered required.- Parameters:
delim- A single characterincluded- Which fields from the label set to include in the rendered string. If none are specified then all are included.- Returns:
- A string representation of the labels
- Throws:
RuntimeException- if a required label name is not present, or its value is null.
-
linearizeValues
This is equivalent to call inglinearizeValues(char, String...)with the '.' character.- Parameters:
included- Which fields from the label set to include in the rendered string. If none are specified, then all are included.- Returns:
- A string representation of the labels
-
linearize_bare
-
linearize
Render a string representation of the label set according to the prometheus exposition naming format. This means that a label set which includes the JSON data:
would render to{ "name": "fooname", "label1": "label1value" }
IF called asfooname{label1="label1value"}linearize("name").The included fields are added to the label set. If none are specified then all are included by default.
- Parameters:
barename- The field from the label set to use as the nominal metric family name part.included- Fields to be used in rendered label set.- Returns:
- A string representation of the labels that is parsable in the prometheus exposition format.
-
forMap
-
forKV
-
modifyName
Return a new NBLabels value with the specified key transformed according to the provided Lambda. The associated value is not modified.- Parameters:
element- The key to modifytransform- A Lambda which will modify the existing key name.- Returns:
- A new NBLabels value, separate from the original
-
modifyValue
Return a new NBLabels value with the specified value transformed according to the provided Lambda. The associated key name is not modified.- Parameters:
labelName- The named label to modifytransform- A Lambda which will modify the existing value.- Returns:
- A new NBLabels value, separate from the original
- Throws:
RuntimeException- if either the key is not found or the values is null.
-
linearizeAsMetrics
String linearizeAsMetrics() -
linearizeAsKvString
String linearizeAsKvString() -
and
-
and
-
and
-
valueOf
Return the value of the specified label key.- Parameters:
name- The label name- Returns:
- The named label's value
- Throws:
RuntimeException- if the specified label does not exist in the set, or the value is null.
-
valueOfOptional
-
asMap
-
intersection
-
difference
-
isEmpty
boolean isEmpty() -
andDefault
-
andDefault
-