Skip to content

Commit

Permalink
record error on span::error (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
ermalkaleci authored Nov 21, 2023
1 parent b732b66 commit d534226
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/extensions/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ impl Client {
}
Err(err) => {
span.set_status(opentelemetry::trace::Status::error(err.to_string()));
span.record_error(&err);
}
});

Expand Down Expand Up @@ -434,9 +435,8 @@ impl Client {
span.set_status(opentelemetry::trace::Status::Ok);
}
Err(err) => {
span.set_status(opentelemetry::trace::Status::Error {
description: std::borrow::Cow::from(err.to_string()),
});
span.set_status(opentelemetry::trace::Status::error(err.to_string()));
span.record_error(&err);
}
});

Expand Down
1 change: 1 addition & 0 deletions src/middlewares/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ impl<Request: Debug + Send + 'static, Result: Send + 'static> Middlewares<Reques
tracing::error!("middlewares timeout: {req}");
opentelemetry::trace::get_active_span(|span| {
span.set_status(opentelemetry::trace::Status::error("middlewares timeout"));
span.record_error(&jsonrpsee::core::Error::Custom("middlewares timeout".to_string()));
});
task_handle.abort();
}
Expand Down
2 changes: 2 additions & 0 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pub async fn build(config: Config) -> anyhow::Result<SubwayServerHandle> {
}
Err(err) => {
span.set_status(opentelemetry::trace::Status::error(err.to_string()));
span.record_error(&err);
}
});

Expand Down Expand Up @@ -168,6 +169,7 @@ pub async fn build(config: Config) -> anyhow::Result<SubwayServerHandle> {
}
Err(err) => {
span.set_status(opentelemetry::trace::Status::error(format!("{:?}", err)));
span.record_error(&jsonrpsee::core::Error::Custom(format!("{:?}", err)));
}
});

Expand Down

0 comments on commit d534226

Please sign in to comment.