|
| 1 | +/* |
| 2 | + * Copyright 2025 Redpanda Data, Inc. |
| 3 | + * |
| 4 | + * Licensed as a Redpanda Enterprise file under the Redpanda Community |
| 5 | + * License (the "License"); you may not use this file except in compliance with |
| 6 | + * the License. You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://github.com/redpanda-data/redpanda/blob/master/licenses/rcl.md |
| 9 | + */ |
| 10 | + |
| 11 | +#pragma once |
| 12 | + |
| 13 | +#include "compaction/types.h" |
| 14 | +#include "metrics/metrics.h" |
| 15 | +#include "utils/log_hist.h" |
| 16 | + |
| 17 | +#include <seastar/core/metrics_registration.hh> |
| 18 | + |
| 19 | +#include <cstdint> |
| 20 | +#include <memory> |
| 21 | + |
| 22 | +namespace cloud_topics::l1 { |
| 23 | + |
| 24 | +class compaction_worker_probe { |
| 25 | +public: |
| 26 | + using hist_t = log_hist_internal; |
| 27 | + compaction_worker_probe() = default; |
| 28 | + |
| 29 | + compaction_worker_probe(const compaction_worker_probe&) = delete; |
| 30 | + compaction_worker_probe& operator=(const compaction_worker_probe&) = delete; |
| 31 | + compaction_worker_probe(compaction_worker_probe&&) = delete; |
| 32 | + compaction_worker_probe& operator=(compaction_worker_probe&&) = delete; |
| 33 | + ~compaction_worker_probe() = default; |
| 34 | + |
| 35 | + void setup_metrics(); |
| 36 | + |
| 37 | + std::unique_ptr<hist_t::measurement> auto_compaction_measurement() { |
| 38 | + return _compaction_runs.auto_measure(); |
| 39 | + } |
| 40 | + |
| 41 | + void add_stats(const compaction::stats& stats) { |
| 42 | + _batches_removed += stats.batches_discarded; |
| 43 | + _records_removed += stats.records_discarded; |
| 44 | + _tombstones_removed += stats.expired_tombstones_discarded; |
| 45 | + } |
| 46 | + |
| 47 | +private: |
| 48 | + hist_t _compaction_runs; |
| 49 | + |
| 50 | + uint64_t _batches_removed{0}; |
| 51 | + uint64_t _records_removed{0}; |
| 52 | + uint64_t _tombstones_removed{0}; |
| 53 | + |
| 54 | + metrics::internal_metric_groups _metrics; |
| 55 | +}; |
| 56 | + |
| 57 | +} // namespace cloud_topics::l1 |
0 commit comments