Line data Source code
1 : #pragma once 2 : 3 : #include <memory> 4 : #include <string> 5 : #include <vector> 6 : 7 : #include "envoy/common/pure.h" 8 : #include "envoy/stats/tag.h" 9 : 10 : #include "absl/strings/string_view.h" 11 : 12 : namespace Envoy { 13 : namespace Stats { 14 : 15 : class TagProducer { 16 : public: 17 346 : virtual ~TagProducer() = default; 18 : 19 : /** 20 : * Take a metric name and a vector then add proper tags into the vector and 21 : * return an extracted metric name. The tags array will be populated with 22 : * name/value pairs extracted from the full metric name, using the regular 23 : * expressions in source/common/config/well_known_names.cc. For example, the 24 : * stat name "vhost.foo.vcluster.bar.c1" would have "foo" extracted as the 25 : * value of tag "vhost" and "bar" extracted as the value of tag 26 : * "vcluster", so this will populate tags with {"vhost", "foo"} and 27 : * {"vcluster", "bar"}, and return "vhost.vcluster.c1". 28 : * 29 : * @param metric_name std::string a name of Stats::Metric (Counter, Gauge, Histogram). 30 : * @param tags TagVector a set of Stats::Tag. 31 : */ 32 : virtual std::string produceTags(absl::string_view metric_name, TagVector& tags) const PURE; 33 : 34 : virtual const TagVector& fixedTags() const PURE; 35 : }; 36 : 37 : using TagProducerPtr = std::unique_ptr<const TagProducer>; 38 : 39 : } // namespace Stats 40 : } // namespace Envoy