Skip to content

Commit

Permalink
refactor: add app in greptime_app_version metric (GreptimeTeam#4626)
Browse files Browse the repository at this point in the history
refactor: add app in greptime_app_version metric
  • Loading branch information
zyy17 authored and CookiePieWw committed Sep 17, 2024
1 parent f4cd2c0 commit ba57068
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/cmd/src/datanode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl StartCommand {
&opts.component.tracing,
opts.component.node_id.map(|x| x.to_string()),
);
log_versions(version(), short_version());
log_versions(version(), short_version(), APP_NAME);

info!("Datanode start command: {:#?}", self);
info!("Datanode options: {:#?}", opts);
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/src/flownode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl StartCommand {
&opts.component.tracing,
opts.component.node_id.map(|x| x.to_string()),
);
log_versions(version(), short_version());
log_versions(version(), short_version(), APP_NAME);

info!("Flownode start command: {:#?}", self);
info!("Flownode options: {:#?}", opts);
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/src/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl StartCommand {
&opts.component.tracing,
opts.component.node_id.clone(),
);
log_versions(version(), short_version());
log_versions(version(), short_version(), APP_NAME);

info!("Frontend start command: {:#?}", self);
info!("Frontend options: {:#?}", opts);
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub mod standalone;

lazy_static::lazy_static! {
static ref APP_VERSION: prometheus::IntGaugeVec =
prometheus::register_int_gauge_vec!("greptime_app_version", "app version", &["version", "short_version"]).unwrap();
prometheus::register_int_gauge_vec!("greptime_app_version", "app version", &["version", "short_version", "app"]).unwrap();
}

#[async_trait]
Expand Down Expand Up @@ -76,10 +76,10 @@ pub trait App: Send {
/// Log the versions of the application, and the arguments passed to the cli.
/// `version` should be the same as the output of cli "--version";
/// and the `short_version` is the short version of the codes, often consist of git branch and commit.
pub fn log_versions(version: &str, short_version: &str) {
pub fn log_versions(version: &str, short_version: &str, app: &str) {
// Report app version as gauge.
APP_VERSION
.with_label_values(&[env!("CARGO_PKG_VERSION"), short_version])
.with_label_values(&[env!("CARGO_PKG_VERSION"), short_version, app])
.inc();

// Log version and argument flags.
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/src/metasrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl StartCommand {
&opts.component.tracing,
None,
);
log_versions(version(), short_version());
log_versions(version(), short_version(), APP_NAME);

info!("Metasrv start command: {:#?}", self);
info!("Metasrv options: {:#?}", opts);
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/src/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl StartCommand {
&opts.component.tracing,
None,
);
log_versions(version(), short_version());
log_versions(version(), short_version(), APP_NAME);

info!("Standalone start command: {:#?}", self);
info!("Standalone options: {opts:#?}");
Expand Down

0 comments on commit ba57068

Please sign in to comment.