Add process name label, fix some metric types
This commit is contained in:
parent
bd7f80f201
commit
190528b722
|
@ -31,7 +31,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
Arc::new(mango::MangoCacheTable {}),
|
||||
];
|
||||
|
||||
let metrics_tx = metrics::start(config.metrics);
|
||||
let metrics_tx = metrics::start(config.metrics, "connector-mango".into());
|
||||
|
||||
let (account_write_queue_sender, slot_queue_sender) =
|
||||
postgres_target::init(&config.postgres_target, account_tables, metrics_tx.clone()).await?;
|
||||
|
|
|
@ -22,7 +22,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
solana_logger::setup_with_default("info");
|
||||
info!("startup");
|
||||
|
||||
let metrics_tx = metrics::start(config.metrics);
|
||||
let metrics_tx = metrics::start(config.metrics, "connector-raw".into());
|
||||
|
||||
let account_tables: AccountTables = vec![Arc::new(RawAccountTable {})];
|
||||
|
||||
|
|
|
@ -247,11 +247,11 @@ pub async fn init(
|
|||
let metrics_sender = metrics_sender.clone();
|
||||
|
||||
let mut metric_events_new =
|
||||
metrics_sender.register_u64("fills_feed_events_new".into(), MetricType::Gauge);
|
||||
metrics_sender.register_u64("fills_feed_events_new".into(), MetricType::Counter);
|
||||
let mut metric_events_change =
|
||||
metrics_sender.register_u64("fills_feed_events_change".into(), MetricType::Gauge);
|
||||
metrics_sender.register_u64("fills_feed_events_change".into(), MetricType::Counter);
|
||||
let mut metrics_events_drop =
|
||||
metrics_sender.register_u64("fills_feed_events_drop".into(), MetricType::Gauge);
|
||||
metrics_sender.register_u64("fills_feed_events_drop".into(), MetricType::Counter);
|
||||
|
||||
// The actual message may want to also contain a retry count, if it self-reinserts on failure?
|
||||
let (account_write_queue_sender, account_write_queue_receiver) =
|
||||
|
|
|
@ -112,6 +112,7 @@ impl MetricBool {
|
|||
#[derive(Clone)]
|
||||
pub struct Metrics {
|
||||
registry: Arc<RwLock<HashMap<String, Value>>>,
|
||||
labels: HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl Metrics {
|
||||
|
@ -201,8 +202,8 @@ impl Metrics {
|
|||
|
||||
async fn handle_prometheus_poll(metrics: Metrics) -> Result<impl Reply, Rejection> {
|
||||
debug!("handle_prometheus_poll");
|
||||
let labels = HashMap::from([("process", "fills")]);
|
||||
let label_strings_vec: Vec<String> = labels
|
||||
let label_strings_vec: Vec<String> = metrics
|
||||
.labels
|
||||
.iter()
|
||||
.map(|(name, value)| format!("{}=\"{}\"", name, value))
|
||||
.collect();
|
||||
|
@ -231,13 +232,13 @@ pub fn with_metrics(
|
|||
warp::any().map(move || metrics.clone())
|
||||
}
|
||||
|
||||
pub fn start(config: MetricsConfig) -> Metrics {
|
||||
pub fn start(config: MetricsConfig, process_name: String) -> Metrics {
|
||||
let mut write_interval = time::interval(time::Duration::from_secs(60));
|
||||
|
||||
let registry = Arc::new(RwLock::new(HashMap::<String, Value>::new()));
|
||||
let registry_c = Arc::clone(®istry);
|
||||
|
||||
let metrics_tx = Metrics { registry };
|
||||
let labels = HashMap::from([(String::from("process"), process_name)]);
|
||||
let metrics_tx = Metrics { registry, labels };
|
||||
let metrics_route = warp::path!("metrics")
|
||||
.and(with_metrics(metrics_tx.clone()))
|
||||
.and_then(handle_prometheus_poll);
|
||||
|
|
|
@ -103,13 +103,13 @@ async fn main() -> anyhow::Result<()> {
|
|||
|
||||
solana_logger::setup_with_default("info");
|
||||
|
||||
let metrics_tx = metrics::start(config.metrics);
|
||||
let metrics_tx = metrics::start(config.metrics, "fills".into());
|
||||
|
||||
let metrics_opened_connections =
|
||||
metrics_tx.register_u64("fills_feed_opened_connections".into(), MetricType::Gauge);
|
||||
metrics_tx.register_u64("fills_feed_opened_connections".into(), MetricType::Counter);
|
||||
|
||||
let metrics_closed_connections =
|
||||
metrics_tx.register_u64("fills_feed_closed_connections".into(), MetricType::Gauge);
|
||||
metrics_tx.register_u64("fills_feed_closed_connections".into(), MetricType::Counter);
|
||||
|
||||
let (account_write_queue_sender, slot_queue_sender, fill_receiver) =
|
||||
fill_event_filter::init(config.markets.clone(), metrics_tx.clone()).await?;
|
||||
|
|
|
@ -198,7 +198,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
solana_logger::setup_with_default("info");
|
||||
info!("startup");
|
||||
|
||||
let metrics_tx = metrics::start(config.metrics);
|
||||
let metrics_tx = metrics::start(config.metrics, "pnl".into());
|
||||
|
||||
let chain_data = Arc::new(RwLock::new(ChainData::new()));
|
||||
let pnl_data = Arc::new(RwLock::new(PnlData::new()));
|
||||
|
|
Loading…
Reference in New Issue