pub trait MetricsProvider: Send + Sync {
// Required method
fn get_metrics<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
resource_id: &'life1 str,
context: &'life2 CallbackContext,
) -> Pin<Box<dyn Future<Output = LighthouseResult<Option<ResourceMetrics>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided method
fn validate_metrics<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
metrics: &'life1 ResourceMetrics,
_context: &'life2 CallbackContext,
) -> Pin<Box<dyn Future<Output = LighthouseResult<Option<ResourceMetrics>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}
Expand description
Trait for handling metric collection and validation
Implement this to provide metrics to the lighthouse engine. This allows you to integrate with any monitoring system.
Required Methods§
Sourcefn get_metrics<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
resource_id: &'life1 str,
context: &'life2 CallbackContext,
) -> Pin<Box<dyn Future<Output = LighthouseResult<Option<ResourceMetrics>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_metrics<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
resource_id: &'life1 str,
context: &'life2 CallbackContext,
) -> Pin<Box<dyn Future<Output = LighthouseResult<Option<ResourceMetrics>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Provided Methods§
Sourcefn validate_metrics<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
metrics: &'life1 ResourceMetrics,
_context: &'life2 CallbackContext,
) -> Pin<Box<dyn Future<Output = LighthouseResult<Option<ResourceMetrics>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn validate_metrics<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
metrics: &'life1 ResourceMetrics,
_context: &'life2 CallbackContext,
) -> Pin<Box<dyn Future<Output = LighthouseResult<Option<ResourceMetrics>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Validate that metrics are reasonable/expected
This is called before metrics are processed by scaling policies. Use this to filter out bad data, apply smoothing, etc.
§Arguments
metrics
- The raw metrics to validatecontext
- Additional context for the callback
§Returns
Ok(Some(validated_metrics))
- Metrics are valid (possibly modified)Ok(None)
- Metrics should be ignoredErr(error)
- Validation failed