Skip to content

Commit

Permalink
Remove telemetry and rest-server feature flags (#3878)
Browse files Browse the repository at this point in the history
* Enable telemetry unconditionally and remove `telemetry` feature flag

* Formatting

* Add changelog entry

* Remove `rest-server` feature flag

* Update changelog entry

---------

Signed-off-by: Romain Ruetschi <romain@informal.systems>
  • Loading branch information
romac authored Apr 2, 2024
1 parent 23a2d00 commit cf17704
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Remove the `telemetry` and `rest-server` feature flags, ensuring Hermes is always built with telemetry and REST support.
Both servers can still be disabled in the configuration file, by setting `telemtry.enabled = false` and `rest.enabled = false`, respectively.
([\#3878](https://github.com/informalsystems/hermes/pull/3878))
11 changes: 2 additions & 9 deletions crates/relayer-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,11 @@ default-run = "hermes"
[[bin]]
name = "hermes"

[features]
default = ["telemetry", "rest-server", "std", "eyre_tracer"]
std = ["flex-error/std"]
eyre_tracer = ["flex-error/eyre_tracer"]
telemetry = ["ibc-relayer/telemetry", "ibc-telemetry"]
rest-server = ["ibc-relayer-rest"]

[dependencies]
ibc-relayer-types = { workspace = true }
ibc-relayer = { workspace = true }
ibc-telemetry = { workspace = true, optional = true }
ibc-relayer-rest = { workspace = true, optional = true }
ibc-telemetry = { workspace = true }
ibc-relayer-rest = { workspace = true }
ibc-chain-registry = { workspace = true }

abscissa_core = { workspace = true, features = ["options"] }
Expand Down
28 changes: 0 additions & 28 deletions crates/relayer-cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ fn register_signals(tx_cmd: Sender<SupervisorCmd>) -> Result<(), io::Error> {
Ok(())
}

#[cfg(feature = "rest-server")]
fn spawn_rest_server(config: &Config) -> Option<rest::Receiver> {
use ibc_relayer::util::spawn_blocking;

Expand Down Expand Up @@ -169,23 +168,6 @@ fn spawn_rest_server(config: &Config) -> Option<rest::Receiver> {
Some(rx)
}

#[cfg(not(feature = "rest-server"))]
fn spawn_rest_server(config: &Config) -> Option<rest::Receiver> {
let rest = config.rest.clone();

if rest.enabled {
warn!(
"REST server enabled in the config but Hermes was built without REST support, \
build Hermes with --features=rest-server to enable REST support."
);

None
} else {
None
}
}

#[cfg(feature = "telemetry")]
fn spawn_telemetry_server(config: &Config) {
use ibc_relayer::util::spawn_blocking;

Expand Down Expand Up @@ -220,16 +202,6 @@ fn spawn_telemetry_server(config: &Config) {
});
}

#[cfg(not(feature = "telemetry"))]
fn spawn_telemetry_server(config: &Config) {
if config.telemetry.enabled {
warn!(
"telemetry enabled in the config but Hermes was built without telemetry support, \
build Hermes with --features=telemetry to enable telemetry support."
);
}
}

fn make_supervisor<Chain: ChainHandle>(
config: Config,
options: SupervisorOptions,
Expand Down
3 changes: 1 addition & 2 deletions crates/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ all-features = true

[features]
default = ["flex-error/std", "flex-error/eyre_tracer"]
telemetry = ["ibc-telemetry"]

[dependencies]
ibc-proto = { workspace = true, features = ["serde"] }
ibc-telemetry = { workspace = true, optional = true }
ibc-telemetry = { workspace = true }
ibc-relayer-types = { workspace = true, features = ["clock"] }

anyhow = { workspace = true }
Expand Down
1 change: 0 additions & 1 deletion crates/relayer/src/chain/cosmos/estimate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ fn can_recover_from_simulation_failure(e: &Error) -> bool {
}
}

#[cfg(feature = "telemetry")]
fn get_error_text(e: &Error) -> String {
use crate::error::ErrorDetail::*;

Expand Down
4 changes: 0 additions & 4 deletions crates/relayer/src/link/relay_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,6 @@ impl<ChainA: ChainHandle, ChainB: ChainHandle> RelayPath<ChainA, ChainB> {
}

// we need fully qualified ChainId to avoid unneeded imports warnings
#[cfg(feature = "telemetry")]
fn target_info(
&self,
target: OperationalDataTarget,
Expand All @@ -1871,7 +1870,6 @@ impl<ChainA: ChainHandle, ChainB: ChainHandle> RelayPath<ChainA, ChainB> {
}
}

#[cfg(feature = "telemetry")]
fn backlog_update(&self, event: &IbcEvent) {
match event {
IbcEvent::SendPacket(send_packet_ev) => {
Expand Down Expand Up @@ -1905,7 +1903,6 @@ impl<ChainA: ChainHandle, ChainB: ChainHandle> RelayPath<ChainA, ChainB> {
}
}

#[cfg(feature = "telemetry")]
fn record_cleared_send_packet(&self, event_with_height: &IbcEventWithHeight) {
if let IbcEvent::SendPacket(send_packet_ev) = &event_with_height.event {
ibc_telemetry::global().send_packet_events(
Expand All @@ -1927,7 +1924,6 @@ impl<ChainA: ChainHandle, ChainB: ChainHandle> RelayPath<ChainA, ChainB> {
}
}

#[cfg(feature = "telemetry")]
fn record_cleared_acknowledgments<'a>(
&self,
events_with_heights: impl Iterator<Item = &'a IbcEventWithHeight>,
Expand Down
1 change: 0 additions & 1 deletion crates/relayer/src/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,6 @@ fn process_batch<Chain: ChainHandle>(
/// So successfully sending a packet from chain A to chain B will result in first a SendPacket
/// event with `chain_id = A` and `counterparty_chain_id = B` and then a WriteAcknowlegment
/// event with `chain_id = B` and `counterparty_chain_id = A`.
#[cfg(feature = "telemetry")]
fn send_telemetry<Src, Dst>(
src: &Src,
dst: &Dst,
Expand Down
11 changes: 0 additions & 11 deletions crates/relayer/src/telemetry.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
// If the `telemetry` feature is enabled, re-export the `ibc-telemetry` state.
#[cfg(feature = "telemetry")]
pub type Telemetry = alloc::sync::Arc<ibc_telemetry::TelemetryState>;

// Otherwise, define and export a dummy type.
#[cfg(not(feature = "telemetry"))]
#[derive(Clone, Debug)]
pub struct TelemetryDisabled;

#[cfg(not(feature = "telemetry"))]
pub type Telemetry = TelemetryDisabled;

/// A macro to send metric updates via a telemetry handle,
/// only if the `telemetry` feature is enabled.
/// Otherwise, it compiles to a no-op.
Expand All @@ -32,7 +23,6 @@ pub type Telemetry = TelemetryDisabled;
#[macro_export]
macro_rules! telemetry {
($id:ident, $($args:expr),* $(,)*) => {
#[cfg(feature = "telemetry")]
#[allow(unused_imports, unused_variables)]
{
use ::ibc_telemetry::state::WorkerType;
Expand All @@ -42,7 +32,6 @@ macro_rules! telemetry {
};

($e:expr) => {
#[cfg(feature = "telemetry")]
#[allow(unused_imports, unused_variables)]
{
use ::ibc_telemetry::state::WorkerType;
Expand Down
1 change: 0 additions & 1 deletion crates/relayer/src/worker/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ impl Drop for WorkerMap {
}
}

#[cfg(feature = "telemetry")]
fn metric_type(o: &Object) -> ibc_telemetry::state::WorkerType {
use ibc_telemetry::state::WorkerType;

Expand Down
5 changes: 0 additions & 5 deletions crates/relayer/src/worker/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,8 @@ fn lowest_sequence(events: &[IbcEventWithHeight]) -> Option<Sequence> {
.min()
}

#[cfg(feature = "telemetry")]
use crate::link::RelaySummary;

#[cfg(feature = "telemetry")]
fn packet_metrics(
path: &Packet,
summary: &RelaySummary,
Expand All @@ -499,7 +497,6 @@ fn packet_metrics(
timeout_metrics(path, summary, dst_channel, dst_port);
}

#[cfg(feature = "telemetry")]
fn receive_packet_metrics(
path: &Packet,
summary: &RelaySummary,
Expand All @@ -526,7 +523,6 @@ fn receive_packet_metrics(
);
}

#[cfg(feature = "telemetry")]
fn acknowledgment_metrics(
path: &Packet,
summary: &RelaySummary,
Expand All @@ -553,7 +549,6 @@ fn acknowledgment_metrics(
);
}

#[cfg(feature = "telemetry")]
fn timeout_metrics(
path: &Packet,
summary: &RelaySummary,
Expand Down

0 comments on commit cf17704

Please sign in to comment.