Skip to content

Commit 4ac85f6

Browse files
committed
More cleanup
1 parent a9cc4a2 commit 4ac85f6

File tree

10 files changed

+212
-287
lines changed

10 files changed

+212
-287
lines changed

client/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,15 @@ impl<T> RequestExt for tonic::Request<T> {
16731673
}
16741674
}
16751675

1676+
macro_rules! dbg_panic {
1677+
($($arg:tt)*) => {
1678+
use tracing::error;
1679+
error!($($arg)*);
1680+
debug_assert!(false, $($arg)*);
1681+
};
1682+
}
1683+
pub(crate) use dbg_panic;
1684+
16761685
#[cfg(test)]
16771686
mod tests {
16781687
use super::*;

client/src/metrics.rs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{AttachMetricLabels, CallType};
1+
use crate::{AttachMetricLabels, CallType, dbg_panic};
22
use futures_util::{FutureExt, future::BoxFuture};
33
use std::{
44
sync::Arc,
@@ -89,27 +89,32 @@ impl MetricsContext {
8989
.meter
9090
.extend_attributes(self.kvs.clone(), new_kvs.into());
9191

92-
// TODO: elses
93-
if let Ok(v) = self.instruments.svc_request.with_attributes(&self.kvs) {
94-
self.instruments.svc_request = v;
95-
}
96-
if let Ok(v) = self.instruments.long_svc_request.with_attributes(&self.kvs) {
97-
self.instruments.long_svc_request = v;
98-
}
99-
if let Ok(v) = self
100-
.instruments
101-
.svc_request_latency
102-
.with_attributes(&self.kvs)
103-
{
104-
self.instruments.svc_request_latency = v;
105-
}
106-
if let Ok(v) = self
92+
let _ = self
10793
.instruments
108-
.long_svc_request_latency
94+
.svc_request
10995
.with_attributes(&self.kvs)
110-
{
111-
self.instruments.long_svc_request_latency = v;
112-
}
96+
.and_then(|v| {
97+
self.instruments.svc_request = v;
98+
self.instruments.long_svc_request.with_attributes(&self.kvs)
99+
})
100+
.and_then(|v| {
101+
self.instruments.long_svc_request = v;
102+
self.instruments
103+
.svc_request_latency
104+
.with_attributes(&self.kvs)
105+
})
106+
.and_then(|v| {
107+
self.instruments.svc_request_latency = v;
108+
self.instruments
109+
.long_svc_request_latency
110+
.with_attributes(&self.kvs)
111+
})
112+
.map(|v| {
113+
self.instruments.long_svc_request_latency = v;
114+
})
115+
.inspect_err(|e| {
116+
dbg_panic!("Failed to extend client metrics attributes: {:?}", e);
117+
});
113118
}
114119

115120
pub(crate) fn set_is_long_poll(&mut self) {

core-api/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ categories = ["development-tools"]
1515
[features]
1616
otel_impls = ["dep:opentelemetry"]
1717
envconfig = ["dep:toml", "dep:serde", "dep:dirs"]
18-
prom_impls = ["dep:prometheus"]
1918

2019
[dependencies]
2120
async-trait = "0.1"
2221
dirs = { version = "5.0", optional = true }
2322
derive_builder = { workspace = true }
2423
derive_more = { workspace = true }
2524
opentelemetry = { workspace = true, optional = true }
26-
prometheus = { version = "0.14", optional = true }
2725
prost = { workspace = true }
2826
serde = { version = "1.0", features = ["derive"], optional = true }
2927
serde_json = "1.0"

core-api/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ pub trait Worker: Send + Sync {
141141

142142
macro_rules! dbg_panic {
143143
($($arg:tt)*) => {
144+
use tracing::error;
144145
error!($($arg)*);
145146
debug_assert!(false, $($arg)*);
146147
};

0 commit comments

Comments
 (0)