-
Notifications
You must be signed in to change notification settings - Fork 437
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
Proposal to improve internal error logging #1146
Comments
It might be worth seeing if we can leverage the tokio tracing crate for this implementation. It already defines concepts of log levels and components (which it calls targets) and has a rich facility for filtering which logs go where. I realize there might appear to be a circular dependency between their crate and |
One option could be extend the existing error_handler for different log levels and so rename it to main...lalitb:opentelemetry-rust:log-handler So, the existing error handling code: if let Some(ref inner) = self.0.inner {
match inner.lock() {
Ok(mut locked) => f(&mut locked),
Err(err) => global::handle_error(err),
}
} to if let Some(ref inner) = self.0.inner {
match inner.lock() {
Ok(mut locked) => f(&mut locked),
Err(err) => otel_log_error!(err, Pillar::Trace, Component::Context),
}
} The user can add custom log handler, which can use The macro to log the INFO level log: #[macro_export]
macro_rules! otel_log_info {
($message:expr, $pillar:expr, $component:expr) => {
if is_compile_time_log_level_enabled!(LogLevel::Info) && is_runtime_log_level_enabled(LogLevel::Info) {
handle_log(Error {
level: LogLevel::Info,
pillar: $pillar,
component: $component,
message: $message.to_string(),
});
}
};
} |
Also, as per the @shaun-cox suggestion, we can also directly use the
|
Thanks! Can you promote the branch to a PR, so we can start reviewing. I don't see any Circular dep issues, and the infinite logging issue looks trivial to fix either by Otel or by user. We need to develop some conventions about target and eventname that must be followed by OTel components.
This is a good plan! |
Have added this - #2128 - for further discussion. |
Moving this to 0.27 milestone. This milestone is expected to upgrade several components to RC status, and quality internal logs is a must have for it. |
Presently, an internal logging mechanism is in place that leverages eprintln! to alert users of errors within the Opentelemetry pipeline. Users have the option to customize this logging by introducing their own error handler.
However, this existing approach exhibits a couple of issues:
To improve user-friendliness of our internal error handling, I am proposing the development of an enhanced internal logging tool with the following attributes:
opentelemetry
. Given thatopentelemetry
is typically used for diagnosing problems in applications and other libraries, it's important that we avoid using its log pillar for error reporting.SpanProvider
,SpanProcessor
,SpanExporter
.To implement these enhancements, I think we should convert the current
Error
enum into anError
structure that will include all the aforementioned metadata and level information. So something likeThe text was updated successfully, but these errors were encountered: