quill
Metric.h
1 
7 #pragma once
8 
9 #include "quill/core/Common.h"
10 #include "quill/core/MacroMetadata.h"
11 
12 #include <string>
13 #include <vector>
14 
15 QUILL_BEGIN_NAMESPACE
16 
17 QUILL_BEGIN_EXPORT
18 
20 {
21  MetricLabel() = default;
22  MetricLabel(std::string k, std::string v) : key(std::move(k)), value(std::move(v)) {}
23 
24  std::string key;
25  std::string value;
26 };
27 
35 class MetricMetadata final : public MacroMetadata
36 {
37 public:
38  MetricMetadata(std::string metric_key, std::string metric_name, std::vector<MetricLabel> labels = {})
39  : MacroMetadata("", "", "", nullptr, LogLevel::None, MacroMetadata::Event::Metric),
40  _metric_key(std::move(metric_key)),
41  _metric_name(std::move(metric_name)),
42  _labels(std::move(labels))
43  {
44  }
45 
46  QUILL_NODISCARD std::string const& metric_key() const noexcept { return _metric_key; }
47 
48  QUILL_NODISCARD std::string const& metric_name() const noexcept { return _metric_name; }
49 
50  QUILL_NODISCARD std::vector<MetricLabel> const& labels() const noexcept { return _labels; }
51 
52 private:
53  std::string _metric_key;
54  std::string _metric_name;
55  std::vector<MetricLabel> _labels;
56 };
57 
58 QUILL_END_EXPORT
59 
60 QUILL_END_NAMESPACE
Captures and stores information about a logging event in compile time.
Definition: MacroMetadata.h:24
MetricMetadata extends MacroMetadata so the existing header-encoding path can carry it in the macro_m...
Definition: Metric.h:35
Definition: Metric.h:19