Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

2.1 KB
Raw Blame
//! What the Lance jobs reclaimed, in numbers a scrape can add up.
//!
//! The generic worker metrics say a job ran and how long it took. These say what
//! it did: a compaction sweep that runs every minute and removes nothing is a
//! different thing from one that never runs, and only these tell them apart.

use anyhow::Result;
use prometheus::IntCounter;
use seaweed_worker_core::Metrics;

/// Counters the Lance jobs raise, registered on the worker's own registry so
/// they are served from the same endpoint.
#[derive(Clone)]
pub struct LanceMetrics {
    /// The worker's own metrics, so a job can also record what it read and what
    /// it had to skip - the pair that tells "nothing needed doing" apart from
    /// "nothing could be read".
    pub worker: Metrics,
    pub fragments_removed: IntCounter,
    pub rows_indexed: IntCounter,
    pub indexes_built: IntCounter,
    pub rows_sorted: IntCounter,
    pub versions_removed: IntCounter,
    pub bytes_reclaimed: IntCounter,
}

impl LanceMetrics {
    pub fn new(metrics: &Metrics) -> Result<Self> {
        Ok(Self {
            worker: metrics.clone(),
            fragments_removed: metrics.counter(
                "lance_fragments_removed_total",
                "Fragments merged away by compaction.",
            )?,
            rows_indexed: metrics.counter(
                "lance_rows_indexed_total",
                "Rows brought under an index that did not cover them.",
            )?,
            indexes_built: metrics.counter(
                "lance_vector_indexes_built_total",
                "Vector indexes built for S3 Vectors tables.",
            )?,
            rows_sorted: metrics.counter(
                "lance_rows_sorted_total",
                "Rows rewritten into their table's declared order.",
            )?,
            versions_removed: metrics.counter(
                "lance_versions_removed_total",
                "Dataset versions removed by cleanup.",
            )?,
            bytes_reclaimed: metrics
                .counter("lance_bytes_reclaimed_total", "Bytes freed by cleanup.")?,
        })
    }
}