mod openmetrics;
mod prometheus;
pub use super::profile::ProtobufProfile;
use crate::{error::Result, registry::Registry};
#[allow(missing_docs)]
#[allow(clippy::all)]
mod openmetrics_data_model {
include!(concat!(env!("OUT_DIR"), "/prost/openmetrics.rs"));
}
#[allow(missing_docs)]
#[allow(clippy::all)]
mod prometheus_data_model {
include!(concat!(env!("OUT_DIR"), "/prost/io.prometheus.client.rs"));
}
pub fn encode(
buffer: &mut impl prost::bytes::BufMut,
registry: &Registry,
profile: ProtobufProfile,
) -> Result<()> {
encode_with(buffer, registry, profile, crate::metrics::lazy_group::enter_scope)
}
pub fn encode_with<G>(
buffer: &mut impl prost::bytes::BufMut,
registry: &Registry,
profile: ProtobufProfile,
enter_scope: impl FnOnce() -> G,
) -> Result<()> {
let _guard = enter_scope();
match profile {
ProtobufProfile::OpenMetrics1 => openmetrics::encode(buffer, registry),
ProtobufProfile::Prometheus => prometheus::encode(buffer, registry),
}
}