pg_exporter 0.4.0

PostgreSQL metric exporter for Prometheus
Documentation
use anyhow::Result;
use futures::future::BoxFuture;
use prometheus::Registry;
use sqlx::PgPool;
use std::collections::HashMap;

#[macro_use]
mod register_macro;

pub trait Collector {
    fn name(&self) -> &'static str;

    // register metrics with the prometheus registry
    fn register_metrics(&self, registry: &Registry) -> Result<()>;

    // lifetime 'a is needed to tie the future to the lifetime of self and pool
    fn collect<'a>(&'a self, pool: &'a PgPool) -> BoxFuture<'a, Result<()>>;

    fn enabled_by_default(&self) -> bool;
}

// THIS IS THE ONLY PLACE YOU NEED TO ADD NEW COLLECTORS ✨
register_collectors! {
    default => DefaultCollector,
    vacuum => VacuumCollector,
    // Add more collectors here - just follow the same pattern!
}

// Other modules
pub mod config;
pub mod registry;