add APP_USER_AGENT to the status page

This commit is contained in:
Bryan Stitt 2023-01-17 20:18:18 -08:00
parent 9fe6365283
commit e4a223732a
4 changed files with 13 additions and 7 deletions

View File

@ -56,11 +56,12 @@ use tokio::time::{sleep, timeout};
use ulid::Ulid; use ulid::Ulid;
// TODO: make this customizable? // 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!( pub static APP_USER_AGENT: &str = concat!(
"satoshiandkin/", "llamanodes_",
env!("CARGO_PKG_NAME"), env!("CARGO_PKG_NAME"),
"/", "/v",
env!("CARGO_PKG_VERSION"), env!("CARGO_PKG_VERSION")
); );
/// TODO: allow customizing the request period? /// TODO: allow customizing the request period?

View File

@ -17,7 +17,7 @@ use std::path::Path;
use std::sync::atomic::{self, AtomicUsize}; use std::sync::atomic::{self, AtomicUsize};
use tokio::runtime; use tokio::runtime;
use tokio::sync::broadcast; 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::config::{CliConfig, TopConfig};
use web3_proxy::{frontend, metrics_frontend}; use web3_proxy::{frontend, metrics_frontend};
@ -235,6 +235,8 @@ fn main() -> anyhow::Result<()> {
log::set_max_level(max_level); log::set_max_level(max_level);
info!("{}", APP_USER_AGENT);
// we used to do this earlier, but now we attach sentry // we used to do this earlier, but now we attach sentry
debug!("CLI config @ {:#?}", cli_config.config); debug!("CLI config @ {:#?}", cli_config.config);

View File

@ -14,10 +14,10 @@ mod user_export;
mod user_import; mod user_import;
use argh::FromArgs; use argh::FromArgs;
use log::warn; use log::{info, warn};
use std::fs; use std::fs;
use web3_proxy::{ use web3_proxy::{
app::{get_db, get_migrated_db}, app::{get_db, get_migrated_db, APP_USER_AGENT},
config::TopConfig, config::TopConfig,
}; };
@ -126,6 +126,8 @@ async fn main() -> anyhow::Result<()> {
log::set_max_level(max_level); log::set_max_level(max_level);
info!("{}", APP_USER_AGENT);
match cli_config.sub_command { match cli_config.sub_command {
SubCommand::ChangeUserAddress(x) => { SubCommand::ChangeUserAddress(x) => {
let db_conn = get_db(cli_config.db_url, 1, 1).await?; let db_conn = get_db(cli_config.db_url, 1, 1).await?;

View File

@ -4,7 +4,7 @@
//! They will eventually move to another port. //! They will eventually move to another port.
use super::{FrontendResponseCache, FrontendResponseCaches}; 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::{http::StatusCode, response::IntoResponse, Extension, Json};
use axum_macros::debug_handler; use axum_macros::debug_handler;
use serde_json::json; use serde_json::json;
@ -33,6 +33,7 @@ pub async fn status(
.get_with(FrontendResponseCaches::Status, async { .get_with(FrontendResponseCaches::Status, async {
// TODO: what else should we include? uptime, cache hit rates, cpu load, memory used // TODO: what else should we include? uptime, cache hit rates, cpu load, memory used
let body = json!({ let body = json!({
"version": APP_USER_AGENT,
"chain_id": app.config.chain_id, "chain_id": app.config.chain_id,
"balanced_rpcs": app.balanced_rpcs, "balanced_rpcs": app.balanced_rpcs,
"private_rpcs": app.private_rpcs, "private_rpcs": app.private_rpcs,