diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/common/perf_counters_collection.h | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/common/perf_counters_collection.h')
-rw-r--r-- | src/common/perf_counters_collection.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/common/perf_counters_collection.h b/src/common/perf_counters_collection.h new file mode 100644 index 00000000..53a8f341 --- /dev/null +++ b/src/common/perf_counters_collection.h @@ -0,0 +1,46 @@ +#pragma once + +#include "common/perf_counters.h" +#include "common/ceph_mutex.h" + +class CephContext; + +class PerfCountersCollection +{ + CephContext *m_cct; + + /** Protects perf_impl->m_loggers */ + mutable ceph::mutex m_lock; + PerfCountersCollectionImpl perf_impl; +public: + PerfCountersCollection(CephContext *cct); + ~PerfCountersCollection(); + void add(PerfCounters *l); + void remove(PerfCounters *l); + void clear(); + bool reset(const std::string &name); + + void dump_formatted(ceph::Formatter *f, bool schema, + const std::string &logger = "", + const std::string &counter = ""); + void dump_formatted_histograms(ceph::Formatter *f, bool schema, + const std::string &logger = "", + const std::string &counter = ""); + + void with_counters(std::function<void(const PerfCountersCollectionImpl::CounterMap &)>) const; + + friend class PerfCountersCollectionTest; +}; + +class PerfCountersDeleter { + CephContext* cct; + +public: + PerfCountersDeleter() noexcept : cct(nullptr) {} + PerfCountersDeleter(CephContext* cct) noexcept : cct(cct) {} + void operator()(PerfCounters* p) noexcept; +}; + +using PerfCountersRef = std::unique_ptr<PerfCounters, PerfCountersDeleter>; + + |