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

Clean up and improve logs #2544

Merged
merged 35 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
32cf498
Instrument more functions using `tracing`
romac Aug 9, 2022
db00740
Use error level everywhere
romac Aug 10, 2022
267a30c
Bit more cleanup
romac Aug 10, 2022
6e9061e
Instrument more functions under the `chain::cosmos` module
romac Aug 10, 2022
080d863
Merge branch 'master' into romac/cleanup-logs
romac Aug 10, 2022
d781630
Removed debug log which outputs the options passed to CLIs
ljoss17 Aug 11, 2022
759c6ac
Cleanup imports
romac Aug 11, 2022
b8f9b5b
Remove `Serialize` bound on `ChainHandle`
romac Aug 11, 2022
df1055a
Remove `Serialize` instances on `ChainHandle` imps
romac Aug 11, 2022
f38dcd2
Preserve current tracing span across the runtime boundary
romac Aug 11, 2022
dae97a9
Remove ad-hoc Display and Debug impl for client and channel events
romac Aug 11, 2022
efbbb40
Improve spawning logs
romac Aug 11, 2022
2e5cec3
Better span for some workers
romac Aug 11, 2022
06a9c54
Extract telemetry code into its own function
romac Aug 11, 2022
4ed6a4e
Few more improvements
romac Aug 11, 2022
75cb215
Tighter Display impl for account-related newtypes
romac Aug 11, 2022
6bfc72b
Add `Display` impl for `version::Specs`
romac Aug 11, 2022
d611f24
Fix clippy warning
romac Aug 11, 2022
ea9a6aa
Cleanup `From` instace for `PathIdentifiers`
romac Aug 11, 2022
a0c7b49
Merge branch 'master' into romac/cleanup-logs
ljoss17 Aug 16, 2022
a528046
Fixed bugs from merge. Clippy and cargo fmt
ljoss17 Aug 16, 2022
3034db8
Emit JSON to stdout
romac Aug 16, 2022
157db23
More instrumentation in `relay_path`
romac Aug 17, 2022
a0971c9
replaced {:#?} by {:?}
Aug 18, 2022
e17b0b7
Updated metrics for events and added comment for method recording met…
ljoss17 Aug 22, 2022
82acba0
Replace all the Debug with Display fmt for 'info!', 'warn!' and 'erro…
ljoss17 Aug 24, 2022
0ed9e6e
Merge branch 'master' into romac/cleanup-logs
ljoss17 Aug 24, 2022
8eabb06
Fixed issues following merge with master. Added comment
ljoss17 Aug 24, 2022
f47801d
Updated std::time to core::time in modules pretty.rs file
ljoss17 Aug 24, 2022
ab72083
Removed line returns in info logs
ljoss17 Aug 25, 2022
8450bf1
Merge branch 'master' into romac/cleanup-logs
ljoss17 Aug 31, 2022
bdb3ac2
Merge branch 'master' into romac/cleanup-logs
ljoss17 Sep 1, 2022
0cfbb10
Merge branch 'master' into romac/cleanup-logs
romac Sep 7, 2022
e2f3117
Add changelog entry
romac Sep 7, 2022
5b1a28d
Merge branch 'master' into romac/cleanup-logs
romac Sep 7, 2022
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
30 changes: 1 addition & 29 deletions modules/src/core/ics02_client/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,6 @@ impl From<Attributes> for Vec<Tag> {
}
}

impl core::fmt::Display for Attributes {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(
f,
"h: {}, cs_h: {}({})",
self.height, self.client_id, self.consensus_height
)
}
}

/// CreateClient event signals the creation of a new on-chain client (IBC client).
#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
pub struct CreateClient(pub Attributes);
Expand Down Expand Up @@ -148,14 +138,8 @@ impl From<CreateClient> for AbciEvent {
}
}

impl core::fmt::Display for CreateClient {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(f, "{}", self.0)
}
}

/// UpdateClient event signals a recent update of an on-chain client (IBC Client).
#[derive(Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct UpdateClient {
pub common: Attributes,
pub header: Option<AnyHeader>,
Expand Down Expand Up @@ -215,18 +199,6 @@ impl From<UpdateClient> for AbciEvent {
}
}

