diff --git a/api/wasm/cpp/proxy_wasm_impl.h b/api/wasm/cpp/proxy_wasm_impl.h index 35aa43d139a9..3dbd835e385d 100644 --- a/api/wasm/cpp/proxy_wasm_impl.h +++ b/api/wasm/cpp/proxy_wasm_impl.h @@ -998,7 +998,9 @@ struct MetricTag { struct MetricBase { MetricBase(MetricType t, const std::string& n) : type(t), name(n) {} MetricBase(MetricType t, const std::string& n, std::vector ts) - : type(t), name(n), tags(ts.begin(), ts.end()) {} + : type(t), name(n), tags(ts.begin(), ts.end()){} + MetricBase(MetricType t, const std::string& n, std::vector ts, std::string fs, std::string vs) + : type(t), name(n), tags(ts.begin(), ts.end()), field_separator(fs), value_separator(vs) {} MetricType type; std::string name; @@ -1006,6 +1008,9 @@ struct MetricBase { std::vector tags; std::unordered_map metric_ids; + std::string field_separator = "."; // used to separate two fields. + std::string value_separator = "."; // used to separate a field from its value. + std::string prefixWithFields(const std::vector& fields); uint32_t resolveFullName(const std::string& n); uint32_t resolveWithFields(const std::vector& fields); @@ -1016,6 +1021,7 @@ struct MetricBase { struct Metric : public MetricBase { Metric(MetricType t, const std::string& n) : MetricBase(t, n) {} Metric(MetricType t, const std::string& n, std::vector ts) : MetricBase(t, n, ts) {} + Metric(MetricType t, const std::string& n, std::vector ts, std::string field_separator, std::string value_separator) : MetricBase(t, n, ts, field_separator, value_separator) {} template void increment(int64_t offset, Fields... tags); template void record(uint64_t value, Fields... tags); @@ -1037,9 +1043,9 @@ inline std::string MetricBase::prefixWithFields(const std::vector& n.append(prefix); for (size_t i = 0; i < fields.size(); i++) { n.append(tags[i].name); - n.append("."); + n.append(value_separator); n.append(fields[i]); - n.append("."); + n.append(field_separator); } return n; }