Class OpenMetricsTextFormatWriter
java.lang.Object
io.prometheus.metrics.expositionformats.OpenMetricsTextFormatWriter
- All Implemented Interfaces:
ExpositionFormatWriter
Write the OpenMetrics text format as defined on https://openmetrics.io.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOpenMetricsTextFormatWriter(boolean createdTimestampsEnabled, boolean exemplarsOnAllMetricTypesEnabled) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbuilder()static OpenMetricsTextFormatWritercreate()private ClassicHistogramBucketsvoidwrite(OutputStream out, MetricSnapshots metricSnapshots, EscapingScheme scheme) Writes the given metric snapshots to the output stream using the specified escaping scheme.private voidwriteClassicHistogramBuckets(Writer writer, MetricMetadata metadata, String countSuffix, String sumSuffix, List<HistogramSnapshot.HistogramDataPointSnapshot> dataList, EscapingScheme scheme) private voidwriteCountAndSum(Writer writer, MetricMetadata metadata, DistributionDataPointSnapshot data, String countSuffix, String sumSuffix, Exemplars exemplars, EscapingScheme scheme) private voidwriteCounter(Writer writer, CounterSnapshot snapshot, EscapingScheme scheme) private voidwriteCreated(Writer writer, MetricMetadata metadata, DataPointSnapshot data, EscapingScheme scheme) private voidwriteGauge(Writer writer, GaugeSnapshot snapshot, EscapingScheme scheme) private voidwriteHistogram(Writer writer, HistogramSnapshot snapshot, EscapingScheme scheme) private voidwriteInfo(Writer writer, InfoSnapshot snapshot, EscapingScheme scheme) private voidwriteMetadata(Writer writer, String typeName, MetricMetadata metadata, EscapingScheme scheme) private voidwriteNameAndLabels(Writer writer, String name, String suffix, Labels labels, EscapingScheme escapingScheme) private voidwriteNameAndLabels(Writer writer, String name, String suffix, Labels labels, EscapingScheme escapingScheme, String additionalLabelName, double additionalLabelValue) private voidwriteScrapeTimestampAndExemplar(Writer writer, DataPointSnapshot data, Exemplar exemplar, EscapingScheme scheme) private voidwriteStateSet(Writer writer, StateSetSnapshot snapshot, EscapingScheme scheme) private voidwriteSummary(Writer writer, SummarySnapshot snapshot, EscapingScheme scheme) private voidwriteUnknown(Writer writer, UnknownSnapshot snapshot, EscapingScheme scheme) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ExpositionFormatWriter
isAvailable, toDebugString, toDebugString, write
-
Field Details
-
CONTENT_TYPE
- See Also:
-
createdTimestampsEnabled
private final boolean createdTimestampsEnabled -
exemplarsOnAllMetricTypesEnabled
private final boolean exemplarsOnAllMetricTypesEnabled
-
-
Constructor Details
-
OpenMetricsTextFormatWriter
public OpenMetricsTextFormatWriter(boolean createdTimestampsEnabled, boolean exemplarsOnAllMetricTypesEnabled) - Parameters:
createdTimestampsEnabled- whether to include the _created timestamp in the output - This will produce an invalid OpenMetrics output, but is kept for backwards compatibility.
-
-
Method Details
-
builder
-
create
-
accepts
- Specified by:
acceptsin interfaceExpositionFormatWriter
-
getContentType
- Specified by:
getContentTypein interfaceExpositionFormatWriter
-
write
public void write(OutputStream out, MetricSnapshots metricSnapshots, EscapingScheme scheme) throws IOException Description copied from interface:ExpositionFormatWriterWrites the given metric snapshots to the output stream using the specified escaping scheme.- Specified by:
writein interfaceExpositionFormatWriter- Throws:
IOException
-
writeCounter
private void writeCounter(Writer writer, CounterSnapshot snapshot, EscapingScheme scheme) throws IOException - Throws:
IOException
-
writeGauge
private void writeGauge(Writer writer, GaugeSnapshot snapshot, EscapingScheme scheme) throws IOException - Throws:
IOException
-
writeHistogram
private void writeHistogram(Writer writer, HistogramSnapshot snapshot, EscapingScheme scheme) throws IOException - Throws:
IOException
-
writeClassicHistogramBuckets
private void writeClassicHistogramBuckets(Writer writer, MetricMetadata metadata, String countSuffix, String sumSuffix, List<HistogramSnapshot.HistogramDataPointSnapshot> dataList, EscapingScheme scheme) throws IOException - Throws:
IOException
-
getClassicBuckets
private ClassicHistogramBuckets getClassicBuckets(HistogramSnapshot.HistogramDataPointSnapshot data) -
writeSummary
private void writeSummary(Writer writer, SummarySnapshot snapshot, EscapingScheme scheme) throws IOException - Throws:
IOException
-
writeInfo
private void writeInfo(Writer writer, InfoSnapshot snapshot, EscapingScheme scheme) throws IOException - Throws:
IOException
-
writeStateSet
private void writeStateSet(Writer writer, StateSetSnapshot snapshot, EscapingScheme scheme) throws IOException - Throws:
IOException
-
writeUnknown
private void writeUnknown(Writer writer, UnknownSnapshot snapshot, EscapingScheme scheme) throws IOException - Throws:
IOException
-
writeCountAndSum
private void writeCountAndSum(Writer writer, MetricMetadata metadata, DistributionDataPointSnapshot data, String countSuffix, String sumSuffix, Exemplars exemplars, EscapingScheme scheme) throws IOException - Throws:
IOException
-
writeCreated
private void writeCreated(Writer writer, MetricMetadata metadata, DataPointSnapshot data, EscapingScheme scheme) throws IOException - Throws:
IOException
-
writeNameAndLabels
private void writeNameAndLabels(Writer writer, String name, String suffix, Labels labels, EscapingScheme escapingScheme) throws IOException - Throws:
IOException
-
writeNameAndLabels
private void writeNameAndLabels(Writer writer, String name, String suffix, Labels labels, EscapingScheme escapingScheme, String additionalLabelName, double additionalLabelValue) throws IOException - Throws:
IOException
-
writeScrapeTimestampAndExemplar
private void writeScrapeTimestampAndExemplar(Writer writer, DataPointSnapshot data, Exemplar exemplar, EscapingScheme scheme) throws IOException - Throws:
IOException
-
writeMetadata
private void writeMetadata(Writer writer, String typeName, MetricMetadata metadata, EscapingScheme scheme) throws IOException - Throws:
IOException
-