///|
pub(all) enum ExpositionFormat {
PrometheusText
OpenMetricsText
} derive(Debug, Eq)
///|
/// A complete, immutable exposition payload.
///
/// `body` always matches `format` and `content_type`; callers should forward
/// the two fields together instead of constructing HTTP headers themselves.
pub(all) struct EncodedExposition {
format : ExpositionFormat
content_type : String
body : String
}
///|
/// A snapshot was not safe or self-consistent enough to expose.
///
/// Exporting is deliberately all-or-nothing: callers receive this error before
/// an `EncodedExposition` value is constructed, never a partially rendered
/// metrics body.
pub(all) suberror EncodingError {
InvalidSnapshot(String)
DuplicateLabelName(String)
InvalidHistogram(String)
} derive(Debug, Eq)
///|
pub fn content_type(format : ExpositionFormat) -> String {
match format {
PrometheusText => "text/plain; version=0.0.4; charset=utf-8"
OpenMetricsText =>
"application/openmetrics-text; version=1.0.0; charset=utf-8"
}
}
///|
pub fn is_openmetrics(format : ExpositionFormat) -> Bool {
format == OpenMetricsText
}