-
Notifications
You must be signed in to change notification settings - Fork 1.9k
enhancement(datadog_agent source): Add request timeout support #24245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3a507ef
Add error type for source sender timeout error
bruceg 2e9b406
Add common internal event for timed out events
bruceg bfda09b
Add timeout support to `SourceSender`
bruceg 0148b87
Add timeout support to `trait SourceConfig`
bruceg 1c91240
Add timeout support to `datadog_agent` source
bruceg aedab4e
Rewrite ComponentEventsTimedOut with `registered_event!`
bruceg e085ee6
Expanded docs
bruceg 27adc78
Fix `SourceSender` not handling timeout on batch sends
bruceg 3f4e5b1
Fix type of timeout config parameter
bruceg d9d7b49
Update docs
bruceg ce952b2
Rename `timedout` to `timed_out`
bruceg 9ad505e
Update changelog
bruceg 4d78b40
Fix changelog
bruceg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Added support for configurable request timeouts to the `datadog_agent` source. | ||
|
|
||
| This change also introduces two new internal metrics: | ||
| - `component_timed_out_events_total` - Counter tracking the number of events that timed out | ||
| - `component_timed_out_requests_total` - Counter tracking the number of requests that timed out | ||
|
|
||
| authors: bruceg | ||
23 changes: 23 additions & 0 deletions
23
lib/vector-common/src/internal_event/component_events_timed_out.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| use metrics::{Counter, counter}; | ||
|
|
||
| use super::Count; | ||
|
|
||
| crate::registered_event! { | ||
| ComponentEventsTimedOut { | ||
| reason: &'static str, | ||
| } => { | ||
| timed_out_events: Counter = counter!("component_timed_out_events_total"), | ||
| timed_out_requests: Counter = counter!("component_timed_out_requests_total"), | ||
| reason: &'static str = self.reason, | ||
| } | ||
|
|
||
| fn emit(&self, data: Count) { | ||
| warn!( | ||
| message = "Events timed out", | ||
| events = data.0, | ||
| reason = self.reason, | ||
| ); | ||
| self.timed_out_events.increment(data.0 as u64); | ||
| self.timed_out_requests.increment(1); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,61 +1,26 @@ | ||
| use std::fmt; | ||
|
|
||
| use tokio::sync::mpsc; | ||
| use vector_buffers::topology::channel::SendError; | ||
| use vector_buffers::topology::channel; | ||
|
|
||
| use crate::event::{Event, EventArray}; | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| pub struct ClosedError; | ||
|
|
||
| impl fmt::Display for ClosedError { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| f.write_str("Sender is closed.") | ||
| } | ||
| } | ||
|
|
||
| impl std::error::Error for ClosedError {} | ||
|
|
||
| impl From<mpsc::error::SendError<Event>> for ClosedError { | ||
| fn from(_: mpsc::error::SendError<Event>) -> Self { | ||
| Self | ||
| } | ||
| #[derive(Clone, Copy, Debug, Eq, PartialEq)] | ||
| pub enum SendError { | ||
| Timeout, | ||
| Closed, | ||
| } | ||
|
|
||
| impl From<mpsc::error::SendError<EventArray>> for ClosedError { | ||
| fn from(_: mpsc::error::SendError<EventArray>) -> Self { | ||
| Self | ||
| impl<T> From<channel::SendError<T>> for SendError { | ||
| fn from(_: channel::SendError<T>) -> Self { | ||
| Self::Closed | ||
| } | ||
| } | ||
|
|
||
| impl<T> From<SendError<T>> for ClosedError { | ||
| fn from(_: SendError<T>) -> Self { | ||
| Self | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug)] | ||
| pub enum StreamSendError<E> { | ||
| Closed(ClosedError), | ||
| Stream(E), | ||
| } | ||
|
|
||
| impl<E> fmt::Display for StreamSendError<E> | ||
| where | ||
| E: fmt::Display, | ||
| { | ||
| impl fmt::Display for SendError { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| match self { | ||
| StreamSendError::Closed(e) => e.fmt(f), | ||
| StreamSendError::Stream(e) => e.fmt(f), | ||
| Self::Timeout => f.write_str("Send timed out."), | ||
| Self::Closed => f.write_str("Sender is closed."), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<E> std::error::Error for StreamSendError<E> where E: std::error::Error {} | ||
|
|
||
| impl<E> From<ClosedError> for StreamSendError<E> { | ||
| fn from(e: ClosedError) -> Self { | ||
| StreamSendError::Closed(e) | ||
| } | ||
| } | ||
| impl std::error::Error for SendError {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.