-
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): Add internal events for
http
source (#3264
) * Add internal events for HTTP source Added HTTPEventsReceived and HTTPBadRequest. Signed-off-by: Duy Do <juchiast@gmail.com>
- Loading branch information
Showing
3 changed files
with
72 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use super::InternalEvent; | ||
use metrics::counter; | ||
|
||
#[derive(Debug)] | ||
pub struct HTTPEventsReceived { | ||
pub events_count: usize, | ||
pub byte_size: usize, | ||
} | ||
|
||
impl InternalEvent for HTTPEventsReceived { | ||
fn emit_logs(&self) { | ||
trace!( | ||
message = "sending events.", | ||
events_count = %self.events_count, | ||
byte_size = %self.byte_size, | ||
); | ||
} | ||
|
||
fn emit_metrics(&self) { | ||
counter!("events_processed", self.events_count as u64, | ||
"component_kind" => "source", | ||
"component_type" => "http", | ||
); | ||
counter!("bytes_processed", self.byte_size as u64, | ||
"component_kind" => "source", | ||
"component_type" => "http", | ||
); | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct HTTPBadRequest<'a> { | ||
pub error_code: u16, | ||
pub error_message: &'a str, | ||
} | ||
|
||
impl<'a> InternalEvent for HTTPBadRequest<'a> { | ||
fn emit_logs(&self) { | ||
warn!( | ||
message = "received bad request.", | ||
code = %self.error_code, | ||
message = %self.error_message, | ||
rate_limit_secs = 10, | ||
); | ||
} | ||
|
||
fn emit_metrics(&self) { | ||
counter!( | ||
"http_bad_requests", 1, | ||
"component_kind" => "source", | ||
"component_type" => "http", | ||
); | ||
} | ||
} |
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