pub mod labels;
mod recorder;
#[cfg(feature = "metrics-server")]
pub mod dashboard;
pub use recorder::*;
pub mod names {
pub const REQUESTS_TOTAL: &str = "llm_requests_total";
pub const REQUEST_DURATION: &str = "llm_request_duration_seconds";
pub const TOKENS_PROMPT: &str = "llm_tokens_prompt_total";
pub const TOKENS_COMPLETION: &str = "llm_tokens_completion_total";
pub const ERRORS_TOTAL: &str = "llm_errors_total";
pub const PROVIDER_HEALTHY: &str = "llm_provider_healthy";
pub const RETRIES_TOTAL: &str = "llm_retries_total";
pub const RATE_LIMITS_TOTAL: &str = "llm_rate_limits_total";
}
pub fn describe_metrics() {
use metrics::{describe_counter, describe_gauge, describe_histogram, Unit};
describe_counter!(
names::REQUESTS_TOTAL,
Unit::Count,
"Total number of LLM requests"
);
describe_histogram!(
names::REQUEST_DURATION,
Unit::Seconds,
"Request duration in seconds"
);
describe_counter!(
names::TOKENS_PROMPT,
Unit::Count,
"Total prompt tokens consumed"
);
describe_counter!(
names::TOKENS_COMPLETION,
Unit::Count,
"Total completion tokens generated"
);
describe_counter!(
names::ERRORS_TOTAL,
Unit::Count,
"Total number of errors by type"
);
describe_gauge!(
names::PROVIDER_HEALTHY,
Unit::Count,
"Provider health status (1=healthy, 0=unhealthy)"
);
describe_counter!(
names::RETRIES_TOTAL,
Unit::Count,
"Total number of retry attempts"
);
describe_counter!(
names::RATE_LIMITS_TOTAL,
Unit::Count,
"Total number of rate limit responses"
);
}