Skip to content

metrics: add process_uptime_seconds_total metric #1659

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

Merged
merged 3 commits into from
May 12, 2022
Merged

metrics: add process_uptime_seconds_total metric #1659

merged 3 commits into from
May 12, 2022

Conversation

hawkw
Copy link
Contributor

@hawkw hawkw commented May 9, 2022

The proxy exposes a process_cpu_seconds_total metric. It also exposes
a process_start_time_seconds metric. But given a random metrics
snapshot, we have no way of knowing the proxy's uptime unless we know
the current time at the time of the snapshot. linkerd/linkerd2#8443
proposed adding a process_uptime_seconds_total metric tracking the
(fractional) number of seconds since the process started, to make these
other process metrics easier to interpret.

This branch implements the process_uptime_seconds_total metric.
Actually adding the metric is rather simple.

However, it occurred to me that uptimes are also used as timestamps in
the proxy's tracing logs. Currently, the start time used to calculate
log timestamps is just recorded when constructing the logger. If
separate Instants are used as the start time for log uptime timestamps
and for the process_uptime_seconds_total metric, this means the
process' uptime as reported by the metrics endpoint and the process'
uptime according to log messages may not quite agree. Therefore, I
thought it would be good if a single Instant was used for both logging
and metrics, and I made some additional changes so that we can record a
single timestamp when the proxy starts, and pass it into both the
metrics endpoint and the logger. This does make this branch a slightly
larger change, though.

Closes linkerd/linkerd2#8443

