Skip to content

Commit

Permalink
Add few debug level internal logs to PeriodicReader
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas committed Nov 5, 2024
1 parent dd7b531 commit 7899bb9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion opentelemetry-sdk/src/metrics/periodic_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ where
}));
};

otel_debug!(
name: "PeriodicReaderBuilt",
message = "Periodic reader built.",
interval_in_secs = self.interval.as_secs(),

Check warning on line 137 in opentelemetry-sdk/src/metrics/periodic_reader.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/periodic_reader.rs#L137

Added line #L137 was not covered by tests
);

PeriodicReader {
exporter: Arc::new(self.exporter),
inner: Arc::new(Mutex::new(PeriodicReaderInner {
Expand Down Expand Up @@ -251,6 +257,10 @@ impl<RT: Runtime> PeriodicReaderWorker<RT> {
async fn process_message(&mut self, message: Message) -> bool {
match message {
Message::Export => {
otel_debug!(
name: "PeriodicReader.ExportMessageReceived",
message = "Export message received.",
);
if let Err(err) = self.collect_and_export().await {
otel_error!(
name: "PeriodicReader.ExportFailed",
Expand All @@ -259,16 +269,24 @@ impl<RT: Runtime> PeriodicReaderWorker<RT> {
}
}
Message::Flush(ch) => {
otel_debug!(
name: "PeriodicReader.FlushMessageReceived",
message = "Flush message received.",
);
let res = self.collect_and_export().await;
if let Err(send_error) = ch.send(res) {
otel_debug!(
name: "PeriodicReader.Flush.SendResultError",
message = "Failed to send flush result",
message = "Failed to send flush result.",
reason = format!("{:?}", send_error),
);
}
}
Message::Shutdown(ch) => {
otel_debug!(
name: "PeriodicReader.ShutdownMessageReceived",
message = "Shutdown message received",
);
let res = self.collect_and_export().await;
let _ = self.reader.exporter.shutdown();
if let Err(send_error) = ch.send(res) {
Expand Down

0 comments on commit 7899bb9

Please sign in to comment.