operations capa

operations-metrics

Observability and metrics for Rust applications

Observability and metrics for Rust applications

Tieroperations
Roleunclassified (baselined)
Pathcrates/operations/metrics
Edition2021
Targetsoperations_metrics
Public items54 across 0 modules
Tests23

What it is for

Observability and metrics library crates for Rust applications.

This crate provides abstractions for collecting and exporting application metrics (counters, gauges, histograms).

Capabilities

Counter

Observability and metrics library crates for Rust applications.

Item
pub struct Counter
Counter :: fn new(name : impl Into <String>, help : impl Into <String>) -> Self
Counter :: fn with_labels(mut self, labels : Labels) -> Self
Counter :: fn inc(& self)
Counter :: fn inc_by(& self, v : u64)
Counter :: fn get(& self) -> u64
Counter :: fn reset(& self)
Counter :: fn name(& self) -> & str
Counter :: fn help(& self) -> & str

Gauge

Observability and metrics library crates for Rust applications.

Item
pub struct Gauge
Gauge :: fn new(name : impl Into <String>, help : impl Into <String>) -> Self
Gauge :: fn with_labels(mut self, labels : Labels) -> Self
Gauge :: fn set(& self, v : i64)
Gauge :: fn inc(& self)
Gauge :: fn dec(& self)
Gauge :: fn add(& self, v : i64)
Gauge :: fn sub(& self, v : i64)
Gauge :: fn get(& self) -> i64
Gauge :: fn name(& self) -> & str

Histogram

Observability and metrics library crates for Rust applications.

Item
pub struct Histogram
Histogram :: fn new(name : impl Into <String>, help : impl Into <String>) -> Self
Histogram :: fn with_buckets(name : impl Into <String>, help : impl Into <String>, mut buckets : Vec <f64>,) -> Self
Histogram :: fn with_labels(mut self, labels : Labels) -> Self
Histogram :: fn observe(& self, v : f64)
Histogram :: fn get_count(& self) -> u64
Histogram :: fn get_sum(& self) -> f64
Histogram :: fn get_buckets(& self) -> Vec <HistogramBucket>
Histogram :: fn name(& self) -> & str

HistogramBucket

Observability and metrics library crates for Rust applications.

Item
pub struct HistogramBucket

Labels

Observability and metrics library crates for Rust applications.

Item
pub type Labels: HashMap <String, String>

MetricSample

Observability and metrics library crates for Rust applications.

Item
pub struct MetricSample
MetricSample :: fn new(name : impl Into <String>, metric_type : MetricType, value : f64) -> Self
MetricSample :: fn with_label(mut self, key : impl Into <String>, value : impl Into <String>) -> Self

MetricType

Observability and metrics library crates for Rust applications.

Item
pub enum MetricType
MetricType :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result

MetricsError

Observability and metrics library crates for Rust applications.

Item
pub enum MetricsError

Registry:Registry

Observability and metrics library crates for Rust applications.

Item
pub struct Registry

Registry:counter

Observability and metrics library crates for Rust applications.

Item
Registry :: fn counter(& self, name : impl Into <String>, help : impl Into <String>) -> Arc <Counter>

Registry:export

Observability and metrics library crates for Rust applications.

Item
Registry :: fn export_prometheus(& self) -> String
Registry :: fn export_json(& self) -> serde_json::Value

Registry:gauge

Observability and metrics library crates for Rust applications.

Item
Registry :: fn gauge(& self, name : impl Into <String>, help : impl Into <String>) -> Arc <Gauge>

Registry:get

Observability and metrics library crates for Rust applications.

Item
Registry :: fn get_counter(& self, name : & str) -> Option <Arc <Counter>>
Registry :: fn get_gauge(& self, name : & str) -> Option <Arc <Gauge>>
Registry :: fn get_histogram(& self, name : & str) -> Option <Arc <Histogram>>

Registry:histogram

Observability and metrics library crates for Rust applications.

Item
Registry :: fn histogram(& self, name : impl Into <String>, help : impl Into <String>) -> Arc <Histogram>

Registry:new

Observability and metrics library crates for Rust applications.

Item
Registry :: fn new() -> Self

Registry:register

Observability and metrics library crates for Rust applications.

Item
Registry :: fn register_counter(& self, counter : Counter) -> Arc <Counter>
Registry :: fn register_gauge(& self, gauge : Gauge) -> Arc <Gauge>
Registry :: fn register_histogram(& self, histogram : Histogram) -> Arc <Histogram>

Result

Observability and metrics library crates for Rust applications.

Item
pub type Result<T>: std::result::Result <T, MetricsError>

Timer

Observability and metrics library crates for Rust applications.

