Skip to content

Commit

Permalink
Merge pull request vectordotdev#260 from answerbook/mdeltito/LOG-16417
Browse files Browse the repository at this point in the history
fix(user_trace): format expected error type in batch service
  • Loading branch information
mdeltito authored May 15, 2023
2 parents d4510c0 + d378080 commit 678e68c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/mezmo/user_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use futures_util::future::BoxFuture;
use futures_util::{future::ready, Stream, StreamExt};
use once_cell::sync::OnceCell;
use std::future::Future;
use std::ops::Deref;
use std::task::{Context, Poll};
use tokio::sync::broadcast::{self, Receiver, Sender};
use tokio_stream::wrappers::BroadcastStream;
Expand All @@ -13,6 +14,7 @@ use value::Value;
use vector_core::event::metric::mezmo::TransformError;
use vector_core::{event::LogEvent, ByteSizeOf};

use crate::http::HttpError;
use crate::sinks::util::http::HttpBatchService;

static USER_LOG_SENDER: OnceCell<Sender<LogEvent>> = OnceCell::new();
Expand Down Expand Up @@ -198,10 +200,15 @@ where
ctx.error(msg);
}
}
Err(err) => {
let msg = Value::from(format!("{err:?}"));
ctx.error(msg);
}
Err(err) => match err.deref().downcast_ref::<HttpError>() {
Some(err) => {
ctx.error(Value::from(format!("{err}")));
}
None => {
warn!(message = "Unable to format service error for user logs", %err);
ctx.error(Value::from("Request failed".to_string()));
}
},
}
res
})
Expand Down

0 comments on commit 678e68c

Please sign in to comment.