pub struct MetricsFileSink { /* private fields */ }Expand description
Writer for one metrics output file.
JSONL output appends one object per event. Prometheus output atomically replaces the file with the latest encoded snapshot on each write.
Implementations§
Source§impl MetricsFileSink
impl MetricsFileSink
Sourcepub fn new(path: impl Into<PathBuf>, format: MetricsFileFormat) -> Result<Self>
pub fn new(path: impl Into<PathBuf>, format: MetricsFileFormat) -> Result<Self>
Create a sink with the default Prometheus metric prefix.
Sourcepub fn with_prefix(
path: impl Into<PathBuf>,
format: MetricsFileFormat,
metric_prefix: impl Into<String>,
) -> Result<Self>
pub fn with_prefix( path: impl Into<PathBuf>, format: MetricsFileFormat, metric_prefix: impl Into<String>, ) -> Result<Self>
Create a sink with a custom Prometheus metric prefix.
Sourcepub fn with_prefix_and_labels<I, K, V>(
path: impl Into<PathBuf>,
format: MetricsFileFormat,
metric_prefix: impl Into<String>,
labels: I,
) -> Result<Self>
pub fn with_prefix_and_labels<I, K, V>( path: impl Into<PathBuf>, format: MetricsFileFormat, metric_prefix: impl Into<String>, labels: I, ) -> Result<Self>
Create a sink with a custom Prometheus metric prefix and labels.
Labels are applied only to Prometheus text exposition output. JSONL output carries structured metric fields and its own schema version.
Sourcepub fn format(&self) -> MetricsFileFormat
pub fn format(&self) -> MetricsFileFormat
Return the configured output format.
Sourcepub fn write_event(&self, event: &MetricEvent) -> Result<()>
pub fn write_event(&self, event: &MetricEvent) -> Result<()>
Write one metrics stream event.
Sourcepub fn write_interval(&self, metrics: &Metrics) -> Result<()>
pub fn write_interval(&self, metrics: &Metrics) -> Result<()>
Write one immediate interval sample.
Sourcepub fn write_window(&self, metrics: &WindowMetrics) -> Result<()>
pub fn write_window(&self, metrics: &WindowMetrics) -> Result<()>
Write one aggregated window summary.
Trait Implementations§
Source§impl Clone for MetricsFileSink
impl Clone for MetricsFileSink
Source§fn clone(&self) -> MetricsFileSink
fn clone(&self) -> MetricsFileSink
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MetricsFileSink
impl RefUnwindSafe for MetricsFileSink
impl Send for MetricsFileSink
impl Sync for MetricsFileSink
impl Unpin for MetricsFileSink
impl UnsafeUnpin for MetricsFileSink
impl UnwindSafe for MetricsFileSink
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