Skip to content

Commit e64164e

Browse files
committed
Use more let-else
1 parent 7edc597 commit e64164e

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

bottlecap/src/otlp/agent.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ impl Agent {
195195
Err(err) => {
196196
error!("OTLP | Error sending traces to the trace flusher: {err}");
197197
(
198-
StatusCode::INTERNAL_SERVER_ERROR,
199-
json!({ "message": format!("Error sending traces to the trace flusher: {err}") }).to_string()
200-
).into_response()
198+
StatusCode::INTERNAL_SERVER_ERROR,
199+
json!({ "message": format!("Error sending traces to the trace flusher: {err}") }).to_string()
200+
).into_response()
201201
}
202202
}
203203
}

bottlecap/src/traces/stats_flusher.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,25 +102,24 @@ impl StatsFlusher for ServerlessStatsFlusher {
102102

103103
let start = std::time::Instant::now();
104104

105-
if let Some(api_key) = self.api_key_factory.get_api_key().await {
106-
let resp =
107-
stats_utils::send_stats_payload(serialized_stats_payload, endpoint, api_key).await;
108-
let elapsed = start.elapsed();
109-
debug!(
110-
"Stats request to {} took {}ms",
111-
stats_url,
112-
elapsed.as_millis()
113-
);
114-
match resp {
115-
Ok(()) => debug!("Successfully flushed stats"),
116-
Err(e) => {
117-
error!("Error sending stats: {e:?}");
118-
}
119-
};
120-
} else {
105+
let Some(api_key) = self.api_key_factory.get_api_key().await else {
121106
error!("Failed to resolve API key");
122107
return;
123-
}
108+
};
109+
let resp =
110+
stats_utils::send_stats_payload(serialized_stats_payload, endpoint, api_key).await;
111+
let elapsed = start.elapsed();
112+
debug!(
113+
"Stats request to {} took {}ms",
114+
stats_url,
115+
elapsed.as_millis()
116+
);
117+
match resp {
118+
Ok(()) => debug!("Successfully flushed stats"),
119+
Err(e) => {
120+
error!("Error sending stats: {e:?}");
121+
}
122+
};
124123
}
125124

126125
async fn flush(&self) {

bottlecap/src/traces/trace_processor.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ impl TraceProcessor for ServerlessTraceProcessor {
162162
tracer_payload.tags.extend(tags.clone());
163163
}
164164
}
165-
166165
let Some(api_key) = self.api_key_factory.get_api_key().await else {
167166
error!("Error processing traces: failed to resolve API key");
168167
return None;

0 commit comments

Comments
 (0)