Skip to content

Commit 6d4889a

Browse files
authored
Merge pull request #1283 from movementlabsxyz/indexer-v2-1
[feat] add metrics+health server component for indexer v2 (1/n)
2 parents e5e78e6 + 36bd80e commit 6d4889a

File tree

12 files changed

+209
-23
lines changed

12 files changed

+209
-23
lines changed

Cargo.lock

Lines changed: 62 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ hyper-util = { version = "0.1.4" }
359359
tower = { version = "0.5" }
360360
http-body-util = "0.1"
361361
tap = "1.0.1"
362+
prometheus = "0.14.0"
362363

363364
# trying to pin diesel
364365
diesel = { version = "2.2.7", features = ["postgres", "numeric", "r2d2"] }

protocol-units/execution/maptos/util/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ hex = { workspace = true }
2929
tokio = { workspace = true }
3030
url = { workspace = true }
3131
tracing = { workspace = true }
32+
poem = { workspace = true }
33+
prometheus = { workspace = true }
34+
3235

3336
aptos-sdk = { workspace = true }
3437
movement-signer-loader = { workspace = true }

protocol-units/execution/maptos/util/src/config/common.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,23 @@ env_default!(
246246
HashValue::sha3_256_of(b"maptos").to_hex()
247247
);
248248

249+
env_default!(
250+
default_health_server_hostname,
251+
"HEALTH_SERVER_HOSTNAME",
252+
String,
253+
"0.0.0.0".to_string()
254+
);
255+
256+
env_default!(default_health_server_port, "HEALTH_SERVER_PORT", u16, 18085);
257+
258+
env_default!(
259+
default_metrics_server_hostname,
260+
"METRICS_SERVER_HOSTNAME",
261+
String,
262+
"0.0.0.0".to_string()
263+
);
264+
env_default!(default_metrics_server_port, "METRICS_SERVER_PORT", u16, 18185);
265+
249266
env_default!(default_batch_production_time, "MAPTOS_BATCH_PRODUCTION_TIME_MS", u64, 2000);
250267

251268
env_default!(default_max_transactions_in_flight, "MAPTOS_MAX_TRANSACTIONS_IN_FLIGHT", u64);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use super::common::{default_health_server_hostname, default_health_server_port};
2+
use serde::{Deserialize, Serialize};
3+
4+
// An additional health server to be used by the indexer(or any other service).
5+
// Do not use this with node since it exposes various endpoints to verify the health of the node.
6+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
7+
pub struct Config {
8+
#[serde(default = "default_health_server_hostname")]
9+
pub hostname: String,
10+
#[serde(default = "default_health_server_port")]
11+
pub port: u16,
12+
}
13+
14+
impl Default for Config {
15+
fn default() -> Self {
16+
Self { hostname: default_health_server_hostname(), port: default_health_server_port() }
17+
}
18+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use super::common::{default_metrics_server_hostname, default_metrics_server_port};
2+
use serde::{Deserialize, Serialize};
3+
4+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
5+
pub struct MetricsConfig {
6+
#[serde(default = "default_metrics_server_hostname")]
7+
pub listen_hostname: String,
8+
#[serde(default = "default_metrics_server_port")]
9+
pub listen_port: u16,
10+
}
11+
12+
impl Default for MetricsConfig {
13+
fn default() -> Self {
14+
Self {
15+
listen_hostname: default_metrics_server_hostname(),
16+
listen_port: default_metrics_server_port(),
17+
}
18+
}
19+
}

protocol-units/execution/maptos/util/src/config/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ pub mod common;
44
pub mod da_sequencer;
55
pub mod faucet;
66
pub mod fin;
7+
pub mod health_server;
78
pub mod indexer;
89
pub mod indexer_processor;
910
pub mod load_shedding;
1011
pub mod mempool;
12+
pub mod metrics_server;
1113

1214
use serde::{Deserialize, Serialize};
1315

util/health/Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "movement-health"
3+
description = "Health utilities for Movement services"
4+
version.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
authors.workspace = true
8+
repository.workspace = true
9+
homepage.workspace = true
10+
publish.workspace = true
11+
rust-version.workspace = true
12+
13+
[dependencies]
14+
poem = { workspace = true }
15+
anyhow = { workspace = true }
16+
17+
[lints]
18+
workspace = true

0 commit comments

Comments
 (0)