]>
git.proxmox.com Git - ceph.git/blob - ceph/src/common/TracepointProvider.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_TRACEPOINT_PROVIDER_H
5 #define CEPH_TRACEPOINT_PROVIDER_H
7 #include "include/int_types.h"
8 #include "common/ceph_context.h"
9 #include "common/config_obs.h"
10 #include "common/Mutex.h"
14 #include <boost/noncopyable.hpp>
18 class TracepointProvider
: public md_config_obs_t
, boost::noncopyable
{
22 const char *config_key
;
24 Traits(const char *library
, const char *config_key
)
25 : library(library
), config_key(config_key
) {
31 Singleton(CephContext
*cct
, const char *library
, const char *config_key
)
32 : tracepoint_provider(new TracepointProvider(cct
, library
, config_key
)) {
35 delete tracepoint_provider
;
38 inline bool is_enabled() const {
39 return tracepoint_provider
->m_handle
!= nullptr;
42 TracepointProvider
*tracepoint_provider
;
45 template <const Traits
&traits
>
46 class TypedSingleton
: public Singleton
{
48 explicit TypedSingleton(CephContext
*cct
)
49 : Singleton(cct
, traits
.library
, traits
.config_key
) {
53 TracepointProvider(CephContext
*cct
, const char *library
,
54 const char *config_key
);
55 ~TracepointProvider() override
;
57 template <const Traits
&traits
>
58 static void initialize(CephContext
*cct
) {
60 TypedSingleton
<traits
> *singleton
;
61 cct
->lookup_or_create_singleton_object(singleton
, traits
.library
);
66 const char** get_tracked_conf_keys() const override
{
69 void handle_conf_change(const struct md_config_t
*conf
,
70 const std::set
<std::string
> &changed
) override
;
74 std::string m_library
;
75 mutable const char* m_config_keys
[2];
78 void* m_handle
= nullptr;
80 void verify_config(const struct md_config_t
*conf
);
83 #endif // CEPH_TRACEPOINT_PROVIDER_H