From e4a223732a7805128436bd9ad2b017934ac73e36 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Tue, 17 Jan 2023 20:18:18 -0800 Subject: [PATCH] add APP_USER_AGENT to the status page --- web3_proxy/src/app/mod.rs | 7 ++++--- web3_proxy/src/bin/web3_proxy.rs | 4 +++- web3_proxy/src/bin/web3_proxy_cli/main.rs | 6 ++++-- web3_proxy/src/frontend/status.rs | 3 ++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/web3_proxy/src/app/mod.rs b/web3_proxy/src/app/mod.rs index 828dc6bb..44df90af 100644 --- a/web3_proxy/src/app/mod.rs +++ b/web3_proxy/src/app/mod.rs @@ -56,11 +56,12 @@ use tokio::time::{sleep, timeout}; use ulid::Ulid; // TODO: make this customizable? +// TODO: include GIT_REF in here. i had trouble getting https://docs.rs/vergen/latest/vergen/ to work with a workspace. also .git is in .dockerignore pub static APP_USER_AGENT: &str = concat!( - "satoshiandkin/", + "llamanodes_", env!("CARGO_PKG_NAME"), - "/", - env!("CARGO_PKG_VERSION"), + "/v", + env!("CARGO_PKG_VERSION") ); /// TODO: allow customizing the request period? diff --git a/web3_proxy/src/bin/web3_proxy.rs b/web3_proxy/src/bin/web3_proxy.rs index 656fdce4..f1461a22 100644 --- a/web3_proxy/src/bin/web3_proxy.rs +++ b/web3_proxy/src/bin/web3_proxy.rs @@ -17,7 +17,7 @@ use std::path::Path; use std::sync::atomic::{self, AtomicUsize}; use tokio::runtime; use tokio::sync::broadcast; -use web3_proxy::app::{flatten_handle, flatten_handles, Web3ProxyApp}; +use web3_proxy::app::{flatten_handle, flatten_handles, Web3ProxyApp, APP_USER_AGENT}; use web3_proxy::config::{CliConfig, TopConfig}; use web3_proxy::{frontend, metrics_frontend}; @@ -235,6 +235,8 @@ fn main() -> anyhow::Result<()> { log::set_max_level(max_level); + info!("{}", APP_USER_AGENT); + // we used to do this earlier, but now we attach sentry debug!("CLI config @ {:#?}", cli_config.config); diff --git a/web3_proxy/src/bin/web3_proxy_cli/main.rs b/web3_proxy/src/bin/web3_proxy_cli/main.rs index e1241908..85dd901b 100644 --- a/web3_proxy/src/bin/web3_proxy_cli/main.rs +++ b/web3_proxy/src/bin/web3_proxy_cli/main.rs @@ -14,10 +14,10 @@ mod user_export; mod user_import; use argh::FromArgs; -use log::warn; +use log::{info, warn}; use std::fs; use web3_proxy::{ - app::{get_db, get_migrated_db}, + app::{get_db, get_migrated_db, APP_USER_AGENT}, config::TopConfig, }; @@ -126,6 +126,8 @@ async fn main() -> anyhow::Result<()> { log::set_max_level(max_level); + info!("{}", APP_USER_AGENT); + match cli_config.sub_command { SubCommand::ChangeUserAddress(x) => { let db_conn = get_db(cli_config.db_url, 1, 1).await?; diff --git a/web3_proxy/src/frontend/status.rs b/web3_proxy/src/frontend/status.rs index 2e4a8198..df7f8bc9 100644 --- a/web3_proxy/src/frontend/status.rs +++ b/web3_proxy/src/frontend/status.rs @@ -4,7 +4,7 @@ //! They will eventually move to another port. use super::{FrontendResponseCache, FrontendResponseCaches}; -use crate::app::Web3ProxyApp; +use crate::app::{Web3ProxyApp, APP_USER_AGENT}; use axum::{http::StatusCode, response::IntoResponse, Extension, Json}; use axum_macros::debug_handler; use serde_json::json; @@ -33,6 +33,7 @@ pub async fn status( .get_with(FrontendResponseCaches::Status, async { // TODO: what else should we include? uptime, cache hit rates, cpu load, memory used let body = json!({ + "version": APP_USER_AGENT, "chain_id": app.config.chain_id, "balanced_rpcs": app.balanced_rpcs, "private_rpcs": app.private_rpcs,