Metrics client abstraction supporting multiple backends.
This crate provides a unified interface for querying metrics from different backends (Prometheus, Enya, etc.) using PromQL as the query language.
Architecture
The [MetricsClient] trait defines a promise-based async interface that all
backends implement. Methods return [Promise] objects that can be polled
each frame in immediate mode GUIs like egui. HTTP requests are handled by
reqwest which works on both native (with tokio) and WASM (with browser fetch).
Example
use enya_client::{MetricsClient, QueryRequest};
use enya_client::prometheus::PrometheusClient;
// Create a client for your backend
let client = PrometheusClient::new("http://localhost:9090");
// Fire off a query - returns a promise
let request = QueryRequest::new("cpu_usage", r#"sum(cpu_usage{env="prod"}) by (host)"#);
let promise = client.query(request, &ctx);
// In your update loop, poll for results
if let Some(result) = promise.ready() {
match result {
Ok(response) => { /* update visualization */ }
Err(e) => { /* show error */ }
}
}