Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions statsd/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ func (a *aggregator) pullMetric() {
case m := <-a.inputMetrics:
switch m.metricType {
case histogram:
a.histogram(m.name, m.fvalue, m.tags, m.rate, m.overrideCard)
a.histogram(m.name, m.fvalue, m.tags, m.rate, m.cardinality)
case distribution:
a.distribution(m.name, m.fvalue, m.tags, m.rate, m.overrideCard)
a.distribution(m.name, m.fvalue, m.tags, m.rate, m.cardinality)
case timing:
a.timing(m.name, m.fvalue, m.tags, m.rate, m.overrideCard)
a.timing(m.name, m.fvalue, m.tags, m.rate, m.cardinality)
}
case <-a.stopChannelMode:
a.wg.Done()
Expand Down Expand Up @@ -191,7 +191,7 @@ func getContextAndTags(name string, tags []string, cardinality Cardinality) (str
if cardString == "" {
return name, ""
}
return name + nameSeparatorSymbol + cardinality.String(), ""
return name + nameSeparatorSymbol + cardString, ""
}

n := len(name) + len(nameSeparatorSymbol) + len(tagSeparatorSymbol)*(len(tags)-1)
Expand Down Expand Up @@ -224,8 +224,7 @@ func getContextAndTags(name string, tags []string, cardinality Cardinality) (str
}

func (a *aggregator) count(name string, value int64, tags []string, cardinality Cardinality) error {
resolvedCardinality := resolveCardinality(cardinality)
context := getContext(name, tags, resolvedCardinality)
context := getContext(name, tags, cardinality)
a.countsM.RLock()
if count, found := a.counts[context]; found {
count.sample(value)
Expand All @@ -234,10 +233,10 @@ func (a *aggregator) count(name string, value int64, tags []string, cardinality
}
a.countsM.RUnlock()

metric := newCountMetric(name, value, tags, resolvedCardinality)
metric := newCountMetric(name, value, tags, cardinality)

a.countsM.Lock()
// Check if another goroutines hasn't created the value betwen the RUnlock and 'Lock'
// Check if another goroutines hasn't created the value between the RUnlock and 'Lock'
if count, found := a.counts[context]; found {
count.sample(value)
a.countsM.Unlock()
Expand All @@ -250,8 +249,7 @@ func (a *aggregator) count(name string, value int64, tags []string, cardinality
}

func (a *aggregator) gauge(name string, value float64, tags []string, cardinality Cardinality) error {
resolvedCardinality := resolveCardinality(cardinality)
context := getContext(name, tags, resolvedCardinality)
context := getContext(name, tags, cardinality)
a.gaugesM.RLock()
if gauge, found := a.gauges[context]; found {
gauge.sample(value)
Expand All @@ -260,7 +258,7 @@ func (a *aggregator) gauge(name string, value float64, tags []string, cardinalit
}
a.gaugesM.RUnlock()

gauge := newGaugeMetric(name, value, tags, resolvedCardinality)
gauge := newGaugeMetric(name, value, tags, cardinality)

a.gaugesM.Lock()
// Check if another goroutines hasn't created the value betwen the 'RUnlock' and 'Lock'
Expand All @@ -275,8 +273,7 @@ func (a *aggregator) gauge(name string, value float64, tags []string, cardinalit
}

func (a *aggregator) set(name string, value string, tags []string, cardinality Cardinality) error {
resolvedCardinality := resolveCardinality(cardinality)
context := getContext(name, tags, resolvedCardinality)
context := getContext(name, tags, cardinality)
a.setsM.RLock()
if set, found := a.sets[context]; found {
set.sample(value)
Expand All @@ -285,7 +282,7 @@ func (a *aggregator) set(name string, value string, tags []string, cardinality C
}
a.setsM.RUnlock()

metric := newSetMetric(name, value, tags, resolvedCardinality)
metric := newSetMetric(name, value, tags, cardinality)

a.setsM.Lock()
// Check if another goroutines hasn't created the value betwen the 'RUnlock' and 'Lock'
Expand Down
Loading
Loading