Class MetricMetadata
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMetricMetadata(String name) MetricMetadata(String name, String help) MetricMetadata(String name, String help, Unit unit) Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) MetricMetadataescape(EscapingScheme escapingScheme) getHelp()getName()The name does not include the_totalsuffix for counter metrics or the_infosuffix for Info metrics.Same asgetName()but with all invalid characters and dots replaced by underscores.getUnit()booleanhasUnit()private voidvalidate()
-
Field Details
-
name
Name without suffix.For example, the name for a counter "http_requests_total" is "http_requests". The name of an info called "jvm_info" is "jvm".
We allow dots in label names. Dots are automatically replaced with underscores in Prometheus exposition formats. However, if metrics from this library are exposed in OpenTelemetry format dots are retained.
See
MetricMetadata(String, String, Unit)for more info on naming conventions. -
prometheusName
Same as name that all invalid char (without Unicode support) are replaced by _Multiple metrics with the same prometheusName are not allowed, because they would end up in the same time series in Prometheus if
EscapingScheme.UNDERSCORE_ESCAPINGorEscapingScheme.DOTS_ESCAPINGis used. -
help
-
unit
-
-
Constructor Details
-
MetricMetadata
-
MetricMetadata
-
MetricMetadata
Constructor.- Parameters:
name- must not benull.isValidMetricName(name)must betrue. UsePrometheusNaming.sanitizeMetricName(String)to convert arbitrary strings into valid names.help- optional. May benull.unit- optional. May benull.
-
-
Method Details
-
getName
The name does not include the_totalsuffix for counter metrics or the_infosuffix for Info metrics.The name may contain any Unicode chars. Use
getPrometheusName()to get the name in legacy Prometheus format, i.e. with all dots and all invalid chars replaced by underscores. -
getPrometheusName
Same asgetName()but with all invalid characters and dots replaced by underscores.This is used by Prometheus exposition formats.
-
getHelp
-
hasUnit
public boolean hasUnit() -
getUnit
-
validate
private void validate() -
escape
-