Skip to main content

vellaveto_http_proxy/
lib.rs

1// Copyright 2026 Paolo Vella
2// SPDX-License-Identifier: BUSL-1.1
3//
4// Use of this software is governed by the Business Source License
5// included in the LICENSE-BSL-1.1 file at the root of this repository.
6//
7// Change Date: Three years from the date of publication of this version.
8// Change License: MPL-2.0
9
10//! Vellaveto MCP HTTP Proxy library.
11//!
12//! Re-exports proxy, session, and OAuth modules for use by both the binary
13//! and integration tests.
14
15pub mod federation;
16pub mod oauth;
17pub mod proxy;
18pub mod session;
19
20/// Metrics instrumentation for the HTTP proxy.
21pub mod proxy_metrics {
22    /// Record a DLP finding with pattern type.
23    /// IMPROVEMENT_PLAN 1.1: DLP findings should be metered for observability.
24    pub fn record_dlp_finding(pattern_type: &str) {
25        metrics::counter!(
26            "vellaveto_dlp_findings_total",
27            "pattern_type" => pattern_type.to_string()
28        )
29        .increment(1);
30    }
31
32    /// Record DLP scan latency in seconds.
33    pub fn record_dlp_scan_latency(seconds: f64) {
34        metrics::histogram!("vellaveto_dlp_scan_duration_seconds").record(seconds);
35    }
36
37    /// Record a DPoP validation failure with a stable reason code.
38    pub fn record_dpop_failure(reason: &str) {
39        metrics::counter!(
40            "vellaveto_oauth_dpop_failures_total",
41            "reason" => reason.to_string()
42        )
43        .increment(1);
44    }
45
46    /// Record that a DPoP replay (`jti` reuse) was detected.
47    pub fn record_dpop_replay_detected() {
48        metrics::counter!("vellaveto_oauth_dpop_replay_total").increment(1);
49    }
50}