Skip to main content

Crate metrique_metricsrs

Crate metrique_metricsrs 

Source
Expand description

This mode provides a few metrics::Recorders that can be used for emitting metrics via metrique-writer. This includes MetricReporter that is designed for use in EC2/Fargate, lambda_reporter that is designed for use in Lambda, and capture that is designed for use in unit tests.

See the linked documentation pages for examples.

This allows capturing metrics emitted via the metrics.rs facade into metrique.

This crate intends to be able to support multiple metrics.rs versions with a single metrique-metricsrs major version. Therefore, you’ll need to enable feature flags corresponding to the metrics.rs version you are using, and pass the version via a dyn metrics::Recorder “witness”.

For example, enable this in your Cargo.toml:

[dependencies]
...
metrique-metricsrs = { version = "0.1", features = ["metrics-rs-024"] }

Then in your main code, for example:

use metrique_metricsrs::MetricReporter;
use metrique_writer::{Entry, EntryIoStream, FormatExt, EntryIoStreamExt};
use metrique_writer_format_emf::Emf;
use tracing_appender::rolling::{RollingFileAppender, Rotation};

let log_dir = std::path::PathBuf::from("example");
let logger = MetricReporter::builder()
    .metrics_rs_version::<dyn metrics::Recorder>()
    .metrics_io_stream(Emf::all_validations("MyNS".to_string(),
        vec![vec![], vec!["service".to_string()]]).output_to_makewriter(
            RollingFileAppender::new(Rotation::HOURLY, &log_dir, "metric_log.log")
        )
    )
    .build_and_install();

Currently, there is only 1 metrics.rs version supported (0.24), but when there will be more, having the feature-flag for an unused metrics.rs version will do no harm.

Modules§

capture
This module contains functions for capturing metrics, generally to be used in tests.
lambda_reporter
This module contains a metric reporter that allows easily emitting metrics from a Lambda.
metrics_histogram
Histogram class to record a distribution of values

Structs§

MetricAccumulatorEntry
Represents a readout of metrics, with values for all the given metrics.
MetricRecorder
The metric recorder belonging to this crate. Accumulates metrics in a registry and lets them be read out via readout
MetricReporter
A handle to a metric reporter. This struct is mainly used to synchronize shutdown of the metric reporter to ensure all metrics are flushed on shutdown.
MetricReporterBuilder
Builder for MetricReporter
SharedRecorder
A Cloneable dynamic recorder that implements the Recorder trait

Traits§

MetricsRsVersion
A trait to allow the metrics.rs bridge to be generic over metrics.rs versions
ParametricRecorder
A trait to allow the metrics.rs bridge to be generic over versions of metrics.rs metrics::Recorders. This trait is not to be manually implemented or called by users.