pub struct CloudWatchMetrics { /* private fields */ }Expand description
AWS CloudWatch Metrics implementation of CloudMetrics.
This implementation provides:
- Batched metric export for efficiency
- Support for custom dimensions
- Automatic namespace configuration
- Standard and custom units
§Example
use llm_shield_cloud_aws::CloudWatchMetrics;
use llm_shield_cloud::{CloudMetrics, Metric};
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let metrics = CloudWatchMetrics::new("LLMShield").await?;
let metric = Metric {
name: "RequestCount".to_string(),
value: 1.0,
timestamp: std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)?
.as_secs(),
dimensions: HashMap::new(),
unit: Some("Count".to_string()),
};
metrics.export_metric(&metric).await?;
Ok(())
}Implementations§
Trait Implementations§
Source§impl CloudMetrics for CloudWatchMetrics
impl CloudMetrics for CloudWatchMetrics
Auto Trait Implementations§
impl Freeze for CloudWatchMetrics
impl !RefUnwindSafe for CloudWatchMetrics
impl Send for CloudWatchMetrics
impl Sync for CloudWatchMetrics
impl Unpin for CloudWatchMetrics
impl !UnwindSafe for CloudWatchMetrics
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> 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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.