-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metrics: Use prometheus-client for proxy_build_info (#2551)
In preparation to add metrics that report float values, and ultimately in service of replacing Linkerd's custom metrics implementation with an upstream library, this change adds an integration with the prometheus-client crate. This is accomplished by leaving the existing types and traits in place and adding a FmtMetrics implementation for the prometheus-client Registry type, minimizing the change needed to support this new library. New metrics can use the upstream registry and metric types. The proxy_build_info metric has been ported to use the new API to validate the new library. Now, the metrics dump ends with: # HELP proxy_build_info Proxy build info. # TYPE proxy_build_info gauge proxy_build_info{date="2023-12-05T19:52:40Z",git_sha="215c32d3f",profile="release",vendor="code@ver-sea",version="0.0.0-dev.215c32d3f"} 1 # EOF
- Loading branch information
Showing
13 changed files
with
123 additions
and
60 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use linkerd_metrics::prom::{self, encoding::EncodeLabelSet}; | ||
|
||
pub const BUILD_INFO: BuildInfo = BuildInfo { | ||
date: env!("LINKERD2_PROXY_BUILD_DATE"), | ||
git_sha: env!("GIT_SHA"), | ||
profile: env!("PROFILE"), | ||
vendor: env!("LINKERD2_PROXY_VENDOR"), | ||
version: env!("LINKERD2_PROXY_VERSION"), | ||
}; | ||
|
||
#[derive(Copy, Clone, Debug, Default, Hash, PartialEq, Eq, EncodeLabelSet)] | ||
pub struct BuildInfo { | ||
pub date: &'static str, | ||
pub git_sha: &'static str, | ||
pub profile: &'static str, | ||
pub vendor: &'static str, | ||
pub version: &'static str, | ||
} | ||
|
||
impl BuildInfo { | ||
pub fn metric(&self) -> prom::Family<BuildInfo, prom::ConstGauge> { | ||
let fam = prom::Family::<Self, prom::ConstGauge>::new_with_constructor(|| { | ||
prom::ConstGauge::new(1) | ||
}); | ||
let _ = fam.get_or_create(self); | ||
fam | ||
} | ||
} |
This file contains 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 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 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pub mod build_info; | ||
pub mod process; | ||
|
||
pub use self::process::StartTime; |
This file was deleted.
Oops, something went wrong.
This file contains 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 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
File renamed without changes.
This file contains 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 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 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