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 "common/config_obs.h"
8 #include "common/Mutex.h"
13 class TracepointProvider : public md_config_obs_t, boost::noncopyable {
17 const char *config_key;
19 Traits(const char *library, const char *config_key)
20 : library(library), config_key(config_key) {
26 Singleton(CephContext *cct, const char *library, const char *config_key)
27 : tracepoint_provider(new TracepointProvider(cct, library, config_key)) {
30 delete tracepoint_provider;
33 inline bool is_enabled() const {
34 return tracepoint_provider->m_handle != nullptr;
37 TracepointProvider *tracepoint_provider;
40 template <const Traits &traits>
41 class TypedSingleton : public Singleton {
43 explicit TypedSingleton(CephContext *cct)
44 : Singleton(cct, traits.library, traits.config_key) {
48 TracepointProvider(CephContext *cct, const char *library,
49 const char *config_key);
50 ~TracepointProvider() override;
52 template <const Traits &traits>
53 static void initialize(CephContext *cct) {
55 TypedSingleton<traits> *singleton;
56 cct->lookup_or_create_singleton_object(singleton, traits.library);
61 const char** get_tracked_conf_keys() const override {
64 void handle_conf_change(const struct md_config_t *conf,
65 const std::set <std::string> &changed) override;
69 std::string m_library;
70 mutable const char* m_config_keys[2];
73 void* m_handle = nullptr;
75 void verify_config(const struct md_config_t *conf);
78 #endif // CEPH_TRACEPOINT_PROVIDER_H