Skip to content

Commit 29b87f1

Browse files
authored
fix(uptime): better vector error messages (#486)
1 parent d3694bb commit 29b87f1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/producer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pub enum ExtractCodeError {
1717
Producer(#[from] ProducerError),
1818
#[error(transparent)]
1919
Schema(#[from] SchemaError),
20-
#[error("Vector request failed")]
21-
VectorError,
20+
#[error("Vector request failed: {msg}")]
21+
VectorError { msg: String },
2222
}
2323

2424
pub trait ResultsProducer: Send + Sync {

src/producer/vector_producer.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl VectorResultsProducer {
9898
metrics::histogram!("vector_producer.send_batch.duration", "uptime_region" => region, "histogram" => "timer").record(start.elapsed().as_secs_f64());
9999
result
100100
} {
101-
tracing::error!(error = ?e, "vector_batch.send_failed");
101+
tracing::error!(error = %e, "vector_batch.send_failed");
102102
}
103103
}
104104

@@ -112,7 +112,7 @@ impl VectorResultsProducer {
112112
)
113113
.await
114114
{
115-
tracing::error!(error = ?e, "final_batch.send_failed");
115+
tracing::error!(error = %e, "final_batch.send_failed");
116116
}
117117
}
118118

@@ -129,7 +129,9 @@ impl ResultsProducer for VectorResultsProducer {
129129
// Send the serialized result to the worker task
130130
if self.sender.send(json).is_err() {
131131
tracing::error!("event.send_failed_channel_closed");
132-
return Err(ExtractCodeError::VectorError);
132+
return Err(ExtractCodeError::VectorError {
133+
msg: "send failed channel closed".to_owned(),
134+
});
133135
}
134136
self.pending_items
135137
.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
@@ -165,7 +167,7 @@ async fn send_batch(
165167
.header("Content-Type", "application/json")
166168
.body(body.clone())
167169
.build()
168-
.map_err(|_e| ExtractCodeError::VectorError)?;
170+
.map_err(|e| ExtractCodeError::VectorError { msg: e.to_string() })?;
169171
let req_id = req.req_id().clone();
170172
let response = client.execute(req).await;
171173
let stats = hyper::stats::consume_request_stats(req_id);
@@ -221,7 +223,9 @@ async fn send_batch(
221223
}
222224
}
223225
if !retry_vector_errors_forever {
224-
return Err(ExtractCodeError::VectorError);
226+
return Err(ExtractCodeError::VectorError {
227+
msg: "retries exhausted".to_owned(),
228+
});
225229
}
226230
sleep(delay).await;
227231
}

0 commit comments

Comments
 (0)