-
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.
feat(internal_metrics source): instrument "kafka" source
ref: #2007 Signed-off-by: Jean Mertz <git@jeanmertz.com>
- Loading branch information
Showing
3 changed files
with
76 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,64 @@ | ||
use super::InternalEvent; | ||
use metrics::counter; | ||
|
||
#[derive(Debug)] | ||
pub struct KafkaEventReceived { | ||
pub byte_size: usize, | ||
} | ||
|
||
impl InternalEvent for KafkaEventReceived { | ||
fn emit_logs(&self) { | ||
trace!(message = "received one event.", rate_limit_secs = 10); | ||
} | ||
|
||
fn emit_metrics(&self) { | ||
counter!( | ||
"events_processed", 1, | ||
"component_kind" => "source", | ||
"component_type" => "kafka", | ||
); | ||
counter!( | ||
"bytes_processed", self.byte_size as u64, | ||
"component_kind" => "source", | ||
"component_type" => "kafka", | ||
); | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct KafkaOffsetUpdateFailed { | ||
pub error: rdkafka::error::KafkaError, | ||
} | ||
|
||
impl InternalEvent for KafkaOffsetUpdateFailed { | ||
fn emit_logs(&self) { | ||
error!(message = "unable to update consumer offset.", error = %self.error); | ||
} | ||
|
||
fn emit_metrics(&self) { | ||
counter!( | ||
"consumer_offset_updates_failed", 1, | ||
"component_kind" => "source", | ||
"component_type" => "kafka", | ||
); | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct KafkaEventFailed { | ||
pub error: rdkafka::error::KafkaError, | ||
} | ||
|
||
impl InternalEvent for KafkaEventFailed { | ||
fn emit_logs(&self) { | ||
error!(message = "failed to read message.", error = %self.error); | ||
} | ||
|
||
fn emit_metrics(&self) { | ||
counter!( | ||
"events_failed", 1, | ||
"component_kind" => "source", | ||
"component_type" => "kafka", | ||
); | ||
} | ||
} |
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