]> git.proxmox.com Git - ceph.git/blame - ceph/src/common/perf_counters_collection.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / common / perf_counters_collection.h
CommitLineData
11fdf7f2
TL
1#pragma once
2
3#include "common/perf_counters.h"
4#include "common/ceph_mutex.h"
9f95a23c 5#include "include/common_fwd.h"
11fdf7f2 6
9f95a23c 7namespace ceph::common {
11fdf7f2
TL
8class PerfCountersCollection
9{
10 CephContext *m_cct;
11
12 /** Protects perf_impl->m_loggers */
13 mutable ceph::mutex m_lock;
14 PerfCountersCollectionImpl perf_impl;
15public:
16 PerfCountersCollection(CephContext *cct);
17 ~PerfCountersCollection();
18 void add(PerfCounters *l);
19 void remove(PerfCounters *l);
20 void clear();
21 bool reset(const std::string &name);
22
23 void dump_formatted(ceph::Formatter *f, bool schema,
24 const std::string &logger = "",
25 const std::string &counter = "");
26 void dump_formatted_histograms(ceph::Formatter *f, bool schema,
27 const std::string &logger = "",
28 const std::string &counter = "");
29
30 void with_counters(std::function<void(const PerfCountersCollectionImpl::CounterMap &)>) const;
31
32 friend class PerfCountersCollectionTest;
33};
34
35class PerfCountersDeleter {
36 CephContext* cct;
37
38public:
39 PerfCountersDeleter() noexcept : cct(nullptr) {}
40 PerfCountersDeleter(CephContext* cct) noexcept : cct(cct) {}
41 void operator()(PerfCounters* p) noexcept;
42};
9f95a23c
TL
43}
44using PerfCountersRef = std::unique_ptr<ceph::common::PerfCounters, ceph::common::PerfCountersDeleter>;