MCPcopy Create free account
hub / github.com/apache/trafficserver / BaseMetrics

Class BaseMetrics

include/cripts/Metrics.hpp:35–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33using MetricID = ts::Metrics::IdType;
34
35class BaseMetrics
36{
37 using self_type = detail::BaseMetrics;
38
39public:
40 BaseMetrics() = delete;
41 BaseMetrics(const self_type &) = delete;
42 void operator=(const self_type &) = delete;
43 virtual ~BaseMetrics() = default;
44
45 BaseMetrics(const cripts::string_view &name) : _name(name) {}
46
47 void
48 operator=(int64_t val)
49 {
50 CAssert(_id != TS_ERROR);
51 _metric->store(val);
52 }
53
54 operator int64_t() const
55 {
56 CAssert(_id != TS_ERROR);
57 return _metric->load();
58 }
59
60 [[nodiscard]] cripts::string_view
61 Name() const
62 {
63 return {_name};
64 }
65
66 [[nodiscard]] detail::MetricID
67 Id() const
68 {
69 return _id;
70 }
71
72 void
73 Increment(int64_t inc) const
74 {
75 CAssert(_id != ts::Metrics::NOT_FOUND);
76 _metric->increment(inc);
77 }
78
79 void
80 Increment() const
81 {
82 Increment(1);
83 }
84
85 void
86 Decrement(int64_t dec) const
87 {
88 CAssert(_id != ts::Metrics::NOT_FOUND);
89 _metric->decrement(dec);
90 }
91
92 void

Callers

nothing calls this directly

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected