Skip to content

Commit d8f2f80

Browse files
committed
fix: example return instead of panic on posined lock
1 parent 79270ce commit d8f2f80

File tree

1 file changed

+6
-2
lines changed
  • examples/tracing-http-propagator/src

1 file changed

+6
-2
lines changed

examples/tracing-http-propagator/src/server.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ impl SpanProcessor for RouteConcurrencyCounterSpanProcessor {
136136
else {
137137
return;
138138
};
139-
let mut counts = self.0.lock().unwrap();
139+
let Ok(mut counts) = self.0.lock() else {
140+
return;
141+
};
140142
let count = counts.entry(route.key.clone()).or_default();
141143
*count += 1;
142144
span.set_attribute(KeyValue::new(
@@ -156,7 +158,9 @@ impl SpanProcessor for RouteConcurrencyCounterSpanProcessor {
156158
else {
157159
return;
158160
};
159-
let mut counts = self.0.lock().unwrap();
161+
let Ok(mut counts) = self.0.lock() else {
162+
return;
163+
};
160164
let Some(count) = counts.get_mut(&route.key) else {
161165
return;
162166
};

0 commit comments

Comments
 (0)