Class TextFormatUtil
java.lang.Object
io.prometheus.metrics.expositionformats.TextFormatUtil
Utility methods for writing Prometheus text exposition formats.
This class provides low-level formatting utilities used by both Prometheus text format and OpenMetrics format writers. It handles escaping, label formatting, timestamp conversion, and merging of duplicate metric names.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MetricSnapshotsmergeDuplicates(MetricSnapshots metricSnapshots) Merges snapshots with duplicate Prometheus names by combining their data points.private static MetricSnapshotmergeSnapshots(List<MetricSnapshot> snapshots) Merges multiple snapshots of the same type into a single snapshot with combined data points.(package private) static voidwriteDouble(Writer writer, double d) (package private) static voidwriteEscapedString(Writer writer, String s) (package private) static voidwriteLabels(Writer writer, Labels labels, String additionalLabelName, double additionalLabelValue, boolean metricInsideBraces, EscapingScheme scheme) (package private) static void(package private) static void(package private) static voidwriteOpenMetricsTimestamp(Writer writer, long timestampMs) (package private) static voidwritePrometheusTimestamp(Writer writer, long timestampMs, boolean timestampsInMs)
-
Constructor Details
-
TextFormatUtil
public TextFormatUtil()
-
-
Method Details
-
mergeDuplicates
Merges snapshots with duplicate Prometheus names by combining their data points. This ensures only one HELP/TYPE declaration per metric family. -
writeLong
- Throws:
IOException
-
writeDouble
- Throws:
IOException
-
writePrometheusTimestamp
static void writePrometheusTimestamp(Writer writer, long timestampMs, boolean timestampsInMs) throws IOException - Throws:
IOException
-
writeOpenMetricsTimestamp
- Throws:
IOException
-
writeEscapedString
- Throws:
IOException
-
writeLabels
static void writeLabels(Writer writer, Labels labels, String additionalLabelName, double additionalLabelValue, boolean metricInsideBraces, EscapingScheme scheme) throws IOException - Throws:
IOException
-
writeName
- Throws:
IOException
-
mergeSnapshots
Merges multiple snapshots of the same type into a single snapshot with combined data points.
-