From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/common/perf_counters_collection.h | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/common/perf_counters_collection.h (limited to 'src/common/perf_counters_collection.h') 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) 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; + + -- cgit v1.2.3