pub struct Cogs { /* private fields */ }Expand description
COGS measurements collector.
The collector is cheap to clone.
Implementations§
Source§impl Cogs
impl Cogs
Sourcepub fn new<T>(recorder: T) -> Selfwhere
T: CogsRecorder + 'static,
pub fn new<T>(recorder: T) -> Selfwhere
T: CogsRecorder + 'static,
Sourcepub fn noop() -> Self
pub fn noop() -> Self
Shortcut for creating a Cogs from a crate::NoopRecorder.
All collected measurements will be dropped.
Source§impl Cogs
impl Cogs
Sourcepub fn timed<F: Into<FeatureWeights>>(
&self,
resource: ResourceId,
weights: F,
) -> Token
pub fn timed<F: Into<FeatureWeights>>( &self, resource: ResourceId, weights: F, ) -> Token
Starts a recording for a COGS measurement, using the SystemClock.
When the returned token is dropped the measurement will be recorded with the configured recorder.
The recorded measurement can be attributed to multiple features by supplying a
weighted FeatureWeights. A single AppFeature attributes the entire measurement
to the feature.
See also: Self::timed_with.
§Example:
fn process_span(cogs: &Cogs, span: &mut Span) {
let _token = cogs.timed(ResourceId::Relay, AppFeature::Spans);
scrub_sql(span);
extract_tags(span);
}
Sourcepub fn timed_with<F: Into<FeatureWeights>, C: Clock>(
&self,
resource: ResourceId,
weights: F,
clock: C,
) -> Token<C>
pub fn timed_with<F: Into<FeatureWeights>, C: Clock>( &self, resource: ResourceId, weights: F, clock: C, ) -> Token<C>
Starts a recording for a COGS measurement with a specific Clock.
When the returned token is dropped the measurement will be recorded with the configured recorder.
The recorded measurement can be attributed to multiple features by supplying a
weighted FeatureWeights. A single AppFeature attributes the entire measurement
to the feature.
§Example:
fn process_span(cogs: &Cogs, span: &mut Span) {
let _token = cogs.timed_with(ResourceId::Relay, AppFeature::Spans, CustomClock);
scrub_sql(span);
extract_tags(span);
}