Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add telemetry and Prometheus endpoint #985

Merged
merged 32 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
26f2728
Initial telemetry support implementation (#868)
andynog May 13, 2021
f83a842
Merging master (#868)
andynog May 18, 2021
ec75bbe
Refactored code for state and service. Replaced hyper with rouille (#…
andynog May 19, 2021
415dead
Merging master changes
andynog May 19, 2021
6954493
Initial logic to include the telemetry in the Supervisor (#868)
andynog May 19, 2021
1781413
Refactored logic into server and service. Server working (#868)
andynog May 22, 2021
9e7a954
Added new methods for state and server (#868)
andynog May 22, 2021
42ee685
Telemetry service logic working, recording a metric (#868)
andynog May 22, 2021
5893724
Added more metrics (#868)
andynog May 22, 2021
9d7985e
Added logic to disable/enable telemetry service and server (#868)
andynog May 23, 2021
2a56c99
Added more metrics to service. Hookup the packet timeout metric (#868)
andynog May 23, 2021
e4639b0
Merge branch 'master' into andy/telemetry
romac May 26, 2021
a178789
Move telemetry service into `ibc-telemetry` crate
romac May 26, 2021
4861504
Move `metric!` macro into its own module
romac May 26, 2021
2a190d8
Move telemetry config under `[telemetry]` section
romac May 26, 2021
85ff902
Disable telemetry by default, fix port to 3001
romac May 26, 2021
2d6cdd2
Merge branch 'master' into andy/telemetry
romac May 26, 2021
c2f2fa9
Try to fix libm.so error
romac May 26, 2021
cf98b0d
Wrap telemetry state in Arc and simplify server a little
romac May 26, 2021
7dd967f
Simplify server a bit more
romac May 26, 2021
4201f92
Fix glibc version mismatch between CI and Docker image
romac May 27, 2021
6d9cbc2
Merge branch 'master' into andy/telemetry
romac May 27, 2021
0dbf86a
Push telemetry handle down into workers
romac May 27, 2021
02b9044
Implement `workers`, `ibc_client_misbehaviours` and `receive_packets`…
romac May 27, 2021
80fdcdf
Add `ibc_client_update` metric
romac May 27, 2021
56a76c2
Remove need for telemetry service by passing around the telemetry state
romac May 28, 2021
ffccfb2
Add ack and timeout metrics
ancazamfir May 28, 2021
4cf8e16
Fix compilation when telemetry feature is not included
ancazamfir May 28, 2021
28198d3
Merge branch 'master' into andy/telemetry
adizere May 31, 2021
c4af7bb
FMT
adizere May 31, 2021
0d8c926
Rename metric! macro to telemetry!
romac Jun 1, 2021
4964019
Add `clippy --no-default-features` to CI
romac Jun 1, 2021
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
628 changes: 593 additions & 35 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ members = [
"modules",
"relayer",
"relayer-cli",
"proto"
"telemetry",
"proto",
]

exclude = [
Expand Down
4 changes: 4 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
strategy = 'packets'
log_level = 'info'

[telemetry]
enabled = true
port = 3001

[[chains]]
id = 'ibc-0'
rpc_addr = 'http://127.0.0.1:26657'
Expand Down
6 changes: 3 additions & 3 deletions modules/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ pub enum IbcEvent {
}

/// For use in debug messages
pub struct VecIbcEvents(pub Vec<IbcEvent>);
impl fmt::Display for VecIbcEvents {
pub struct PrettyEvents<'a>(pub &'a [IbcEvent]);
impl<'a> fmt::Display for PrettyEvents<'a> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
writeln!(f, "events:")?;
for v in &self.0 {
for v in self.0 {
writeln!(f, "\t{}", v)?;
}
Ok(())
Expand Down
9 changes: 6 additions & 3 deletions relayer-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ description = """
name = "hermes"

[features]
default = ["telemetry"]
profiling = ["ibc-relayer/profiling"]
telemetry = ["ibc-relayer/telemetry", "ibc-telemetry"]

[dependencies]
ibc = { version = "0.3.2", path = "../modules" }
ibc-relayer = { version = "0.3.2", path = "../relayer" }
ibc-proto = { version = "0.8.0", path = "../proto" }
ibc = { version = "0.3.2", path = "../modules" }
ibc-relayer = { version = "0.3.2", path = "../relayer" }
ibc-proto = { version = "0.8.0", path = "../proto" }
ibc-telemetry = { version = "0.1.0", path = "../telemetry", optional = true }

anomaly = "0.2.0"
gumdrop = { version = "0.7", features = ["default_expr"] }
Expand Down
28 changes: 27 additions & 1 deletion relayer-cli/src/commands/start.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use abscissa_core::{Command, Options, Runnable};

use ibc_relayer::config::Config;
use ibc_relayer::supervisor::Supervisor;

use crate::conclude::Output;
Expand All @@ -11,10 +12,35 @@ pub struct StartCmd {}
impl Runnable for StartCmd {
fn run(&self) {
let config = app_config();
let supervisor = Supervisor::spawn(config.clone()).expect("failed to spawn supervisor");

let supervisor = spawn_supervisor(config.clone());
match supervisor.run() {
Ok(()) => Output::success_msg("done").exit(),
Err(e) => Output::error(e).exit(),
}
}
}

#[cfg(feature = "telemetry")]
fn spawn_supervisor(config: Config) -> Supervisor {
let state = ibc_telemetry::new_state();

if config.telemetry.enabled {
ibc_telemetry::spawn(config.telemetry.port, state.clone());
}

Supervisor::spawn(config, state)
}

#[cfg(not(feature = "telemetry"))]
fn spawn_supervisor(config: Config) -> Supervisor {
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."
);
}

let telemetry = ibc_relayer::telemetry::TelemetryDisabled;
Supervisor::spawn(config, telemetry)
}
6 changes: 4 additions & 2 deletions relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ description = """

[features]
profiling = []
telemetry = ["ibc-telemetry"]

[dependencies]
ibc = { version = "0.3.2", path = "../modules" }
ibc-proto = { version = "0.8.0", path = "../proto" }
ibc = { version = "0.3.2", path = "../modules" }
ibc-proto = { version = "0.8.0", path = "../proto" }
ibc-telemetry = { version = "0.1.0", path = "../telemetry", optional = true }

subtle-encoding = "0.5"
anomaly = "0.2.0"
Expand Down
51 changes: 33 additions & 18 deletions relayer/src/chain/handle.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
use std::fmt::Debug;
use std::sync::Arc;
use std::{
fmt::{self, Debug},
sync::Arc,
};

use crossbeam_channel as channel;
use dyn_clone::DynClone;
use serde::{Serialize, Serializer};

use ibc::ics02_client::client_consensus::{AnyConsensusState, AnyConsensusStateWithHeight};
use ibc::ics02_client::client_state::{AnyClientState, IdentifiedAnyClientState};
use ibc::ics02_client::events::UpdateClient;
use ibc::ics02_client::misbehaviour::AnyMisbehaviour;
use ibc::ics04_channel::channel::IdentifiedChannelEnd;
use ibc::query::QueryTxRequest;
use ibc::{
events::IbcEvent,
ics02_client::header::AnyHeader,
ics02_client::{
client_consensus::{AnyConsensusState, AnyConsensusStateWithHeight},
client_state::{AnyClientState, IdentifiedAnyClientState},
events::UpdateClient,
header::AnyHeader,
misbehaviour::AnyMisbehaviour,
},
ics03_connection::{connection::ConnectionEnd, version::Version},
ics04_channel::{
channel::ChannelEnd,
channel::{ChannelEnd, IdentifiedChannelEnd},
packet::{PacketMsgType, Sequence},
},
ics23_commitment::commitment::CommitmentPrefix,
ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, PortId},
proofs::Proofs,
query::QueryTxRequest,
signer::Signer,
Height,
};
use ibc_proto::ibc::core::channel::v1::{
PacketState, QueryChannelClientStateRequest, QueryChannelsRequest,
QueryConnectionChannelsRequest, QueryNextSequenceReceiveRequest,
QueryPacketAcknowledgementsRequest, QueryPacketCommitmentsRequest, QueryUnreceivedAcksRequest,
QueryUnreceivedPacketsRequest,

use ibc_proto::ibc::core::{
channel::v1::{
PacketState, QueryChannelClientStateRequest, QueryChannelsRequest,
QueryConnectionChannelsRequest, QueryNextSequenceReceiveRequest,
QueryPacketAcknowledgementsRequest, QueryPacketCommitmentsRequest,
QueryUnreceivedAcksRequest, QueryUnreceivedPacketsRequest,
},
client::v1::{QueryClientStatesRequest, QueryConsensusStatesRequest},
commitment::v1::MerkleProof,
connection::v1::QueryClientConnectionsRequest,
};
use ibc_proto::ibc::core::client::v1::{QueryClientStatesRequest, QueryConsensusStatesRequest};
use ibc_proto::ibc::core::commitment::v1::MerkleProof;
use ibc_proto::ibc::core::connection::v1::QueryClientConnectionsRequest;

pub use prod::ProdChainHandle;

Expand Down Expand Up @@ -63,6 +69,15 @@ impl ChainHandlePair {
}
}

impl Debug for ChainHandlePair {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ChainHandlePair")
.field("a", &self.a.id())
.field("b", &self.b.id())
.finish()
}
}

pub type Subscription = channel::Receiver<Arc<MonitorResult<EventBatch>>>;

pub type ReplyTo<T> = channel::Sender<Result<T, Error>>;
Expand Down
17 changes: 17 additions & 0 deletions relayer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ pub mod default {
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct Config {
pub global: GlobalConfig,
#[serde(default)]
pub telemetry: TelemetryConfig,
#[serde(default = "Vec::new", skip_serializing_if = "Vec::is_empty")]
pub chains: Vec<ChainConfig>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -102,6 +104,21 @@ impl Default for GlobalConfig {
}
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TelemetryConfig {
pub enabled: bool,
pub port: u16,
}

impl Default for TelemetryConfig {
fn default() -> Self {
Self {
enabled: false,
port: 3001,
}
}
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ChainConfig {
pub id: ChainId,
Expand Down
1 change: 1 addition & 0 deletions relayer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub mod macros;
pub mod object;
pub mod registry;
pub mod supervisor;
pub mod telemetry;
pub mod transfer;
pub mod upgrade_chain;
pub mod util;
Expand Down
Loading