impl core::fmt::Display for UpdateClient {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(f, "{}", self.common)
}
}

impl core::fmt::Debug for UpdateClient {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.common)
}
}

/// ClientMisbehaviour event signals the update of an on-chain client (IBC Client) with evidence of
/// misbehaviour.
#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
Expand Down
10 changes: 5 additions & 5 deletions modules/src/core/ics03_connection/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub const CLIENT_ID_ATTRIBUTE_KEY: &str = "client_id";
pub const COUNTERPARTY_CONN_ID_ATTRIBUTE_KEY: &str = "counterparty_connection_id";
pub const COUNTERPARTY_CLIENT_ID_ATTRIBUTE_KEY: &str = "counterparty_client_id";

#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)]
pub struct Attributes {
pub height: Height,
pub connection_id: Option<ConnectionId>,
Expand Down Expand Up @@ -81,7 +81,7 @@ impl From<Attributes> for Vec<Tag> {
}
}

#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct OpenInit(Attributes);

impl OpenInit {
Expand Down Expand Up @@ -121,7 +121,7 @@ impl From<OpenInit> for AbciEvent {
}
}

#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct OpenTry(Attributes);

impl OpenTry {
Expand Down Expand Up @@ -161,7 +161,7 @@ impl From<OpenTry> for AbciEvent {
}
}

#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct OpenAck(Attributes);

impl OpenAck {
Expand Down Expand Up @@ -201,7 +201,7 @@ impl From<OpenAck> for AbciEvent {
}
}

#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct OpenConfirm(Attributes);

impl OpenConfirm {
Expand Down
104 changes: 13 additions & 91 deletions modules/src/core/ics04_channel/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub const PKT_TIMEOUT_HEIGHT_ATTRIBUTE_KEY: &str = "packet_timeout_height";
pub const PKT_TIMEOUT_TIMESTAMP_ATTRIBUTE_KEY: &str = "packet_timeout_timestamp";
pub const PKT_ACK_ATTRIBUTE_KEY: &str = "packet_ack";

#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)]
pub struct Attributes {
pub height: Height,
pub port_id: PortId,
Expand Down Expand Up @@ -183,7 +183,7 @@ pub trait EventType {
fn event_type() -> IbcEventType;
}

#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct OpenInit {
pub height: Height,
pub port_id: PortId,
Expand Down Expand Up @@ -233,7 +233,7 @@ impl EventType for OpenInit {
}
}

#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct OpenTry {
pub height: Height,
pub port_id: PortId,
Expand Down Expand Up @@ -282,7 +282,7 @@ impl EventType for OpenTry {
}
}

#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct OpenAck {
pub height: Height,
pub port_id: PortId,
Expand Down Expand Up @@ -336,7 +336,7 @@ impl EventType for OpenAck {
}
}

#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct OpenConfirm {
pub height: Height,
pub port_id: PortId,
Expand Down Expand Up @@ -386,7 +386,7 @@ impl EventType for OpenConfirm {
}
}

#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct CloseInit {
pub height: Height,
pub port_id: PortId,
Expand Down Expand Up @@ -459,25 +459,13 @@ impl From<CloseInit> for IbcEvent {
}
}

impl core::fmt::Display for CloseInit {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(
f,
"{} {} {:?}",
self.height(),
IbcEventType::CloseInitChannel.as_str(),
Attributes::from(self.clone())
)
}
}

impl EventType for CloseInit {
fn event_type() -> IbcEventType {
IbcEventType::CloseInitChannel
}
}

#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct CloseConfirm {
pub height: Height,
pub channel_id: Option<ChannelId>,
Expand Down Expand Up @@ -569,7 +557,7 @@ impl_from_ibc_to_abci_event!(
CloseConfirm
);

#[derive(Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct SendPacket {
pub height: Height,
pub packet: Packet,
Expand Down Expand Up @@ -614,19 +602,7 @@ impl TryFrom<SendPacket> for AbciEvent {
}
}

impl core::fmt::Display for SendPacket {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(f, "SendPacket - h:{}, {}", self.height, self.packet)
}
}

impl core::fmt::Debug for SendPacket {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "SendPacket - h:{}, {}", self.height, self.packet)
}
}

