Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metrics: Use prometheus for process metrics #2543

Closed
wants to merge 4 commits into from
Closed

Conversation

olix0r
Copy link
Member

@olix0r olix0r commented Dec 2, 2023

We currently have our own implementation of system level metrics. This is unnecessary. The prometheus crate provides a process feature that bundles prometheus's default process-level metrics. This adds a process_threads metric.

This change also updates the static proxy_build_info metric to be exported via the default prometheus registry. This allows us to export this metric from the top-level linkerd2-proxy crate so that the build metadata is not inferred from the linkerd-app-core crate (fixing an old TODO).


Before

# 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 1701551542
# HELP process_uptime_seconds_total Total time since the process started (in seconds)
# TYPE process_uptime_seconds_total counter
process_uptime_seconds_total 1782.137
# 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.72
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 111042560
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 33910784
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 28
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1048576
# HELP proxy_build_info Proxy build info
# TYPE proxy_build_info gauge
proxy_build_info{version="2.213.0",git_sha="9f7e7ac",profile="release",date="2023-11-16T23:24:26Z",vendor="linkerd"} 1

After:

# 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_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1048576
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 24
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 27656192
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1701553218
# HELP process_threads Number of OS threads in the process.
# TYPE process_threads gauge
process_threads 2
# HELP process_uptime_seconds_total Total time since the process started (in seconds)
# TYPE process_uptime_seconds_total gauge
process_uptime_seconds_total 9.700919434
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 109264896
# HELP proxy_build_info Proxy build info
# TYPE proxy_build_info gauge
proxy_build_info{date="2023-12-02T21:32:40Z",git_sha="9a4d02c6f",profile="release",vendor="code@ver-sea",version="0.0.0-dev.9a4d02c6f"} 1

We currently have our own implementation of system level metrics. This
is unnecessary. The `prometheus` crate provides a _process_ feature that
bundles prometheus's default process-level metrics. This adds a
`process_threads` metric.

This change also updates the static `proxy_build_info` metric to be
exported via the default prometheus registry. This allows us to export
this metric from the top-level `linkerd2-proxy` crate so that the build
metadata is not inferred from the linkerd-app-core crate (fixing an old
TODO).

---

Before

> # 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 1701551542
> # HELP process_uptime_seconds_total Total time since the process started (in seconds)
> # TYPE process_uptime_seconds_total counter
> process_uptime_seconds_total 1782.137
> # 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.72
> # HELP process_virtual_memory_bytes Virtual memory size in bytes.
> # TYPE process_virtual_memory_bytes gauge
> process_virtual_memory_bytes 111042560
> # HELP process_resident_memory_bytes Resident memory size in bytes.
> # TYPE process_resident_memory_bytes gauge
> process_resident_memory_bytes 33910784
> # HELP process_open_fds Number of open file descriptors.
> # TYPE process_open_fds gauge
> process_open_fds 28
> # HELP process_max_fds Maximum number of open file descriptors.
> # TYPE process_max_fds gauge
> process_max_fds 1048576
> # HELP proxy_build_info Proxy build info
> # TYPE proxy_build_info gauge
> proxy_build_info{version="2.213.0",git_sha="9f7e7ac",profile="release",date="2023-11-16T23:24:26Z",vendor="linkerd"} 1

After:

> # 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_max_fds Maximum number of open file descriptors.
> # TYPE process_max_fds gauge
> process_max_fds 1048576
> # HELP process_open_fds Number of open file descriptors.
> # TYPE process_open_fds gauge
> process_open_fds 24
> # HELP process_resident_memory_bytes Resident memory size in bytes.
> # TYPE process_resident_memory_bytes gauge
> process_resident_memory_bytes 27656192
> # HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
> # TYPE process_start_time_seconds gauge
> process_start_time_seconds 1701553218
> # HELP process_threads Number of OS threads in the process.
> # TYPE process_threads gauge
> process_threads 2
> # HELP process_uptime_seconds_total Total time since the process started (in seconds)
> # TYPE process_uptime_seconds_total gauge
> process_uptime_seconds_total 9.700919434
> # HELP process_virtual_memory_bytes Virtual memory size in bytes.
> # TYPE process_virtual_memory_bytes gauge
> process_virtual_memory_bytes 109264896
> # HELP proxy_build_info Proxy build info
> # TYPE proxy_build_info gauge
> proxy_build_info{date="2023-12-02T21:32:40Z",git_sha="9a4d02c6f",profile="release",vendor="code@ver-sea",version="0.0.0-dev.9a4d02c6f"} 1
Copy link

codecov bot commented Dec 2, 2023

Codecov Report

Merging #2543 (871af8c) into main (2fe5e7a) will decrease coverage by 0.08%.
The diff coverage is 80.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2543      +/-   ##
==========================================
- Coverage   67.39%   67.31%   -0.08%     
==========================================
  Files         329      327       -2     
  Lines       14652    14568      -84     
==========================================
- Hits         9874     9807      -67     
+ Misses       4778     4761      -17     
Files Coverage Δ
linkerd/app/core/src/lib.rs 87.50% <ø> (ø)
linkerd/app/core/src/metrics.rs 98.43% <100.00%> (-0.04%) ⬇️
linkerd/app/inbound/src/test_util.rs 100.00% <100.00%> (ø)
linkerd/app/outbound/src/test_util.rs 100.00% <100.00%> (ø)
linkerd/app/src/lib.rs 87.11% <100.00%> (ø)
linkerd/metrics/src/counter.rs 91.30% <ø> (ø)
linkerd/metrics/src/fmt.rs 72.41% <ø> (ø)
linkerd/metrics/src/gauge.rs 88.88% <ø> (ø)
linkerd/metrics/src/lib.rs 75.00% <0.00%> (-25.00%) ⬇️
linkerd/metrics/src/serve.rs 80.55% <85.71%> (-0.22%) ⬇️
... and 1 more

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2fe5e7a...871af8c. Read the comment docs.

@olix0r olix0r closed this Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant