Skip to content

Commit

Permalink
Merge pull request #6 from srikar-jilugu/counterbugfix
Browse files Browse the repository at this point in the history
fix bug in reportCount
  • Loading branch information
syntaqx committed Jul 9, 2024
2 parents 2095153 + b328886 commit be267c8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ func (r *Reporter) Flush() {
// data submission variations.
func (r *Reporter) FlushOnce() error {
reportCount := func(name string, tags []string, value int64) {
last := r.ss[name]
metric := getFullMetricName(name, tags)
last := r.ss[metric]
r.Client.Count(name, value-last, tags, 1)
r.ss[name] = value
r.ss[metric] = value
}
r.Registry.Each(func(metricName string, i interface{}) {
name, tags := r.splitNameAndTags(metricName)
Expand Down Expand Up @@ -174,3 +175,7 @@ func (r *Reporter) splitNameAndTags(metric string) (string, []string) {
}
return metric, r.tags
}

func getFullMetricName(name string, tags []string) string {
return fmt.Sprintf("%s[%s]", name, strings.Join(tags, ","))
}

0 comments on commit be267c8

Please sign in to comment.