rpc/rpc_helper.rs: Ported to opentelemetry 0.18.

This commit is contained in:
Jonathan Davies 2023-01-27 16:45:52 +00:00
parent 3131052678
commit 0a3d332966

View file

@ -136,7 +136,10 @@ impl RpcHelper {
KeyValue::new("to", format!("{:?}", to)), KeyValue::new("to", format!("{:?}", to)),
]; ];
self.0.metrics.rpc_counter.add(1, &metric_tags); self.0
.metrics
.rpc_counter
.add(&Context::current(), 1, &metric_tags);
let node_id = to.into(); let node_id = to.into();
let rpc_call = endpoint let rpc_call = endpoint
@ -154,18 +157,18 @@ impl RpcHelper {
select! { select! {
res = rpc_call => { res = rpc_call => {
if res.is_err() { if res.is_err() {
self.0.metrics.rpc_netapp_error_counter.add(1, &metric_tags); self.0.metrics.rpc_netapp_error_counter.add(&Context::current(), 1, &metric_tags);
} }
let res = res?.into_msg(); let res = res?.into_msg();
if res.is_err() { if res.is_err() {
self.0.metrics.rpc_garage_error_counter.add(1, &metric_tags); self.0.metrics.rpc_garage_error_counter.add(&Context::current(), 1, &metric_tags);
} }
Ok(res?) Ok(res?)
} }
() = timeout => { () = timeout => {
self.0.metrics.rpc_timeout_counter.add(1, &metric_tags); self.0.metrics.rpc_timeout_counter.add(&Context::current(), 1, &metric_tags);
Err(Error::Timeout) Err(Error::Timeout)
} }
} }