Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Add a new optional configuration `prefix` for telemetry, allowing users
to specify a prefixed namespace for Prometheus metrics.
([\#4380](https://github.com/informalsystems/hermes/issues/4380))
36 changes: 24 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ num-bigint = "0.4"
num-rational = "0.4.1"
once_cell = "1.20.2"
oneline-eyre = "0.1"
opentelemetry = "0.19.0"
opentelemetry-prometheus = "0.12.0"
opentelemetry = "0.20.0"
opentelemetry_sdk = { version = "0.20.0", features = ["metrics"] }
opentelemetry-prometheus = "0.13.0"
primitive-types = { version = "0.12.1", default-features = false }
prometheus = "0.13.4"
prost = "0.13"
Expand Down
12 changes: 12 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ host = '127.0.0.1'
# by the telemetry service. Default: 3001
port = 3001

# Specify the prefix used for Prometheus metrics. This configuration is optional, if
# it is missing the result is equivalent to setting it to empty string: `prefix = ""`
# For example setting `prefix = "hermes"` will result in:
# * `hermes_acknowledgement_events_total`
# * `hermes_wallet_balance`
# * etc...
# The default is no prefix, which results in:
# * `acknowledgement_events_total`
# * `wallet_balance`
# * etc...
# prefix = ""

[telemetry.buckets]
# Specify the range of the 10 histogram buckets in ms for the `tx_latency_submitted` metric.
# Default: { start = 500, end = 10000, buckets = 10 }
Expand Down
1 change: 1 addition & 0 deletions crates/relayer-cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ fn spawn_telemetry_server(config: &Config) {
config.telemetry.buckets.latency_submitted.buckets,
config.telemetry.buckets.latency_confirmed.range.clone(),
config.telemetry.buckets.latency_confirmed.buckets,
config.telemetry.prefix.as_str(),
);
let telemetry = config.telemetry.clone();

Expand Down
3 changes: 3 additions & 0 deletions crates/relayer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ pub struct TelemetryConfig {
pub port: u16,
#[serde(default = "HistogramBuckets::default")]
pub buckets: HistogramBuckets,
#[serde(default)]
pub prefix: String,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -562,6 +564,7 @@ impl Default for TelemetryConfig {
host: "127.0.0.1".to_string(),
port: 3001,
buckets: HistogramBuckets::default(),
prefix: Default::default(),
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/telemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ axum = { workspace = true }
dashmap = { workspace = true }
moka = { workspace = true, features = ["sync"] }
once_cell = { workspace = true }
opentelemetry = { workspace = true, features = ["metrics"] }
opentelemetry = { workspace = true }
opentelemetry_sdk = { workspace = true, features = ["metrics"] }
opentelemetry-prometheus = { workspace = true }
prometheus = { workspace = true }
serde = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions crates/telemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ pub fn new_state(
tx_latency_submitted_buckets: u64,
tx_latency_confirmed_range: Range<u64>,
tx_latency_confirmed_buckets: u64,
namespace: &str,
) -> Arc<TelemetryState> {
Arc::new(TelemetryState::new(
tx_latency_submitted_range,
tx_latency_submitted_buckets,
tx_latency_confirmed_range,
tx_latency_confirmed_buckets,
namespace,
))
}

Expand All @@ -36,12 +38,14 @@ pub fn init(
tx_latency_submitted_buckets: u64,
tx_latency_confirmed_range: Range<u64>,
tx_latency_confirmed_buckets: u64,
namespace: &str,
) -> &'static Arc<TelemetryState> {
let new_state = new_state(
tx_latency_submitted_range,
tx_latency_submitted_buckets,
tx_latency_confirmed_range,
tx_latency_confirmed_buckets,
namespace,
);
match GLOBAL_STATE.set(new_state) {
Ok(_) => debug!("initialised telemetry global state"),
Expand All @@ -68,6 +72,7 @@ pub fn global() -> &'static Arc<TelemetryState> {
end: 20000,
},
10,
"",
)
}
}
Expand Down
Loading
Loading