# ██████╗ ███████╗██████╗ ███████╗
# ██╔══██╗██╔════╝██╔══██╗██╔════╝
# ██████╔╝█████╗  ██████╔╝███████╗
# ██╔══██╗██╔══╝  ██╔═══╝ ╚════██║
# ██║  ██║███████╗██║     ███████║
# ╚═╝  ╚═╝╚══════╝╚═╝     ╚══════╝
#╔═══════════════════════════════╗
#║ Rust Efficiency & Performance ║
#╚═══════════════════════════════╝
[package]
name    = "metrics-lib"
version = "0.9.5"

# Minimum Supported Rust Version (MSRV)
rust-version = "1.70"
edition = "2021"

# License
license = "Apache-2.0"

# Readme
readme = "README.md"

# Description
description = "High-performance Rust metrics library: sub-2ns counters, sub-1ns gauges, nanosecond timers, tumbling-window rate meters, async timing, adaptive sampling, and system health. Cross-platform with minimal dependencies."

# Keywords (5 total)
keywords = [
    "benchmark", 
    "performance", 
    "profiling", 
    "timing", 
    "metrics"
]

# Categories (5 total)
categories = [
    "development-tools::profiling", 
    "memory-management"
]

# Links
homepage      = "https://github.com/jamesgober/metrics-lib"
repository    = "https://github.com/jamesgober/metrics-lib"
documentation = "https://docs.rs/metrics-lib"

# Authors
authors = [
    "James Gober <me@jamesgober.com>"
]

# `sysinfo` is gated on `#[cfg(not(target_os = "linux"))]` everywhere it
# is used. On Linux CI runners cargo-udeps therefore reports it as
# "unused"; this is a false positive (it's the cross-platform backend on
# macOS and Windows). Tell cargo-udeps to skip it.
[package.metadata.cargo-udeps.ignore]
normal = ["sysinfo"]



# FEATURE FLAGS
# #################################
[features]
# Core metric types — each gates its own module and re-exports.
count       = []
gauge       = []
timer       = []
meter       = []

# Adaptive sampling / circuit breaker / backpressure controllers.
sample      = []

# Enable running benchmark-style assertions inside `cargo test` (slow,
# timing-coupled; gated and ignored by default).
bench-tests = []

# Enables async support (Tokio runtime helpers + AsyncMetricsBatcher).
async       = ["dep:tokio"]

# Histogram type with configurable buckets and quantile estimation.
histogram   = ["sample"]

# Wire Serde derive support for stats and snapshot types, plus the
# `exporters::json` JSON snapshot exporter (pulls in `serde_json`).
serde       = ["dep:serde", "dep:serde_json"]

# Built-in StatsD UDP exporter (`exporters::statsd`). No new transitive deps
# — uses `std::net::UdpSocket`.
statsd      = []

# Built-in OTLP/HTTP+JSON exporter (`exporters::otlp`). Requires the
# `serde` feature so the OTLP payload can be serialised.
otlp        = ["serde"]

# Optional `tracing` integration: opt-in helpers that wrap `Timer`
# operations with a `tracing::info_span!`. Hot paths are unchanged when
# this flag is off.
tracing     = ["dep:tracing"]

# All built-in exporters (Prometheus + OpenMetrics are always-on; this flag
# adds JSON snapshot + StatsD UDP + OTLP/HTTP+JSON).
exporters-all = ["serde", "statsd", "otlp"]

# Aggregate flags. `all` excludes runtime-dependent features so it can be
# enabled on environments that don't link against Tokio or Serde.
all  = ["count", "gauge", "timer", "meter", "sample", "histogram"]
full = [
    "count", "gauge", "timer", "meter", "sample", "histogram",
    "async", "serde", "statsd", "otlp", "tracing",
]

# Default build: counters + gauges + timers (the most common subset).
default = ["count", "gauge", "timer"]

# Smallest useful build (counter only).
minimal = ["count"]



# BENCHMARKS
# #################################
[[bench]]
name    = "metrics_bench"
harness = false
required-features = ["meter"]

# EXAMPLES
# #################################
[[example]]
name = "quick_start"
required-features = ["meter"]

[[example]]
name = "quick_tour"
required-features = ["meter"]

[[example]]
name = "token_bucket_limiter"
required-features = ["meter"]

[[example]]
name = "contention_admission"
required-features = ["meter"]

[[example]]
name = "broker_throughput"
required-features = ["meter"]

[[example]]
name = "custom_exporter_openmetrics"
required-features = ["meter"]

[[example]]
name = "benchmark_comparison"
required-features = ["meter"]

[[example]]
name = "async_batch_timing"
required-features = ["async"]

[[example]]
name = "axum_middleware_metrics"
required-features = ["async"]

[[example]]
name = "health_dashboard"
required-features = ["async"]

[[example]]
name = "streaming_rate_window"
required-features = ["async", "meter"]

[[example]]
name = "axum_registry_integration"
required-features = ["async", "meter"]

# Examples that use specific metric features.
[[example]]
name = "cache_hit_miss"
required-features = ["count", "timer"]

# System health examples — only need SystemHealth (always compiled), no metric feature gates required.
[[example]]
name = "cpu_stats"

[[example]]
name = "memory_stats"

# v0.9.3 telemetry examples.
[[example]]
name = "labels_demo"
required-features = ["count"]

[[example]]
name = "histogram_latency"
required-features = ["histogram"]

[[example]]
name = "prometheus_endpoint"
required-features = ["async", "count", "gauge", "timer", "histogram"]

[[example]]
name = "statsd_push"
required-features = ["statsd", "count", "gauge", "timer"]

[[example]]
name = "otlp_push"
required-features = ["otlp", "count", "gauge", "timer", "histogram"]

[[example]]
name = "snapshot_serde"
required-features = ["serde", "count", "gauge"]



# DEPENDENCIES
# #################################
[dependencies]
tokio = { version = "1.0", features = ["rt", "time", "macros", "sync"], optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
tracing = { version = "0.1", default-features = false, features = ["std"], optional = true }
num_cpus    = "1.16"
parking_lot = "0.12"
sysinfo = { version = "0.29", default-features = false }



# DEV DEPENDENCIES
# #################################
[dev-dependencies]
# Pin Criterion minor for reproducible output layout in CI aggregation
criterion = { version = "=0.4.0", default-features = false }
tokio-test = "0.4"
half = "=2.2.1" # Pin transitive resolution (via plotters) to MSRV-compatible half version
doc-comment = "0.3"
axum = { version = "0.7", default-features = false, features = ["http1", "json", "tokio"] }
serde_json = "1.0"
# Tokio runtime for examples
tokio = { version = "1.0", features = ["full"] }
rand = "0.8"
anyhow = "1"
tower = "0.5"
crossbeam-channel = "0.5"
# Property-based testing (v0.9.5+). Pinned to a 1.0.x line that compiles
# clean on MSRV 1.70.
proptest = { version = "=1.0.0", default-features = false, features = ["std"] }
