pub struct Metrics { /* private fields */ }Expand description
Holds counters and histograms for websocket metrics.
Implementations§
Source§impl Metrics
impl Metrics
Sourcepub fn new(source: &'static str, worker: String) -> Self
pub fn new(source: &'static str, worker: String) -> Self
Creates a new Metrics instance configured for a specified source and worker.
§Arguments
source- A static string identifying the source whose metrics are being recorded.worker- The worker identifier for labeling metrics.
§Examples
use bothan_lib::metrics::websocket::{Metrics, MessageType, ConnectionResult};
let metrics = Metrics::new("example_source", "worker-1".to_string());
metrics.increment_activity_messages_total(MessageType::Ping);
metrics.update_websocket_connection(200, ConnectionResult::Success);Sourcepub fn increment_activity_messages_total(&self, message: MessageType)
pub fn increment_activity_messages_total(&self, message: MessageType)
Increments the activity message counter for a given message type.
§Arguments
message- The type of activity message sent.
Sourcepub fn update_websocket_connection(
&self,
elapsed_time: u128,
status: ConnectionResult,
)
pub fn update_websocket_connection( &self, elapsed_time: u128, status: ConnectionResult, )
Records a websocket connection attempt and its duration.
§Arguments
elapsed_time- Duration of the connection attempt in milliseconds.status- The result of the connection attempt.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Metrics
impl !RefUnwindSafe for Metrics
impl Send for Metrics
impl Sync for Metrics
impl Unpin for Metrics
impl !UnwindSafe for Metrics
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request