mirror of https://github.com/linkerd/linkerd2.git
This branch adds process stats to the proxy's metrics, as described in https://prometheus.io/docs/instrumenting/writing_clientlibs/#process-metrics. In particular, it adds metrics for the process's total CPU time, number of open file descriptors and max file descriptors, virtual memory size, and resident set size. This branch adds a dependency on the `procinfo` crate. Since this crate and the syscalls it wraps are Linux-specific, these stats are only reported on Linux. On other operating systems, they aren't reported. Manual testing Metrics scrape: ``` eliza@ares:~$ curl http://localhost:4191/metrics # HELP process_cpu_seconds_total Total user and system CPU time spent in seconds. # TYPE process_cpu_seconds_total counter process_cpu_seconds_total 0 # HELP process_open_fds Number of open file descriptors. # TYPE process_open_fds gauge process_open_fds 19 # HELP process_max_fds Maximum number of open file descriptors. # TYPE process_max_fds gauge process_max_fds 1024 # HELP process_virtual_memory_bytes Virtual memory size in bytes. # TYPE process_virtual_memory_bytes gauge process_virtual_memory_bytes 45252608 # HELP process_resident_memory_bytes Resident memory size in bytes. # TYPE process_resident_memory_bytes gauge process_resident_memory_bytes 12132352 # HELP process_start_time_seconds Time that the process started (in seconds since the UNIX epoch) # TYPE process_start_time_seconds gauge process_start_time_seconds 1529017536 ``` Note that the `process_cpu_seconds_total` stat is 0 because I just launched this conduit instance and it's not seeing any load; it does go up after i sent a few requests to it. Confirm RSS & virtual memory stats w/ `ps`, and get Conduit's pid so we can check the fd stats (note that `ps` reports virt/rss in kb while Conduit's metrics reports them in bytes): ``` eliza@ares:~$ ps aux | grep conduit | grep -v grep eliza 16766 0.0 0.0 44192 12956 pts/2 Sl+ 16:05 0:00 target/debug/conduit-proxy ``` Count conduit process's open fds: ``` eliza@ares:~$ cd /proc/16766/fd eliza@ares:/proc/16766/fd$ ls -l | wc -l 18 ``` Signed-off-by: Eliza Weisman <eliza@buoyant.io> |
||
---|---|---|
.. | ||
benches | ||
controller-grpc | ||
futures-mpsc-lossy | ||
router | ||
src | ||
tests | ||
Cargo.toml | ||
Dockerfile |