state: add span to state service

Here the span is added to the body of the `Service::call`
implementation, not to the futures it returns, because the state service
does all of the work synchronously in `call` rather than in the futures
it returns.

The service is skipped as a span field.  We could either include or
exclude the request itself.  It would be useful, but the request body
can be very large.  Instead, we make two spans, one at info level and
one at trace level, and filter that way.
This commit is contained in:
Henry de Valence 2020-11-20 12:43:50 -08:00 committed by Deirdre Connolly
parent 04acc9da6c
commit 3bfe63e38f
1 changed files with 7 additions and 0 deletions

View File

@ -383,6 +383,13 @@ impl Service<Request> for StateService {
Poll::Ready(Ok(()))
}
// Because the request might have a verbose debug output (e.g.,
// an entire block), include it only in a second trace-level span.
// For some reason putting them in this order causes the info-level
// span to be entered first.
#[allow(unused_braces)] // fixes a spurious warning from the proc macro
#[instrument(name = "state_trace", level = "trace", skip(self))]
#[instrument(name = "state", level = "info", skip(self, req))]
fn call(&mut self, req: Request) -> Self::Future {
match req {
Request::CommitBlock { block } => {