pub struct Collector {
pub config: Config,
/* private fields */
}Expand description
Embedded CloudWatch Metrics Collector + Emitter
Use Builder to construct
§Example
let metrics = metrics_cloudwatch_embedded::Builder::new()
.cloudwatch_namespace("MyApplication")
.init()
.unwrap();
metrics::counter!("requests", "Method" => "Default").increment(1);
metrics
.set_property("RequestId", "ABC123")
.flush(std::io::stdout());Fields§
§config: ConfigImplementations§
Source§impl Collector
impl Collector
pub fn new(config: Config, lambda_cold_start_span: Option<Span>) -> Self
Sourcepub fn set_property(
&self,
name: impl Into<SharedString>,
value: impl Into<Value>,
) -> &Self
pub fn set_property( &self, name: impl Into<SharedString>, value: impl Into<Value>, ) -> &Self
Set a property to emit with the metrics
- Properites persist accross flush calls
- Setting a property with same name multiple times will overwrite the previous value
Sourcepub fn remove_property<'a>(&'a self, name: impl Into<&'a str>) -> &'a Self
pub fn remove_property<'a>(&'a self, name: impl Into<&'a str>) -> &'a Self
Removes a property to emit with the metrics
Sourcepub fn flush(&self, writer: impl Write) -> Result<()>
pub fn flush(&self, writer: impl Write) -> Result<()>
Flush the current counter values to an implementation of std::io::Write
Sourcepub fn write_single(
&self,
name: impl Into<SharedString>,
unit: Option<Unit>,
value: impl Into<Value>,
writer: impl Write,
) -> Result<()>
pub fn write_single( &self, name: impl Into<SharedString>, unit: Option<Unit>, value: impl Into<Value>, writer: impl Write, ) -> Result<()>
Write a single metric to an implementation of std::io::Write, avoids the overhead of going through the metrics recorder
pub fn take_cold_start_span(&self) -> Option<Span>
Auto Trait Implementations§
impl !Freeze for Collector
impl RefUnwindSafe for Collector
impl Send for Collector
impl Sync for Collector
impl Unpin for Collector
impl UnwindSafe for Collector
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