#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct ReceivePacket {
pub height: Height,
pub packet: Packet,
Expand Down Expand Up @@ -671,13 +647,7 @@ impl TryFrom<ReceivePacket> for AbciEvent {
}
}

impl core::fmt::Display for ReceivePacket {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(f, "ReceivePacket - h:{}, {}", self.height, self.packet)
}
}

#[derive(Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct WriteAcknowledgement {
pub height: Height,
pub packet: Packet,
Expand Down Expand Up @@ -732,27 +702,7 @@ impl TryFrom<WriteAcknowledgement> for AbciEvent {
}
}

impl core::fmt::Display for WriteAcknowledgement {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(
f,
"WriteAcknowledgement - h:{}, {}",
self.height, self.packet
)
}
}

impl core::fmt::Debug for WriteAcknowledgement {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(
f,
"WriteAcknowledgement - h:{}, {}",
self.height, self.packet
)
}
}

#[derive(Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct AcknowledgePacket {
pub height: Height,
pub packet: Packet,
Expand Down Expand Up @@ -791,19 +741,7 @@ impl TryFrom<AcknowledgePacket> for AbciEvent {
}
}

impl core::fmt::Display for AcknowledgePacket {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(f, "h:{}, {}", self.height, self.packet)
}
}

impl core::fmt::Debug for AcknowledgePacket {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "AcknowledgePacket - h:{}, {}", self.height, self.packet)
}
}

#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct TimeoutPacket {
pub height: Height,
pub packet: Packet,
Expand Down Expand Up @@ -848,13 +786,7 @@ impl TryFrom<TimeoutPacket> for AbciEvent {
}
}

impl core::fmt::Display for TimeoutPacket {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(f, "TimeoutPacket - h:{}, {}", self.height, self.packet)
}
}

#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct TimeoutOnClosePacket {
pub height: Height,
pub packet: Packet,
Expand Down Expand Up @@ -898,13 +830,3 @@ impl TryFrom<TimeoutOnClosePacket> for AbciEvent {
})
}
}

