From 109d6c143d01b2d59027d45738692fa8ef6253ee Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 18 Feb 2022 20:23:10 +0100 Subject: [PATCH] Add length of query to span --- src/client.rs | 8 ++++++-- src/server.rs | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client.rs b/src/client.rs index e08b30b..d6caf68 100644 --- a/src/client.rs +++ b/src/client.rs @@ -14,7 +14,7 @@ use tokio_util::compat::*; #[cfg(feature = "telemetry")] use opentelemetry::{ trace::{FutureExt, Span, SpanKind, TraceContextExt, Tracer}, - Context, + Context, KeyValue, }; #[cfg(feature = "telemetry")] use opentelemetry_contrib::trace::propagator::binary::*; @@ -136,7 +136,7 @@ impl ClientConn { cfg_if::cfg_if! { if #[cfg(feature = "telemetry")] { let tracer = opentelemetry::global::tracer("netapp"); - let span = tracer.span_builder(format!("RPC >> {}", path)) + let mut span = tracer.span_builder(format!("RPC >> {}", path)) .with_kind(SpanKind::Server) .start(&tracer); let propagator = BinaryPropagator::new(); @@ -174,6 +174,10 @@ impl ClientConn { } trace!("request: query_send {}, {} bytes", id, bytes.len()); + + #[cfg(feature = "telemetry")] + span.set_attribute(KeyValue::new("len_query", bytes.len() as i64)); + query_send.send((id, prio, bytes))?; cfg_if::cfg_if! { diff --git a/src/server.rs b/src/server.rs index 8b60e17..7bf17df 100644 --- a/src/server.rs +++ b/src/server.rs @@ -161,6 +161,7 @@ impl ServerConn { .start(&tracer) }; span.set_attribute(KeyValue::new("path", path.to_string())); + span.set_attribute(KeyValue::new("len_query", data.len() as i64)); handler.handle(data, self.peer_id) .with_context(Context::current_with_span(span))