hyperlane-plugin-metrics 22.14.1

A lock-free atomic Prometheus/OpenMetrics observability plugin for the Hyperlane framework with built-in HTTP request counters, in-flight gauges, latency histograms, custom user metric registration, and a scrapeable /metrics endpoint.
Documentation
/// Default Prometheus scrape endpoint path.
pub const DEFAULT_METRICS_ENDPOINT: &str = "/metrics";

/// Default metric prefix namespace.
pub const DEFAULT_METRICS_NAMESPACE: &str = "hyperlane";

/// Prometheus text exposition format 0.0.4 `Content-Type` header value.
pub const PROMETHEUS_CONTENT_TYPE: &str = "text/plain; version=0.0.4; charset=utf-8";

/// Default latency histogram bucket upper bounds in seconds.
pub const DEFAULT_LATENCY_BUCKETS: [f64; 12] = [
    0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0,
];

/// Stack buffer length for fast decimal formatting of signed and unsigned 64-bit integers.
pub(crate) const INT_STACK_BUF_LEN: usize = 24;

/// Maximum bucket count eligible for branchless linear scan in [`crate::Histogram::observe`].
pub(crate) const LINEAR_SCAN_BUCKET_LIMIT: usize = 16;

/// Predefined HTTP status class labels emitted by Prometheus exposition.
pub(crate) const STATUS_CLASS_LABELS: [&str; 6] = ["1xx", "2xx", "3xx", "4xx", "5xx", "other"];

/// Context attribute key storing request start `Instant` for latency observation.
pub(crate) const ATTR_METRICS_STARTED_AT: &str = "hyperlane_plugin_metrics_started_at";

/// `Cache-Control` directive preventing caching of live Prometheus scrapes.
pub(crate) const CACHE_CONTROL_NO_STORE: &str = "no-store";

/// Lowercase `bearer ` prefix for optional `/metrics` scrape authentication.
pub(crate) const PREFIX_BEARER: &str = "bearer ";

/// Prometheus `# HELP ` line prefix.
pub(crate) const PROM_HELP_PREFIX: &str = "# HELP ";

/// Prometheus `# TYPE ` line prefix.
pub(crate) const PROM_TYPE_PREFIX: &str = "# TYPE ";

/// Prometheus ` histogram\n` type suffix.
pub(crate) const PROM_TYPE_HISTOGRAM_NL: &str = " histogram\n";

/// Prometheus `_bucket{le="` suffix.
pub(crate) const PROM_BUCKET_LE_OPEN: &str = "_bucket{le=\"";

/// Prometheus `"} ` suffix.
pub(crate) const PROM_BUCKET_LE_CLOSE: &str = "\"} ";

/// Prometheus `_bucket{le="+Inf"} ` suffix.
pub(crate) const PROM_BUCKET_INF: &str = "_bucket{le=\"+Inf\"} ";

/// Prometheus `_sum ` suffix.
pub(crate) const PROM_SUM_SUFFIX: &str = "_sum ";

/// Prometheus `_count ` suffix.
pub(crate) const PROM_COUNT_SUFFIX: &str = "_count ";

/// Default help text for built-in HTTP duration histogram.
pub(crate) const HELP_HTTP_DURATION: &str = "HTTP request latency distribution in seconds.";