Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Expose component configs as info metrics (#1584)
## What ❔ - Exposes configs of various components as info metrics [defined](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#info) in the Open Metrics standard. - Reworks mempool cache to be shared between API servers. ## Why ❔ - More idiomatic and observable than printing these configs to logs (or not observing at all). - Allows to use configs in Grafana dashboards, alerts etc. - The mempool cache makes sense to share logically, and if multiple instances are used, reported metrics can be bogus. ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`. - [x] Spellcheck has been run via `zk spellcheck`. - [ ] Linkcheck has been run via `zk linkcheck`.
- Loading branch information
Showing
30 changed files
with
669 additions
and
242 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,46 @@ | ||
//! Build script for the external node binary. | ||
|
||
use std::{ | ||
env, fs, | ||
io::{self, Write}, | ||
path::Path, | ||
}; | ||
|
||
use rustc_version::{Channel, LlvmVersion}; | ||
|
||
fn print_rust_meta(out: &mut impl Write, meta: &rustc_version::VersionMeta) -> io::Result<()> { | ||
writeln!( | ||
out, | ||
"pub(crate) const RUSTC_METADATA: RustcMetadata = RustcMetadata {{ \ | ||
version: {semver:?}, \ | ||
commit_hash: {commit_hash:?}, \ | ||
commit_date: {commit_date:?}, \ | ||
channel: {channel:?}, \ | ||
host: {host:?}, \ | ||
llvm: {llvm:?} \ | ||
}};", | ||
semver = meta.semver.to_string(), | ||
commit_hash = meta.commit_hash, | ||
commit_date = meta.commit_date, | ||
channel = match meta.channel { | ||
Channel::Dev => "dev", | ||
Channel::Beta => "beta", | ||
Channel::Nightly => "nightly", | ||
Channel::Stable => "stable", | ||
}, | ||
host = meta.host, | ||
llvm = meta.llvm_version.as_ref().map(LlvmVersion::to_string), | ||
) | ||
} | ||
|
||
fn main() { | ||
let out_dir = env::var("OUT_DIR").expect("`OUT_DIR` env var not set for build script"); | ||
let rustc_meta = rustc_version::version_meta().expect("Failed obtaining rustc metadata"); | ||
|
||
let metadata_module_path = Path::new(&out_dir).join("metadata_values.rs"); | ||
let metadata_module = | ||
fs::File::create(metadata_module_path).expect("cannot create metadata module"); | ||
let mut metadata_module = io::BufWriter::new(metadata_module); | ||
|
||
print_rust_meta(&mut metadata_module, &rustc_meta).expect("failed printing rustc metadata"); | ||
} |
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
Oops, something went wrong.