Skip to content

Commit

Permalink
chore: log exception responses on error! level and simplify span
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Sep 8, 2023
1 parent a2fee50 commit bdbe283
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 39 deletions.
17 changes: 9 additions & 8 deletions abci/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ impl<A: Application> RequestDispatcher for A {
fn handle(&self, request: abci::Request) -> Option<abci::Response> {
#[cfg(feature = "tracing-span")]
let _span = super::tracing_span::span(request.clone().value?);
tracing::trace!(?request, "received request");
tracing::trace!(?request, "received ABCI request");

let response: Result<response::Value, abci::ResponseException> = match request.value? {
let response: response::Value = match request.value? {
request::Value::Echo(req) => self.echo(req).map(|v| v.into()),
request::Value::Flush(req) => self.flush(req).map(|v| v.into()),
request::Value::Info(req) => self.info(req).map(|v| v.into()),
Expand All @@ -176,15 +176,16 @@ impl<A: Application> RequestDispatcher for A {
request::Value::VerifyVoteExtension(req) => {
self.verify_vote_extension(req).map(|v| v.into())
},
};
}
.unwrap_or_else(|e| e.into());

let response = match response {
Ok(v) => v,
Err(e) => response::Value::from(e),
// TODO: errors as err
if let response::Value::Exception(ref exception) = response {
tracing::error!(response=?exception, "sending ABCI exception");
} else {
tracing::trace!(?response, "sending ABCI response");
};

tracing::trace!(?response, "sending response");

Some(abci::Response {
value: Some(response),
})
Expand Down
38 changes: 7 additions & 31 deletions abci/src/tracing_span.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use hex::ToHex;
use tenderdash_proto::abci::request::Value;
use tracing::Level;
pub(super) fn span<T>(request: T) -> tracing::span::EnteredSpan

pub fn span<T>(request: T) -> tracing::span::EnteredSpan
where
T: Into<Value>,
{
Expand All @@ -12,23 +12,9 @@ where
let request_id = uuid::Uuid::new_v4().to_string();

let span = match value {
Value::Info(r) => tracing::span!(
LEVEL,
SPAN_NAME,
endpoint,
request_id,
tenderdash_version = r.version,
block_version = r.block_version,
p2p_version = r.p2p_version,
),
Value::InitChain(r) => {
tracing::span!(
LEVEL,
SPAN_NAME,
endpoint,
request_id,
chain_id = r.chain_id
)
Value::Info(_r) => tracing::span!(LEVEL, SPAN_NAME, endpoint, request_id),
Value::InitChain(_r) => {
tracing::span!(LEVEL, SPAN_NAME, endpoint, request_id)
},
Value::PrepareProposal(r) => {
tracing::span!(
Expand All @@ -38,8 +24,6 @@ where
request_id,
height = r.height,
round = r.round,
quorum_hash = r.quorum_hash.encode_hex::<String>(),
core_locked_height = r.core_chain_locked_height,
)
},
Value::ProcessProposal(r) => tracing::span!(
Expand All @@ -49,8 +33,6 @@ where
request_id,
height = r.height,
round = r.round,
quorum_hash = r.quorum_hash.encode_hex::<String>(),
core_locked_height = r.core_chain_locked_height,
),
Value::ExtendVote(r) => {
tracing::span!(
Expand Down Expand Up @@ -82,14 +64,8 @@ where
round = r.round
)
},
Value::CheckTx(r) => {
tracing::span!(
LEVEL,
SPAN_NAME,
endpoint,
request_id,
tx = r.tx.encode_hex::<String>()
)
Value::CheckTx(_r) => {
tracing::span!(LEVEL, SPAN_NAME, endpoint, request_id)
},
Value::Query(r) => {
tracing::span!(LEVEL, SPAN_NAME, endpoint, request_id, path = r.path)
Expand Down

0 comments on commit bdbe283

Please sign in to comment.