impl core::fmt::Display for TimeoutOnClosePacket {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(
f,
"TimeoutOnClosePacket - h:{}, {}",
self.height, self.packet
)
}
}
54 changes: 27 additions & 27 deletions modules/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,33 +264,33 @@ impl fmt::Display for IbcEvent {
match self {
IbcEvent::NewBlock(ev) => write!(f, "NewBlock({})", ev.height),

IbcEvent::CreateClient(ev) => write!(f, "CreateClientEv({})", ev),
IbcEvent::UpdateClient(ev) => write!(f, "UpdateClientEv({})", ev),
IbcEvent::UpgradeClient(ev) => write!(f, "UpgradeClientEv({:?})", ev),
IbcEvent::ClientMisbehaviour(ev) => write!(f, "ClientMisbehaviourEv({:?})", ev),

IbcEvent::OpenInitConnection(ev) => write!(f, "OpenInitConnectionEv({:?})", ev),
IbcEvent::OpenTryConnection(ev) => write!(f, "OpenTryConnectionEv({:?})", ev),
IbcEvent::OpenAckConnection(ev) => write!(f, "OpenAckConnectionEv({:?})", ev),
IbcEvent::OpenConfirmConnection(ev) => write!(f, "OpenConfirmConnectionEv({:?})", ev),

IbcEvent::OpenInitChannel(ev) => write!(f, "OpenInitChannelEv({:?})", ev),
IbcEvent::OpenTryChannel(ev) => write!(f, "OpenTryChannelEv({:?})", ev),
IbcEvent::OpenAckChannel(ev) => write!(f, "OpenAckChannelEv({:?})", ev),
IbcEvent::OpenConfirmChannel(ev) => write!(f, "OpenConfirmChannelEv({:?})", ev),
IbcEvent::CloseInitChannel(ev) => write!(f, "CloseInitChannelEv({})", ev),
IbcEvent::CloseConfirmChannel(ev) => write!(f, "CloseConfirmChannelEv({:?})", ev),

IbcEvent::SendPacket(ev) => write!(f, "SendPacketEv({})", ev),
IbcEvent::ReceivePacket(ev) => write!(f, "ReceivePacketEv({})", ev),
IbcEvent::WriteAcknowledgement(ev) => write!(f, "WriteAcknowledgementEv({})", ev),
IbcEvent::AcknowledgePacket(ev) => write!(f, "AcknowledgePacketEv({})", ev),
IbcEvent::TimeoutPacket(ev) => write!(f, "TimeoutPacketEv({})", ev),
IbcEvent::TimeoutOnClosePacket(ev) => write!(f, "TimeoutOnClosePacketEv({})", ev),

IbcEvent::AppModule(ev) => write!(f, "AppModuleEv({:?})", ev),

IbcEvent::ChainError(ev) => write!(f, "ChainErrorEv({})", ev),
IbcEvent::CreateClient(ev) => write!(f, "CreateClient({:?})", ev),
IbcEvent::UpdateClient(ev) => write!(f, "UpdateClient({:?})", ev),
IbcEvent::UpgradeClient(ev) => write!(f, "UpgradeClient({:?})", ev),
IbcEvent::ClientMisbehaviour(ev) => write!(f, "ClientMisbehaviour({:?})", ev),

IbcEvent::OpenInitConnection(ev) => write!(f, "OpenInitConnection({:?})", ev),
IbcEvent::OpenTryConnection(ev) => write!(f, "OpenTryConnection({:?})", ev),
IbcEvent::OpenAckConnection(ev) => write!(f, "OpenAckConnection({:?})", ev),
IbcEvent::OpenConfirmConnection(ev) => write!(f, "OpenConfirmConnection({:?})", ev),

IbcEvent::OpenInitChannel(ev) => write!(f, "OpenInitChannel({:?})", ev),
IbcEvent::OpenTryChannel(ev) => write!(f, "OpenTryChannel({:?})", ev),
IbcEvent::OpenAckChannel(ev) => write!(f, "OpenAckChannel({:?})", ev),
IbcEvent::OpenConfirmChannel(ev) => write!(f, "OpenConfirmChannel({:?})", ev),
IbcEvent::CloseInitChannel(ev) => write!(f, "CloseInitChannel({:?})", ev),
IbcEvent::CloseConfirmChannel(ev) => write!(f, "CloseConfirmChannel({:?})", ev),

IbcEvent::SendPacket(ev) => write!(f, "SendPacket({:?})", ev),
IbcEvent::ReceivePacket(ev) => write!(f, "ReceivePacket({:?})", ev),
IbcEvent::WriteAcknowledgement(ev) => write!(f, "WriteAcknowledgement({:?})", ev),
IbcEvent::AcknowledgePacket(ev) => write!(f, "AcknowledgePacket({:?})", ev),
IbcEvent::TimeoutPacket(ev) => write!(f, "TimeoutPacket({:?})", ev),
IbcEvent::TimeoutOnClosePacket(ev) => write!(f, "TimeoutOnClosePacket({:?})", ev),

IbcEvent::AppModule(ev) => write!(f, "AppModule({:?})", ev),

IbcEvent::ChainError(ev) => write!(f, "ChainError({})", ev),
}
}
}
Expand Down
14 changes: 6 additions & 8 deletions relayer-cli/src/commands/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,21 @@ impl Runnable for HealthCheckCmd {
let config = (*app_config()).clone();

for ch in &config.chains {
info!("[{}] performing health check...", ch.id);
let _span = tracing::error_span!("health_check", chain = %ch.id).entered();

info!("performing health check...");

let chain =
spawn_chain_runtime(&config, &ch.id).unwrap_or_else(exit_with_unrecoverable_error);

match chain.health_check() {
Ok(Healthy) => info!(chain = %ch.id, "chain is healthy"),
Ok(Healthy) => info!("chain is healthy"),
Ok(Unhealthy(_)) => {
// No need to print the error here as it's already printed in `Chain::health_check`
// TODO(romac): Move the printing code here and in the supervisor/registry
warn!("[{}] chain is unhealthy", ch.id)
warn!("chain is not healthy")
}
Err(e) => error!(
"[{}] failed to perform health check, reason: {}",
ch.id,
e.detail()
),
Err(e) => error!("failed to perform health check, reason: {}", e.detail()),
}
}

Expand Down
Loading