use crate::metrics::labels;
use metrics::histogram;
pub fn query_startup_duration(entity: &str, duration_ms: u64) {
histogram!(
"fraiseql_query_startup_duration_ms",
labels::ENTITY => entity.to_string(),
)
.record(duration_ms as f64);
}
pub fn query_total_duration(entity: &str, duration_ms: u64) {
histogram!(
"fraiseql_query_total_duration_ms",
labels::ENTITY => entity.to_string(),
)
.record(duration_ms as f64);
}
pub fn query_rows_processed(entity: &str, count: u64) {
histogram!(
"fraiseql_query_rows_processed",
labels::ENTITY => entity.to_string(),
)
.record(count as f64);
}
pub fn query_bytes_received(entity: &str, bytes: u64) {
histogram!(
"fraiseql_query_bytes_received",
labels::ENTITY => entity.to_string(),
)
.record(bytes as f64);
}
pub fn chunk_processing_duration(entity: &str, duration_ms: u64) {
histogram!(
"fraiseql_chunk_processing_duration_ms",
labels::ENTITY => entity.to_string(),
)
.record(duration_ms as f64);
}
pub fn chunk_size(entity: &str, rows: u64) {
histogram!(
"fraiseql_chunk_size_rows",
labels::ENTITY => entity.to_string(),
)
.record(rows as f64);
}
pub fn json_parse_duration(entity: &str, duration_ms: u64) {
histogram!(
"fraiseql_json_parse_duration_ms",
labels::ENTITY => entity.to_string(),
)
.record(duration_ms as f64);
}
pub fn filter_duration(entity: &str, duration_ms: u64) {
histogram!(
"fraiseql_filter_duration_ms",
labels::ENTITY => entity.to_string(),
)
.record(duration_ms as f64);
}
pub fn deserialization_duration(entity: &str, type_name: &str, duration_ms: u64) {
histogram!(
"fraiseql_deserialization_duration_ms",
labels::ENTITY => entity.to_string(),
labels::TYPE_NAME => type_name.to_string(),
)
.record(duration_ms as f64);
}
pub fn channel_send_latency(entity: &str, duration_ms: u64) {
histogram!(
"fraiseql_channel_send_latency_ms",
labels::ENTITY => entity.to_string(),
)
.record(duration_ms as f64);
}
pub fn auth_duration(mechanism: &str, duration_ms: u64) {
histogram!(
"fraiseql_auth_duration_ms",
labels::MECHANISM => mechanism.to_string(),
)
.record(duration_ms as f64);
}
pub fn channel_occupancy(entity: &str, items_buffered: u64) {
histogram!(
"fraiseql_channel_occupancy_rows",
labels::ENTITY => entity.to_string(),
)
.record(items_buffered as f64);
}
pub fn stream_pause_duration(entity: &str, duration_ms: u64) {
histogram!(
"fraiseql_stream_pause_duration_ms",
labels::ENTITY => entity.to_string(),
)
.record(duration_ms as f64);
}
#[cfg(test)]
mod tests;