handlebars_helpers.js (nsq-1.2.0) | : | handlebars_helpers.js (nsq-1.2.1) | ||
---|---|---|---|---|
skipping to change at line 64 | skipping to change at line 64 | |||
return 'red'; | return 'red'; | |||
} | } | |||
} else if (typ === 'node') { | } else if (typ === 'node') { | |||
return 'red,green,blue,purple'; | return 'red,green,blue,purple'; | |||
} else if (typ === 'counter') { | } else if (typ === 'counter') { | |||
return 'green'; | return 'green'; | |||
} | } | |||
return 'blue'; | return 'blue'; | |||
}; | }; | |||
// sanitizeGraphiteKey removes special characters from a graphite key | ||||
// this matches behavior of bitly/statsdaemon | ||||
// https://github.com/bitly/statsdaemon/blob/fc46d9cfe29b674a0c8abc723afaa937043 | ||||
0cdcd/statsdaemon.go#L64-L88 | ||||
var sanitizeGraphiteKey = function(s) { | ||||
return s.replaceAll(' ', '_').replaceAll('/', '-').replaceAll(/[^a-zA-Z0-9-_ | ||||
.]/g, ''); | ||||
} | ||||
var genTargets = function(typ, node, ns1, ns2, key) { | var genTargets = function(typ, node, ns1, ns2, key) { | |||
var targets = []; | var targets = []; | |||
var prefix = statsdPrefix(node ? node : '*'); | var prefix = statsdPrefix(node ? node : '*'); | |||
var fullKey; | var fullKey; | |||
var target; | var target; | |||
if (typ === 'topic') { | if (typ === 'topic') { | |||
fullKey = formatStatsdKey(metricType(key), prefix + 'topic.' + ns1 + '.' + key); | fullKey = formatStatsdKey(metricType(key), prefix + 'topic.' + sanitizeG raphiteKey(ns1) + '.' + key); | |||
targets.push('sumSeries(' + fullKey + ')'); | targets.push('sumSeries(' + fullKey + ')'); | |||
} else if (typ === 'channel') { | } else if (typ === 'channel') { | |||
fullKey = formatStatsdKey(metricType(key), prefix + 'topic.' + ns1 + '.c | fullKey = formatStatsdKey(metricType(key), prefix + 'topic.' + sanitizeG | |||
hannel.' + | raphiteKey(ns1) + '.channel.' + | |||
ns2 + '.' + key); | sanitizeGraphiteKey(ns2) + '.' + key); | |||
targets.push('sumSeries(' + fullKey + ')'); | targets.push('sumSeries(' + fullKey + ')'); | |||
} else if (typ === 'node') { | } else if (typ === 'node') { | |||
target = prefix + 'mem.' + key; | target = prefix + 'mem.' + key; | |||
if (key === 'gc_runs') { | if (key === 'gc_runs') { | |||
target = 'movingAverage(' + target + ',45)'; | target = 'movingAverage(' + target + ',45)'; | |||
} | } | |||
targets.push(formatStatsdKey(metricType(key), target)); | targets.push(formatStatsdKey(metricType(key), target)); | |||
} else if (typ === 'e2e') { | } else if (typ === 'e2e') { | |||
targets = _.map(ns1['percentiles'], function(p) { | targets = _.map(ns1['percentiles'], function(p) { | |||
var t; | var t; | |||
End of changes. 3 change blocks. | ||||
4 lines changed or deleted | 13 lines changed or added |