Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit fee7dc5

Browse files
committed
Metrics: Allow setting custom key-values on all metrics data
1 parent a7417a0 commit fee7dc5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class CacheServer {
3838

3939
this.statsd = new StatsDClient({
4040
prefix: 'cache-server',
41+
tags: opts.statsdTags,
4142
host: opts.statsdServer ? opts.statsdServer : '127.0.0.1'
4243
});
4344
}

main.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ function atLeastOne(val) {
1616
return Math.max(1, val);
1717
}
1818

19+
function parseKeyValues(val) {
20+
let obj = {};
21+
val.split(',').forEach(function (kv) {
22+
let pair = kv.split(':');
23+
obj[pair[0]] = pair[1];
24+
});
25+
return obj;
26+
}
27+
1928
program.description("Unity Cache Server")
2029
.version(consts.VERSION)
2130
.option('-s, --size <n>', 'Specify the maximum allowed size of the LRU cache. Files that have not been used recently will automatically be discarded when the cache size is exceeded. Default is 50Gb', myParseInt, consts.DEFAULT_CACHE_SIZE)
@@ -25,7 +34,8 @@ program.description("Unity Cache Server")
2534
.option('-w, --workers <n>', 'Number of worker threads to spawn. Default is 1 for every 2 CPUs reported by the OS', atLeastOne, consts.DEFAULT_WORKERS)
2635
.option('-v, --verify', 'Verify the Cache Server integrity, without fixing errors')
2736
.option('-f, --fix', 'Fix errors found while verifying the Cache Server integrity')
28-
.option('--statsd-server [host]', 'Send statsd-metrics to this host')
37+
.option('--statsd-server [host]', 'Send statsd metrics to this host')
38+
.option('--statsd-tags [key:val,...]', 'Extra tags for statsd metrics', parseKeyValues)
2939
.option('-m, --monitor-parent-process <n>', 'Monitor a parent process and exit if it dies', myParseInt, 0)
3040
.parse(process.argv);
3141

@@ -79,6 +89,7 @@ var errHandler = function () {
7989

8090
var server = new CacheServer(cache, {
8191
port: program.port,
92+
statsdTags: program.statsdTags,
8293
statsdServer: program.statsdServer
8394
});
8495

0 commit comments

Comments
 (0)