Change CCMetric's internal data structure (#22)

* package ccmetric rewrite

* Create deep copy in New() to avoid access conflicts

* Renamed TagMap() -> Tags(), MetaMap() -> Meta

Co-authored-by: Holger Obermaier <40787752+ho-ob@users.noreply.github.com>
This commit is contained in:
Thomas Gruber
2022-02-01 14:54:34 +01:00
committed by GitHub
parent 862630a218
commit 6ff6cb7219
4 changed files with 92 additions and 158 deletions

View File

@@ -30,16 +30,16 @@ func (s *GangliaSink) Write(point lp.CCMetric) error {
var err error = nil
var tagsstr []string
var argstr []string
for _, t := range point.TagList() {
switch t.Key {
for key, value := range point.Tags() {
switch key {
case "cluster":
argstr = append(argstr, fmt.Sprintf("--cluster=%s", t.Value))
argstr = append(argstr, fmt.Sprintf("--cluster=%s", value))
case "unit":
argstr = append(argstr, fmt.Sprintf("--units=%s", t.Value))
argstr = append(argstr, fmt.Sprintf("--units=%s", value))
case "group":
argstr = append(argstr, fmt.Sprintf("--group=%s", t.Value))
argstr = append(argstr, fmt.Sprintf("--group=%s", value))
default:
tagsstr = append(tagsstr, fmt.Sprintf("%s=%s", t.Key, t.Value))
tagsstr = append(tagsstr, fmt.Sprintf("%s=%s", key, value))
}
}
if len(tagsstr) > 0 {