27 #include <string_view> 42 static constexpr
char matchEscapeChar =
'\\';
43 static constexpr
char matchSubstitutionPrefix =
'$';
44 static constexpr std::string_view matchSubstitutionPathPrefix =
"path_"sv;
50 std::map<std::string, std::string>
tags_;
71 const
std::vector<
std::
string>& name() const noexcept;
76 const
std::
string& value() const noexcept;
81 const
std::
string& unit() const noexcept;
86 const
std::map<
std::
string,
std::
string>& tags() const noexcept;
91 bool computeRate() const noexcept;
96 bool convertToUnitsPerSecond() const noexcept;
102 void setName(const
std::vector<
std::
string>& name) noexcept;
107 void setValue(const
std::
string& value) noexcept;
112 void setUnit(const
std::
string& unit) noexcept;
117 void setTags(const
std::map<
std::
string,
std::
string>& tags) noexcept;
122 void setComputeRate(
bool computeRate) noexcept;
127 void setConvertToUnitsPerSecond(
bool convertToUnitsPerSecond) noexcept;
137 std::optional<
std::vector<
std::
string>> getName(const
std::cmatch& match, const
std::vector<
std::
string>& pathParts) const noexcept;
146 std::optional<
double>
getValue(const
std::cmatch& match, const
std::vector<
std::
string>& pathParts) const noexcept;
155 std::optional<
std::
string> getUnit(const
std::cmatch& match, const
std::vector<
std::
string>& pathParts) const noexcept;
164 std::optional<
std::map<
std::
string,
std::
string>> getTags(const
std::cmatch& match, const
std::vector<
std::
string>& pathParts) const noexcept;
173 std::optional<
Metric> getMetric(const
std::cmatch& match, const
std::vector<
std::
string>& pathParts) const noexcept;
std::map< std::string, std::string > tags_
Pattern for the tags of the metric.
std::string value_
Pattern for the value of the metric.
std::string unit_
Pattern for the unit of the metric.
bool computeRate_
Whether the metric is a rate.
bool convertToUnitsPerSecond_
Whether the metric should be converted to units per second.
Struct used to represent the JSON configuration file.
Class used to represent a matcher, that is a way to convert expressions matches into a metric...
std::vector< std::string > name_
Pattern for the name of the metric.
Class used to represent a metric object (with a name, unit, tags, a value and a timestamp) ...
T getValue(const nlohmann::json &j, const K &key) noexcept
Parse a JSON value of specified type from a JSON dictionary.