Item
pub struct Timer
Timer :: fn new(histogram : Arc <Histogram>) -> Self
Timer :: fn stop(self) -> f64
Timer :: fn drop(& mut self)

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
pub enum MetricsErrorErrors that can occur with metrics.
pub type Result<T>: std::result::Result <T, MetricsError>Result type for metrics operations.
pub enum MetricTypeMetric type.
MetricType :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
pub type Labels: HashMap <String, String>Labels for a metric (key-value pairs).
pub struct CounterA metric counter.
Counter :: fn new(name : impl Into <String>, help : impl Into <String>) -> SelfCreates a new counter.
Counter :: fn with_labels(mut self, labels : Labels) -> SelfCreates a counter with labels.
Counter :: fn inc(& self)Increments the counter by 1.
Counter :: fn inc_by(& self, v : u64)Increments the counter by a value.
Counter :: fn get(& self) -> u64Gets the current value.
Counter :: fn reset(& self)Resets the counter.
Counter :: fn name(& self) -> & strGets the metric name.
Counter :: fn help(& self) -> & strGets the help text.
pub struct GaugeA metric gauge.
Gauge :: fn new(name : impl Into <String>, help : impl Into <String>) -> SelfCreates a new gauge.
Gauge :: fn with_labels(mut self, labels : Labels) -> SelfCreates a gauge with labels.
Gauge :: fn set(& self, v : i64)Sets the gauge value.
Gauge :: fn inc(& self)Increments the gauge by 1.
Gauge :: fn dec(& self)Decrements the gauge by 1.
Gauge :: fn add(& self, v : i64)Adds to the gauge.
Gauge :: fn sub(& self, v : i64)Subtracts from the gauge.
Gauge :: fn get(& self) -> i64Gets the current value.
Gauge :: fn name(& self) -> & strGets the metric name.
pub struct HistogramBucketHistogram bucket.
pub struct HistogramA metric histogram.
Histogram :: fn new(name : impl Into <String>, help : impl Into <String>) -> SelfCreates a new histogram with default buckets.
Histogram :: fn with_buckets(name : impl Into <String>, help : impl Into <String>, mut buckets : Vec <f64>,) -> SelfCreates a histogram with custom buckets.
Histogram :: fn with_labels(mut self, labels : Labels) -> SelfCreates a histogram with labels.
Histogram :: fn observe(& self, v : f64)Observes a value.
Histogram :: fn get_count(& self) -> u64Gets the observation count.
Histogram :: fn get_sum(& self) -> f64Gets the sum of observations.
Histogram :: fn get_buckets(& self) -> Vec <HistogramBucket>Gets bucket data.
Histogram :: fn name(& self) -> & strGets the metric name.
pub struct TimerTimer for measuring duration.
Timer :: fn new(histogram : Arc <Histogram>) -> SelfCreates a new timer.
Timer :: fn stop(self) -> f64Stops the timer and records the duration.
Timer :: fn drop(& mut self)
pub struct RegistryMetrics registry.
Registry :: fn new() -> SelfCreates a new registry.
Registry :: fn register_counter(& self, counter : Counter) -> Arc <Counter>Registers a counter.
Registry :: fn register_gauge(& self, gauge : Gauge) -> Arc <Gauge>Registers a gauge.
Registry :: fn register_histogram(& self, histogram : Histogram) -> Arc <Histogram>Registers a histogram.
Registry :: fn get_counter(& self, name : & str) -> Option <Arc <Counter>>Gets a counter by name.
Registry :: fn get_gauge(& self, name : & str) -> Option <Arc <Gauge>>Gets a gauge by name.
Registry :: fn get_histogram(& self, name : & str) -> Option <Arc <Histogram>>Gets a histogram by name.
Registry :: fn counter(& self, name : impl Into <String>, help : impl Into <String>) -> Arc <Counter>Gets or creates a counter.
Registry :: fn gauge(& self, name : impl Into <String>, help : impl Into <String>) -> Arc <Gauge>Gets or creates a gauge.
Registry :: fn histogram(& self, name : impl Into <String>, help : impl Into <String>) -> Arc <Histogram>Gets or creates a histogram.
Registry :: fn export_prometheus(& self) -> StringExports metrics in Prometheus format.
Registry :: fn export_json(& self) -> serde_json::ValueExports metrics as JSON.
pub struct MetricSampleMetric sample for export.
MetricSample :: fn new(name : impl Into <String>, metric_type : MetricType, value : f64) -> SelfCreates a new sample.
MetricSample :: fn with_label(mut self, key : impl Into <String>, value : impl Into <String>) -> SelfAdds a label.

No pub use re-exports: every item above is declared in this crate.

Boundary

Depends on no other workspace tier.

Shares tier operations with 40 other crates: operations-approval-workflow, operations-assessments, operations-block-imaging, operations-boot-media, operations-browser-agent-worker, operations-camera-discovery, operations-camera-liveview, operations-camera-registry, … (40 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)operations
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/operations/metrics
Vocabulary in force (lexicon)current

Dependencies

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
chrono^0.4serdenoalways
serde^1derivenoalways
serde_json^1noalways
thiserror^2noalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio^1fullnoalways

Build. None.

Depended on by. 1 workspace crate.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_application_metrics["application-metrics"] -->|uses| SELF
  SELF["operations-metrics"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
liboperations_metrics`src/lib.rs`

Error model

Error typeNamed by
MetricsErrorResult

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

1 workspace crate depends on this one: application-metrics.

Verification

KindCount
Unit tests23
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root1101

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc5254
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 52
    "No rustdoc detected" : 2

Metrics

MetricValue
Rust source files1
Source lines755
Code lines572
Public API items54
Public modules0
Tests23
Examples0
Cargo features0
Direct runtime dependencies4
Workspace reverse dependencies1
pie showData
    title Public API by kind
    "enum" : 2
    "method" : 43
    "struct" : 7
    "type alias" : 2
pie showData
    title Rust source composition
    "Code" : 572
    "Blank or comment" : 183

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

Todas las operations · Manual