зеркало из https://github.com/microsoft/statsd.git
Metric name sanitization moved to graphite backend. it is now the responsibility of each backend developer to take care for sanitization
This commit is contained in:
Родитель
55281abc0c
Коммит
0eb2517b04
|
@ -33,7 +33,6 @@ var prefixGauge;
|
|||
var prefixSet;
|
||||
var globalSuffix;
|
||||
var prefixStats;
|
||||
var globalKeySanitize = true;
|
||||
|
||||
// set up namespaces
|
||||
var legacyNamespace = true;
|
||||
|
@ -100,13 +99,9 @@ var flush_stats = function graphite_flush(ts, metrics) {
|
|||
|
||||
// Sanitize key for graphite if not done globally
|
||||
function sk(key) {
|
||||
if (globalKeySanitize) {
|
||||
return key;
|
||||
} else {
|
||||
return key.replace(/\s+/g, '_')
|
||||
.replace(/\//g, '-')
|
||||
.replace(/[^a-zA-Z_\-0-9\.]/g, '');
|
||||
}
|
||||
};
|
||||
|
||||
for (key in counters) {
|
||||
|
@ -253,10 +248,6 @@ exports.init = function graphite_init(startup_time, config, events, logger) {
|
|||
graphiteStats.flush_time = 0;
|
||||
graphiteStats.flush_length = 0;
|
||||
|
||||
if (config.keyNameSanitize !== undefined) {
|
||||
globalKeySanitize = config.keyNameSanitize;
|
||||
}
|
||||
|
||||
flushInterval = config.flushInterval;
|
||||
|
||||
flush_counts = typeof(config.flush_counts) === "undefined" ? true : config.flush_counts;
|
||||
|
|
|
@ -53,9 +53,6 @@ Optional Variables:
|
|||
deleteCounters: don't send values to graphite for inactive counters, as opposed to sending 0 [default: false]
|
||||
prefixStats: prefix to use for the statsd statistics data for this running instance of statsd [default: statsd]
|
||||
applies to both legacy and new namespacing
|
||||
keyNameSanitize: sanitize all stat names on ingress [default: true]
|
||||
If disabled, it is up to the backends to sanitize keynames
|
||||
as appropriate per their storage requirements.
|
||||
|
||||
console:
|
||||
prettyprint: whether to prettyprint the console backend
|
||||
|
|
16
stats.js
16
stats.js
|
@ -29,7 +29,6 @@ var backendEvents = new events.EventEmitter();
|
|||
var healthStatus = config.healthStatus || 'up';
|
||||
var old_timestamp = 0;
|
||||
var timestamp_lag_namespace;
|
||||
var keyNameSanitize = true;
|
||||
|
||||
// Load and init the backend from the backends/ directory.
|
||||
function loadBackend(config, name) {
|
||||
|
@ -159,16 +158,6 @@ var stats = {
|
|||
}
|
||||
};
|
||||
|
||||
function sanitizeKeyName(key) {
|
||||
if (keyNameSanitize) {
|
||||
return key.replace(/\s+/g, '_')
|
||||
.replace(/\//g, '-')
|
||||
.replace(/[^a-zA-Z_\-0-9\.]/g, '');
|
||||
} else {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
// Global for the logger
|
||||
var l;
|
||||
|
||||
|
@ -191,9 +180,6 @@ config.configFile(process.argv[2], function (config) {
|
|||
counters[bad_lines_seen] = 0;
|
||||
counters[packets_received] = 0;
|
||||
|
||||
if (config.keyNameSanitize !== undefined) {
|
||||
keyNameSanitize = config.keyNameSanitize;
|
||||
}
|
||||
if (!serverLoaded) {
|
||||
// key counting
|
||||
var keyFlushInterval = Number((config.keyFlush && config.keyFlush.interval) || 0);
|
||||
|
@ -218,7 +204,7 @@ config.configFile(process.argv[2], function (config) {
|
|||
l.log(metrics[midx].toString());
|
||||
}
|
||||
var bits = metrics[midx].toString().split(':');
|
||||
var key = sanitizeKeyName(bits.shift());
|
||||
var key = bits.shift();
|
||||
|
||||
if (keyFlushInterval > 0) {
|
||||
if (! keyCounter[key]) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче