Go proc metrics collector#55
Conversation
via the in-built expvar mechanism.
| from __future__ import print_function | ||
| import traceback | ||
|
|
||
| import requests |
There was a problem hiding this comment.
Will this require a dependency on python-requests.deb/rpm?
There was a problem hiding this comment.
As discussed, it's already part of the installer dependencies.
| from collectors.lib import utils | ||
|
|
||
| COLLECTION_INTERVAL_SECONDS = 15 | ||
| SKIP_MEM_KEYS = ['PauseNs', 'PauseEnd', 'BySize'] |
There was a problem hiding this comment.
The collector decides what metrics it will emit, this should not be user configurable.
| @@ -0,0 +1,64 @@ | |||
| #!/usr/bin/env python | |||
|
|
|||
| from __future__ import print_function | |||
There was a problem hiding this comment.
How come other collectors did not have this?
|
|
||
|
|
||
| def main(argv): | ||
| expvar_url = goprocconf.get_expvar_url() |
There was a problem hiding this comment.
First line of main is usually utils.drop_privileges()
| except: | ||
| utils.err("Unexpected error: %s" % sys.exc_info()[0]) | ||
| traceback.print_exc() | ||
| exit(13) |
There was a problem hiding this comment.
Instead of exiting anytime we get a connection error, I suggest we change the workflow to:
- Before while(true): Try connecting to the endpoint if it errors out then exit - This is the scenario where the URL in the yml is not on this server
- In the while(true): On connection error, we log the error and continue the loop - This is the scenario where the URL is correct (we checked before the loop), but there is a transient error
| print("memstats.%s %s %s" % (mk, ts, mv)) | ||
| elif k != 'cmdline': | ||
| _print_nested_metrics(k, v, ts) | ||
| sys.stdout.flush() |
There was a problem hiding this comment.
Convention has been to flush once at the end of each loop, please move it just before the sleep
| collector: | ||
| name: goproc | ||
| config: | ||
| expvar_url: http://localhost:3001/debug/vars No newline at end of file |
There was a problem hiding this comment.
Please change the path to collector.config.endpoints.url so thatwe could support multiple URL scraping in future
There was a problem hiding this comment.
Done. It's a list of dictionaries now in the YAML but we just parse the first element in the list.
| import sys | ||
| import time | ||
|
|
||
| from collectors.etc import goprocconf |
There was a problem hiding this comment.
We are trying to move away from py based conf to yml based conf. Could you inline the yml reading in this collector?
|
Could you rename the collector to |
| pause_sum += pause_ns[index] | ||
| gc_count += 1 | ||
| index = index - 1 | ||
| _print_metric('memstats.PauseNs.sum', ts_seconds, pause_sum) |
There was a problem hiding this comment.
The name as per Metrics 2.0 convention would be memstats.Pause.total.nanos
Fix for #49