This repository was archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 126
Msiebuhr/add statsd to stream refactor #15
Closed
msiebuhr
wants to merge
3
commits into
Unity-Technologies:feature/streams-refactor
from
tactileentertainment:msiebuhr/add-statsd-to-stream-refactor
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ const prompt = require('prompt'); | |
| const dns = require('dns'); | ||
| const ip = require('ip'); | ||
| const VERSION = require('./package.json').version; | ||
| const StatsDClient = require('statsd-client'); | ||
|
|
||
| function myParseInt(val, def) { | ||
| val = parseInt(val); | ||
|
|
@@ -25,6 +26,16 @@ function collect(val, memo) { | |
| return memo; | ||
| } | ||
|
|
||
|
|
||
| function parseKeyValues(val) { | ||
| let obj = {}; | ||
| val.split(',').forEach(function (kv) { | ||
| let pair = kv.split(':'); | ||
| obj[pair[0]] = pair[1]; | ||
| }); | ||
| return obj; | ||
| } | ||
|
|
||
| const defaultCacheModule = config.get("Cache.defaultModule"); | ||
|
|
||
| program.description("Unity Cache Server") | ||
|
|
@@ -34,6 +45,8 @@ program.description("Unity Cache Server") | |
| .option('-P, --cache-path [path]', `Specify the path of the cache directory`) | ||
| .option('-l, --log-level <n>', `Specify the level of log verbosity. Valid values are 0 (silent) through 5 (debug). Default is ${consts.DEFAULT_LOG_LEVEL}`, myParseInt, consts.DEFAULT_LOG_LEVEL) | ||
| .option('-w, --workers <n>', `Number of worker threads to spawn. Default is ${consts.DEFAULT_WORKERS}`, zeroOrMore, consts.DEFAULT_WORKERS) | ||
| .option('--statsd-server [host]', 'Send statsd metrics to this host', '127.0.0.1') | ||
| .option('--statsd-tags [key:val,...]', 'Extra tags for statsd metrics', parseKeyValues) | ||
| .option('-m --mirror [host:port]', `Mirror transactions to another cache server. Can be repeated for multiple mirrors`, collect, []) | ||
| .option('-m, --monitor-parent-process <n>', 'Monitor a parent process and exit if it dies', myParseInt, 0); | ||
|
|
||
|
|
@@ -42,6 +55,12 @@ program.parse(process.argv); | |
| helpers.setLogLevel(program.logLevel); | ||
| helpers.setLogger(program.workers > 0 ? helpers.defaultClusterLogger : helpers.defaultLogger); | ||
|
|
||
| const statsd = new StatsDClient({ | ||
| prefix: 'cache-server', | ||
| host: program.statsdHost, | ||
| tags: program.statsdTags | ||
| }); | ||
|
|
||
| if (program.monitorParentProcess > 0) { | ||
| function monitor() { | ||
| function is_running(pid) { | ||
|
|
@@ -78,7 +97,9 @@ if(program.workers > 0 && !CacheModule.properties.clustering) { | |
|
|
||
| let server = null; | ||
|
|
||
| let cacheOpts = {}; | ||
| let cacheOpts = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why pass the statsd object to the cache init() if it isn't used in the cache module? |
||
| statsd: statsd | ||
| }; | ||
| if(program.cachePath !== null) { | ||
| cacheOpts.cachePath = program.cachePath; | ||
| } | ||
|
|
@@ -158,6 +179,7 @@ function startPrompt() { | |
| switch(result.command) { | ||
| case 'q': | ||
| helpers.log(consts.LOG_INFO, "Shutting down ..."); | ||
| this.statsd.close(); | ||
| Cache.shutdown().then(() => { | ||
| server.stop(); | ||
| process.exit(0); | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,7 @@ | |
| "lodash": "^4.17.4", | ||
| "lokijs": "^1.5.1", | ||
| "prompt": "^1.0.0", | ||
| "statsd-client": "^0.4.0", | ||
| "uuid": "^3.1.0" | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved after the 'await' on endPutTransaction below.