};
+/* Class for constructing a PerfCounters object.
+ *
+ * This class performs some validation that the parameters we have supplied are
+ * correct in create_perf_counters().
+ *
+ * In the future, we will probably get rid of the first/last arguments, since
+ * PerfCountersBuilder can deduce them itself.
+ */
+class PerfCountersBuilder
+{
+public:
+ PerfCountersBuilder(CephContext *cct, const std::string &name,
+ int first, int last);
+ ~PerfCountersBuilder();
+
+ // prio values: higher is better, and higher values get included in
+ // 'ceph daemonperf' (and similar) results.
+ // Use of priorities enables us to add large numbers of counters
+ // internally without necessarily overwhelming consumers.
+ enum {
+ PRIO_CRITICAL = 10,
+ // 'interesting' is the default threshold for `daemonperf` output
+ PRIO_INTERESTING = 8,
+ // `useful` is the default threshold for transmission to ceph-mgr
+ // and inclusion in prometheus/influxdb plugin output
+ PRIO_USEFUL = 5,
+ PRIO_UNINTERESTING = 2,
+ PRIO_DEBUGONLY = 0,
+ };
+ void add_u64(int key, const char *name,
+ const char *description=NULL, const char *nick = NULL,
+ int prio=0);
+ void add_u64_counter(int key, const char *name,
+ const char *description=NULL,
+ const char *nick = NULL,
+ int prio=0);
+ void add_u64_avg(int key, const char *name,
+ const char *description=NULL,
+ const char *nick = NULL,
+ int prio=0);
+ void add_time(int key, const char *name,
+ const char *description=NULL,
+ const char *nick = NULL,
+ int prio=0);
+ void add_time_avg(int key, const char *name,
+ const char *description=NULL,
+ const char *nick = NULL,
+ int prio=0);
+ void add_u64_counter_histogram(
+ int key, const char* name,
+ PerfHistogramCommon::axis_config_d x_axis_config,
+ PerfHistogramCommon::axis_config_d y_axis_config,
+ const char *description=NULL,
+ const char* nick = NULL,
+ int prio=0);
+
+ void set_prio_default(int prio_)
+ {
+ prio_default = prio_;
+ }
+
+ PerfCounters* create_perf_counters();
+private:
+ PerfCountersBuilder(const PerfCountersBuilder &rhs);
+ PerfCountersBuilder& operator=(const PerfCountersBuilder &rhs);
+ void add_impl(int idx, const char *name,
+ const char *description, const char *nick, int prio, int ty,
+ unique_ptr<PerfHistogram<>> histogram = nullptr);
+
+ PerfCounters *m_perf_counters;
+
+ int prio_default = 0;
+};
+
/*
* A PerfCounters object is usually associated with a single subsystem.
* It contains counters which we modify to track performance and throughput
const char *name;
const char *description;
const char *nick;
- int prio = 0;
+ uint8_t prio = 0;
enum perfcounter_type_d type;
std::atomic<uint64_t> u64 = { 0 };
std::atomic<uint64_t> avgcount = { 0 };
prio_adjust = p;
}
+ int get_adjusted_priority(int p) const {
+ return std::max(std::min(p + prio_adjust,
+ (int)PerfCountersBuilder::PRIO_CRITICAL),
+ 0);
+ }
+
private:
PerfCounters(CephContext *cct, const std::string &name,
int lower_bound, int upper_bound);
dump_formatted_generic(f, schema, true, logger, counter);
}
+ // A reference to a perf_counter_data_any_d, with an accompanying
+ // pointer to the enclosing PerfCounters, in order that the consumer
+ // can see the prio_adjust
+ class PerfCounterRef
+ {
+ public:
+ PerfCounters::perf_counter_data_any_d *data;
+ PerfCounters *perf_counters;
+ };
typedef std::map<std::string,
- PerfCounters::perf_counter_data_any_d *> CounterMap;
+ PerfCounterRef> CounterMap;
void with_counters(std::function<void(const CounterMap &)>) const;
perf_counters_set_t m_loggers;
- std::map<std::string, PerfCounters::perf_counter_data_any_d *> by_path;
+ CounterMap by_path;
friend class PerfCountersCollectionTest;
};
-/* Class for constructing a PerfCounters object.
- *
- * This class performs some validation that the parameters we have supplied are
- * correct in create_perf_counters().
- *
- * In the future, we will probably get rid of the first/last arguments, since
- * PerfCountersBuilder can deduce them itself.
- */
-class PerfCountersBuilder
-{
-public:
- PerfCountersBuilder(CephContext *cct, const std::string &name,
- int first, int last);
- ~PerfCountersBuilder();
-
- // prio values: higher is better, and higher values get included in
- // 'ceph daemonperf' (and similar) results.
- enum {
- PRIO_CRITICAL = 10,
- PRIO_INTERESTING = 8,
- PRIO_USEFUL = 5,
- PRIO_UNINTERESTING = 2,
- PRIO_DEBUGONLY = 0,
- };
- void add_u64(int key, const char *name,
- const char *description=NULL, const char *nick = NULL,
- int prio=0);
- void add_u64_counter(int key, const char *name,
- const char *description=NULL,
- const char *nick = NULL,
- int prio=0);
- void add_u64_avg(int key, const char *name,
- const char *description=NULL,
- const char *nick = NULL,
- int prio=0);
- void add_time(int key, const char *name,
- const char *description=NULL,
- const char *nick = NULL,
- int prio=0);
- void add_time_avg(int key, const char *name,
- const char *description=NULL,
- const char *nick = NULL,
- int prio=0);
- void add_u64_counter_histogram(
- int key, const char* name,
- PerfHistogramCommon::axis_config_d x_axis_config,
- PerfHistogramCommon::axis_config_d y_axis_config,
- const char *description=NULL,
- const char* nick = NULL,
- int prio=0);
-
- PerfCounters* create_perf_counters();
-private:
- PerfCountersBuilder(const PerfCountersBuilder &rhs);
- PerfCountersBuilder& operator=(const PerfCountersBuilder &rhs);
- void add_impl(int idx, const char *name,
- const char *description, const char *nick, int prio, int ty,
- unique_ptr<PerfHistogram<>> histogram = nullptr);
- PerfCounters *m_perf_counters;
-};
#endif