pub struct Builder { /* private fields */ }Expand description
Builder for the Embedded Cloudwatch Metrics Collector
§Example
let metrics = metrics_cloudwatch_embedded::Builder::new()
.cloudwatch_namespace("MyApplication")
.init()
.unwrap();Implementations§
Source§impl Builder
impl Builder
pub fn new() -> Self
Sourcepub fn cloudwatch_namespace(self, namespace: impl Into<SharedString>) -> Self
pub fn cloudwatch_namespace(self, namespace: impl Into<SharedString>) -> Self
Sets the CloudWatch namespace for all metrics
- Must be set or init() will return Err(“cloudwatch_namespace missing”)
Sourcepub fn with_dimension(
self,
name: impl Into<SharedString>,
value: impl Into<SharedString>,
) -> Self
pub fn with_dimension( self, name: impl Into<SharedString>, value: impl Into<SharedString>, ) -> Self
Adds a static dimension (name, value), that will be sent with each MetricDatum.
- This method can be called multiple times with distinct names
- Dimention names may not overlap with metrics::Label names
- Metrics can have no more than 30 dimensions + labels
Sourcepub fn with_timestamp(self, timestamp: u64) -> Self
pub fn with_timestamp(self, timestamp: u64) -> Self
Sets the timestamp for flush to a constant value to simplify tests
Sourcepub fn emit_zeros(self, emit_zeros: bool) -> Self
pub fn emit_zeros(self, emit_zeros: bool) -> Self
If set to true, the collector will emit a zero value metrics instead of skipping
defaults to false
Sourcepub fn lambda_cold_start_span(self, cold_start_span: Span) -> Self
pub fn lambda_cold_start_span(self, cold_start_span: Span) -> Self
Passes a tracing span to drop after our cold start is complete
requires the lambda feature flag
Sourcepub fn lambda_cold_start_metric(self, name: &'static str) -> Self
pub fn lambda_cold_start_metric(self, name: &'static str) -> Self
Emits a cold start metric with the given name once to mark a cold start
requires the lambda feature flag
Sourcepub fn with_lambda_request_id(self, name: &'static str) -> Self
pub fn with_lambda_request_id(self, name: &'static str) -> Self
Decorates every metric with request_id from the lambda request context as a property with the given name
requires the lambda feature flag
Sourcepub fn with_lambda_xray_trace_id(self, name: &'static str) -> Self
pub fn with_lambda_xray_trace_id(self, name: &'static str) -> Self
Decorates every metric with lambda_xray_trace_id from the lambda request context as a property with the given name
requires the lambda feature flag
Sourcepub fn init(self) -> Result<&'static Collector, Error>
pub fn init(self) -> Result<&'static Collector, Error>
Intialize the metrics collector including the call to metrics::set_global_recorder