pub struct MetricsManager { /* private fields */ }Expand description
Metrics manager for the proxy.
This manages all proxy metrics and provides a Prometheus-compatible export endpoint.
Implementations§
Source§impl MetricsManager
impl MetricsManager
Sourcepub fn new(
service_name: impl Into<String>,
instance_id: impl Into<String>,
) -> Self
pub fn new( service_name: impl Into<String>, instance_id: impl Into<String>, ) -> Self
Create a new metrics manager.
Sourcepub fn with_aggregator(aggregator: Arc<UnifiedMetricsAggregator>) -> Self
pub fn with_aggregator(aggregator: Arc<UnifiedMetricsAggregator>) -> Self
Create from an existing aggregator.
Sourcepub fn allowed_ips(self, ips: Vec<String>) -> Self
pub fn allowed_ips(self, ips: Vec<String>) -> Self
Set allowed IPs for metrics access.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if metrics are enabled.
Sourcepub fn metrics_path(&self) -> &str
pub fn metrics_path(&self) -> &str
Get the metrics path.
Sourcepub fn aggregator(&self) -> &UnifiedMetricsAggregator
pub fn aggregator(&self) -> &UnifiedMetricsAggregator
Get a reference to the aggregator.
Sourcepub fn aggregator_arc(&self) -> Arc<UnifiedMetricsAggregator>
pub fn aggregator_arc(&self) -> Arc<UnifiedMetricsAggregator>
Get an Arc to the aggregator.
Sourcepub fn is_ip_allowed(&self, ip: &str) -> bool
pub fn is_ip_allowed(&self, ip: &str) -> bool
Check if an IP is allowed to access metrics.
Sourcepub async fn register_pool_metrics(
&self,
agent_id: impl Into<String>,
collector: Arc<MetricsCollector>,
)
pub async fn register_pool_metrics( &self, agent_id: impl Into<String>, collector: Arc<MetricsCollector>, )
Register a pool metrics collector for a v2 agent.
Pool metrics will be included in the /metrics output.
Sourcepub async fn unregister_pool_metrics(&self, agent_id: &str)
pub async fn unregister_pool_metrics(&self, agent_id: &str)
Unregister a pool metrics collector.
Sourcepub fn handle_metrics_request(&self) -> MetricsResponse
pub fn handle_metrics_request(&self) -> MetricsResponse
Handle a metrics request.
Returns the Prometheus text format metrics body, including:
- Proxy metrics from the UnifiedMetricsAggregator
- Pool metrics from all registered v2 agent pools
Sourcepub fn inc_requests_total(&self, method: &str, status: u16, route: &str)
pub fn inc_requests_total(&self, method: &str, status: u16, route: &str)
Increment total requests counter.
Sourcepub fn observe_request_duration(
&self,
method: &str,
route: &str,
duration_secs: f64,
)
pub fn observe_request_duration( &self, method: &str, route: &str, duration_secs: f64, )
Record request duration.
Sourcepub fn set_active_connections(&self, count: f64)
pub fn set_active_connections(&self, count: f64)
Set active connections gauge.
Sourcepub fn set_active_requests(&self, count: f64)
pub fn set_active_requests(&self, count: f64)
Set active requests gauge.
Sourcepub fn inc_upstream_requests(&self, upstream: &str, status: u16, success: bool)
pub fn inc_upstream_requests(&self, upstream: &str, status: u16, success: bool)
Increment upstream requests.
Sourcepub fn observe_upstream_duration(&self, upstream: &str, duration_secs: f64)
pub fn observe_upstream_duration(&self, upstream: &str, duration_secs: f64)
Record upstream latency.
Sourcepub fn inc_agent_requests(&self, agent: &str, decision: &str)
pub fn inc_agent_requests(&self, agent: &str, decision: &str)
Increment agent requests.
Sourcepub fn observe_agent_duration(&self, agent: &str, duration_secs: f64)
pub fn observe_agent_duration(&self, agent: &str, duration_secs: f64)
Record agent processing time.
Sourcepub fn inc_circuit_breaker_trips(&self, upstream: &str)
pub fn inc_circuit_breaker_trips(&self, upstream: &str)
Increment circuit breaker trips.
Sourcepub fn set_circuit_breaker_state(&self, upstream: &str, open: bool)
pub fn set_circuit_breaker_state(&self, upstream: &str, open: bool)
Set circuit breaker state.
Sourcepub fn inc_rate_limited(&self, route: &str)
pub fn inc_rate_limited(&self, route: &str)
Increment rate limited requests.
Sourcepub fn inc_cache_access(&self, hit: bool)
pub fn inc_cache_access(&self, hit: bool)
Increment cache hits/misses.
Sourcepub fn set_cache_size(&self, size_bytes: f64)
pub fn set_cache_size(&self, size_bytes: f64)
Set cache size.
Auto Trait Implementations§
impl !Freeze for MetricsManager
impl !RefUnwindSafe for MetricsManager
impl Send for MetricsManager
impl Sync for MetricsManager
impl Unpin for MetricsManager
impl !UnwindSafe for MetricsManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more