@hawkw hawkw requested a review from a team as a code owner May 9, 2022 17:40
Comment on lines 63 to 65
pub fn from_env() -> Self {
Self {
filter: std::env::var(ENV_LOG_LEVEL).ok(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC this is only called in one place. Should it just take an Instant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call, changed it to just pass in the Instant there!

Signed-off-by: Eliza Weisman <[email protected]>
@hawkw hawkw merged commit 862e2f1 into main May 12, 2022
@hawkw hawkw deleted the eliza/uptime branch May 12, 2022 16:54
olix0r added a commit to linkerd/linkerd2 that referenced this pull request May 12, 2022
This release updates "ingress-mode" proxies to be able to forward
non-HTTP traffic within the cluster. Protocol detection is always
attempted for outbound connections, however, when in ingress mode.

This release also adds a new `process_uptime_seconds_total` metric.

---

* Replace std::<num>::MAX with <num>::MAX  (linkerd/linkerd2-proxy#1619)
* build(deps): bump prettyplease from 0.1.9 to 0.1.10 (linkerd/linkerd2-proxy#1624)
* build(deps): bump tj-actions/changed-files from 18.7 to 19 (linkerd/linkerd2-proxy#1628)
* build(deps): bump httparse from 1.7.0 to 1.7.1 (linkerd/linkerd2-proxy#1627)
* build(deps): bump tonic-build from 0.7.0 to 0.7.1 (linkerd/linkerd2-proxy#1629)
* build(deps): bump pin-project-lite from 0.2.8 to 0.2.9 (linkerd/linkerd2-proxy#1630)
* build(deps): bump codecov/codecov-action from 3.0.0 to 3.1.0 (linkerd/linkerd2-proxy#1620)
* build(deps): bump actions/checkout from 3.0.1 to 3.0.2 (linkerd/linkerd2-proxy#1621)
* build(deps): bump anyhow from 1.0.56 to 1.0.57 (linkerd/linkerd2-proxy#1623)
* build(deps): bump tracing-log from 0.1.2 to 0.1.3 (linkerd/linkerd2-proxy#1622)
* build(deps): bump tinyvec from 1.5.1 to 1.6.0 (linkerd/linkerd2-proxy#1625)
* build(deps): bump unicode-bidi from 0.3.7 to 0.3.8 (linkerd/linkerd2-proxy#1626)
* build(deps): bump libc from 0.2.124 to 0.2.125 (linkerd/linkerd2-proxy#1632)
* build(deps): bump tokio from 1.17.0 to 1.18.0 (linkerd/linkerd2-proxy#1633)
* build(deps): bump syn from 1.0.91 to 1.0.92 (linkerd/linkerd2-proxy#1634)
* build(deps): bump http from 0.2.6 to 0.2.7 (linkerd/linkerd2-proxy#1631)
* build(deps): bump serde from 1.0.136 to 1.0.137 (linkerd/linkerd2-proxy#1639)
* build(deps): bump serde_json from 1.0.79 to 1.0.80 (linkerd/linkerd2-proxy#1635)
* build(deps): bump thiserror from 1.0.30 to 1.0.31 (linkerd/linkerd2-proxy#1636)
* build(deps): bump parking_lot_core from 0.9.2 to 0.9.3 (linkerd/linkerd2-proxy#1637)
* build(deps): bump memchr from 2.4.1 to 2.5.0 (linkerd/linkerd2-proxy#1638)
* build(deps): bump tokio from 1.18.0 to 1.18.1 (linkerd/linkerd2-proxy#1643)
* build(deps): bump unicode-xid from 0.2.2 to 0.2.3 (linkerd/linkerd2-proxy#1646)
* build(deps): bump log from 0.4.16 to 0.4.17 (linkerd/linkerd2-proxy#1645)
* build(deps): bump num-traits from 0.2.14 to 0.2.15 (linkerd/linkerd2-proxy#1644)
* ingress: Fall back to normal TCP forwarding (linkerd/linkerd2-proxy#1649)
* build(deps): bump serde_json from 1.0.80 to 1.0.81 (linkerd/linkerd2-proxy#1647)
* build(deps): bump tokio-rustls from 0.23.3 to 0.23.4 (linkerd/linkerd2-proxy#1648)
* build(deps): bump tonic-build from 0.7.1 to 0.7.2 (linkerd/linkerd2-proxy#1650)
* build(deps): bump prost-build from 0.10.0 to 0.10.3 (linkerd/linkerd2-proxy#1651)
* build(deps): bump socket2 from 0.4.4 to 0.4.5 (linkerd/linkerd2-proxy#1654)
* build(deps): bump EmbarkStudios/cargo-deny-action from 1.2.15 to 1.2.16 (linkerd/linkerd2-proxy#1653)
* build(deps): bump prost from 0.10.0 to 0.10.3 (linkerd/linkerd2-proxy#1655)
* build(deps): bump tokio from 1.18.1 to 1.18.2 (linkerd/linkerd2-proxy#1657)
* build(deps): bump mio from 0.8.2 to 0.8.3 (linkerd/linkerd2-proxy#1656)
* build(deps): bump proc-macro2 from 1.0.37 to 1.0.38 (linkerd/linkerd2-proxy#1658)
* build(deps): bump EmbarkStudios/cargo-deny-action from 1.2.16 to 1.2.17 (linkerd/linkerd2-proxy#1660)
* build(deps): bump syn from 1.0.92 to 1.0.93 (linkerd/linkerd2-proxy#1661)
* metrics: add `process_uptime_seconds_total` metric (linkerd/linkerd2-proxy#1659)

Signed-off-by: Oliver Gould <[email protected]>
mateiidavid pushed a commit to linkerd/linkerd2 that referenced this pull request May 13, 2022
This release updates "ingress-mode" proxies to be able to forward
non-HTTP traffic within the cluster. Protocol detection is always
attempted for outbound connections, however, when in ingress mode.

This release also adds a new `process_uptime_seconds_total` metric.

---

* Replace std::<num>::MAX with <num>::MAX  (linkerd/linkerd2-proxy#1619)
* build(deps): bump prettyplease from 0.1.9 to 0.1.10 (linkerd/linkerd2-proxy#1624)
* build(deps): bump tj-actions/changed-files from 18.7 to 19 (linkerd/linkerd2-proxy#1628)
* build(deps): bump httparse from 1.7.0 to 1.7.1 (linkerd/linkerd2-proxy#1627)
* build(deps): bump tonic-build from 0.7.0 to 0.7.1 (linkerd/linkerd2-proxy#1629)
* build(deps): bump pin-project-lite from 0.2.8 to 0.2.9 (linkerd/linkerd2-proxy#1630)
* build(deps): bump codecov/codecov-action from 3.0.0 to 3.1.0 (linkerd/linkerd2-proxy#1620)
* build(deps): bump actions/checkout from 3.0.1 to 3.0.2 (linkerd/linkerd2-proxy#1621)
* build(deps): bump anyhow from 1.0.56 to 1.0.57 (linkerd/linkerd2-proxy#1623)
* build(deps): bump tracing-log from 0.1.2 to 0.1.3 (linkerd/linkerd2-proxy#1622)
* build(deps): bump tinyvec from 1.5.1 to 1.6.0 (linkerd/linkerd2-proxy#1625)
* build(deps): bump unicode-bidi from 0.3.7 to 0.3.8 (linkerd/linkerd2-proxy#1626)
* build(deps): bump libc from 0.2.124 to 0.2.125 (linkerd/linkerd2-proxy#1632)
* build(deps): bump tokio from 1.17.0 to 1.18.0 (linkerd/linkerd2-proxy#1633)
* build(deps): bump syn from 1.0.91 to 1.0.92 (linkerd/linkerd2-proxy#1634)
* build(deps): bump http from 0.2.6 to 0.2.7 (linkerd/linkerd2-proxy#1631)
* build(deps): bump serde from 1.0.136 to 1.0.137 (linkerd/linkerd2-proxy#1639)
* build(deps): bump serde_json from 1.0.79 to 1.0.80 (linkerd/linkerd2-proxy#1635)
* build(deps): bump thiserror from 1.0.30 to 1.0.31 (linkerd/linkerd2-proxy#1636)
* build(deps): bump parking_lot_core from 0.9.2 to 0.9.3 (linkerd/linkerd2-proxy#1637)
* build(deps): bump memchr from 2.4.1 to 2.5.0 (linkerd/linkerd2-proxy#1638)
* build(deps): bump tokio from 1.18.0 to 1.18.1 (linkerd/linkerd2-proxy#1643)
* build(deps): bump unicode-xid from 0.2.2 to 0.2.3 (linkerd/linkerd2-proxy#1646)
* build(deps): bump log from 0.4.16 to 0.4.17 (linkerd/linkerd2-proxy#1645)
* build(deps): bump num-traits from 0.2.14 to 0.2.15 (linkerd/linkerd2-proxy#1644)
* ingress: Fall back to normal TCP forwarding (linkerd/linkerd2-proxy#1649)
* build(deps): bump serde_json from 1.0.80 to 1.0.81 (linkerd/linkerd2-proxy#1647)
* build(deps): bump tokio-rustls from 0.23.3 to 0.23.4 (linkerd/linkerd2-proxy#1648)
* build(deps): bump tonic-build from 0.7.1 to 0.7.2 (linkerd/linkerd2-proxy#1650)
* build(deps): bump prost-build from 0.10.0 to 0.10.3 (linkerd/linkerd2-proxy#1651)
* build(deps): bump socket2 from 0.4.4 to 0.4.5 (linkerd/linkerd2-proxy#1654)
* build(deps): bump EmbarkStudios/cargo-deny-action from 1.2.15 to 1.2.16 (linkerd/linkerd2-proxy#1653)
* build(deps): bump prost from 0.10.0 to 0.10.3 (linkerd/linkerd2-proxy#1655)
* build(deps): bump tokio from 1.18.1 to 1.18.2 (linkerd/linkerd2-proxy#1657)
* build(deps): bump mio from 0.8.2 to 0.8.3 (linkerd/linkerd2-proxy#1656)
* build(deps): bump proc-macro2 from 1.0.37 to 1.0.38 (linkerd/linkerd2-proxy#1658)
* build(deps): bump EmbarkStudios/cargo-deny-action from 1.2.16 to 1.2.17 (linkerd/linkerd2-proxy#1660)
* build(deps): bump syn from 1.0.92 to 1.0.93 (linkerd/linkerd2-proxy#1661)
* metrics: add `process_uptime_seconds_total` metric (linkerd/linkerd2-proxy#1659)

Signed-off-by: Oliver Gould <[email protected]>
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.

Add a process_uptime_seconds_total proxy metric
2 participants