-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement(observability): Convert
BytesReceived
to a registered e…
…vent (#13934) This change moves the common `BytesReceived` into `vector-common` and converts it and all uses of it to a registered event.
- Loading branch information
Showing
31 changed files
with
262 additions
and
170 deletions.
There are no files selected for viewing
This file contains 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 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,41 @@ | ||
use metrics::{register_counter, Counter}; | ||
|
||
use super::{ByteSize, InternalEventHandle, Protocol, RegisterInternalEvent, SharedString}; | ||
|
||
pub struct BytesReceived { | ||
pub protocol: SharedString, | ||
} | ||
|
||
impl RegisterInternalEvent for BytesReceived { | ||
type Handle = Handle; | ||
|
||
fn register(self) -> Self::Handle { | ||
Handle { | ||
received_bytes: register_counter!("component_received_bytes_total", "protocol" => self.protocol.clone()), | ||
protocol: self.protocol, | ||
} | ||
} | ||
} | ||
|
||
impl From<Protocol> for BytesReceived { | ||
fn from(protocol: Protocol) -> Self { | ||
Self { | ||
protocol: protocol.0, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct Handle { | ||
protocol: SharedString, | ||
received_bytes: Counter, | ||
} | ||
|
||
impl InternalEventHandle for Handle { | ||
type Data = ByteSize; | ||
|
||
fn emit(&self, data: Self::Data) { | ||
self.received_bytes.increment(data.0 as u64); | ||
trace!(message = "Bytes received.", byte_size = %data.0, protocol = %self.protocol); | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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 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 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.