1
#pragma once
2

            
3
#include "envoy/stats/tag.h"
4

            
5
#include "source/common/stats/symbol_table.h"
6

            
7
namespace Envoy {
8
namespace Stats {
9
namespace TagUtility {
10

            
11
/**
12
 * Combines a stat name with an optional set of tag to create the final stat name to use. The
13
 * resulting StatNames will be valid through the lifetime of this object and all provided stat
14
 * names.
15
 */
16
class TagStatNameJoiner {
17
public:
18
  /**
19
   * Combines a prefix, stat name and tags into a single stat name.
20
   * @param prefix StaName the stat prefix to use.
21
   * @param name StaName the stat name to use.
22
   * @param stat_name_tags optionally StatNameTagVector the stat name tags to add to the stat name.
23
   */
24
  TagStatNameJoiner(StatName prefix, StatName stat_name,
25
                    StatNameTagVectorOptConstRef stat_name_tags, SymbolTable& symbol_table);
26

            
27
  /**
28
   * @return StatName the full stat name, including the tag suffix.
29
   */
30
87022601
  StatName nameWithTags() const { return name_with_tags_; }
31

            
32
  /**
33
   * @return StatName the stat name without the tags appended.
34
   */
35
33037326
  StatName tagExtractedName() const { return tag_extracted_name_; }
36

            
37
private:
38
  // TODO(snowp): This isn't really "tag extracted", but we'll use this for the sake of consistency
39
  // until we can change the naming convention throughout.
40
  StatName tag_extracted_name_;
41
  SymbolTable::StoragePtr prefix_storage_;
42
  SymbolTable::StoragePtr full_name_storage_;
43
  StatName name_with_tags_;
44

            
45
  SymbolTable::StoragePtr joinNameAndTags(StatName name, const StatNameTagVector& stat_name_tags,
46
                                          SymbolTable& symbol_table);
47
};
48

            
49
bool isTagNameValid(absl::string_view name);
50

            
51
bool isTagValueValid(absl::string_view value);
52

            
53
} // namespace TagUtility
54
} // namespace Stats
55
} // namespace Envoy