summaryrefslogtreecommitdiffstats
path: root/src/common/perf_counters_collection.cc
blob: f03980eba2d48bc3d14a6869d7a3fa60de429572 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "common/perf_counters_collection.h"
#include "common/ceph_mutex.h"
#include "common/ceph_context.h"

namespace ceph::common {
/* PerfcounterCollection hold the lock for PerfCounterCollectionImp */
PerfCountersCollection::PerfCountersCollection(CephContext *cct)
  : m_cct(cct),
    m_lock(ceph::make_mutex("PerfCountersCollection"))
{
}
PerfCountersCollection::~PerfCountersCollection()
{
  clear();
}
void PerfCountersCollection::add(PerfCounters *l)
{
  std::lock_guard lck(m_lock);
  perf_impl.add(l);
}
void PerfCountersCollection::remove(PerfCounters *l)
{
  std::lock_guard lck(m_lock);
  perf_impl.remove(l);
}
void PerfCountersCollection::clear()
{
  std::lock_guard lck(m_lock);
  perf_impl.clear();
}
bool PerfCountersCollection::reset(const std::string &name)
{
  std::lock_guard lck(m_lock);
  return perf_impl.reset(name);
}
void PerfCountersCollection::dump_formatted(ceph::Formatter *f, bool schema,
                      bool dump_labeled,
                      const std::string &logger,
                      const std::string &counter)
{
  std::lock_guard lck(m_lock);
  perf_impl.dump_formatted(f, schema, dump_labeled, logger, counter);
}
void PerfCountersCollection::dump_formatted_histograms(ceph::Formatter *f, bool schema,
                                 const std::string &logger,
                                 const std::string &counter)
{
  std::lock_guard lck(m_lock);
  perf_impl.dump_formatted_histograms(f,schema,logger,counter);
}
void PerfCountersCollection::with_counters(std::function<void(const PerfCountersCollectionImpl::CounterMap &)> fn) const
{
  std::lock_guard lck(m_lock);
  perf_impl.with_counters(fn);
}
void PerfCountersDeleter::operator()(PerfCounters* p) noexcept
{
  if (cct)
    cct->get_perfcounters_collection()->remove(p);
  delete p;
}

}