Skip to content
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

adds timestamps #2231

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions opentelemetry-appender-tracing/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ where
log_record.set_event_name(meta.name());
log_record.set_severity_number(severity_of_level(meta.level()));
log_record.set_severity_text(meta.level().as_str());
log_record.set_timestamp(std::time::SystemTime::now());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the specs - This field is optional, it may be missing if the source timestamp is unknown.

log_record.set_observed_timestamp(std::time::SystemTime::now());
Copy link
Member

@lalitb lalitb Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already done in SDK, why do we need it here?

Copy link
Author

@montekki montekki Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this path in SDK hit when this Bridge is added as a layer into tracing_subscriber ? On the QuickWit side I see that this timestamp was not populated which needed a workaround: quickwit-oss/quickwit#5366
However this fix is not ideal since it will set the log timestamp at the received time, not at the emit time which will lead to all sorts of troubles.

Copy link
Member

@lalitb lalitb Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this path in SDK hit when this Bridge is added as a layer into tracing_subscriber

yes it does. You can try running the example to verify - https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-appender-tracing/examples/basic.rs

let mut visitor = EventVisitor::new(&mut log_record);
#[cfg(feature = "experimental_metadata_attributes")]
visitor.visit_experimental_metadata(meta);
Expand Down
Loading