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

Have Opentelemetry error handler to use tracing::error #852

Merged
merged 8 commits into from
Dec 17, 2024

Conversation

yuandrew
Copy link
Contributor

@yuandrew yuandrew commented Dec 10, 2024

What was changed

Set OpenTelemetry global setting to log to tracing::error

Why?

Checklist

  1. Closes [Feature Request] Have OpenTelemetry failure logs go to logger instead of stderr #810

  2. How was this tested:

Added a new test

  1. Any docs updates needed?

@yuandrew yuandrew marked this pull request as ready for review December 13, 2024 16:35
@yuandrew yuandrew requested a review from a team as a code owner December 13, 2024 16:35
Comment on lines +123 to +125
global::set_error_handler(|err| {
tracing::error!("{}", err);
})?;
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there is a better more global place to set this instead of on each build_otlp_metric_exporter call? Unsure if we have global metric initialization code.

@@ -120,6 +120,9 @@ pub(super) fn augment_meter_provider_with_defaults(
pub fn build_otlp_metric_exporter(
opts: OtelCollectorOptions,
) -> Result<CoreOtelMeter, anyhow::Error> {
global::set_error_handler(|err| {
Copy link
Member

Choose a reason for hiding this comment

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

Note this was removed recently in 0.27 (ref open-telemetry/opentelemetry-rust#2260), so we either need to say in the dep that we are 0.26 (not sure if you can say < 0.27) or look at that migration guide and see if just upgrading to 0.27 is enough to get proper logs here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the change only changes the behavior on how you can override their default logging behavior, we would still need to override their behavior, just in a different way now. I'm not sure it's worth upgrading to 0.27 over this.

Copy link
Member

Choose a reason for hiding this comment

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

I think my concern is whether other people want to upgrade to 0.27+. I am not sure what Cargo's auto-upgrade logic is for zero-ver. Obviously one day we will need to as well even if that day is not today (can't stay on 0.26 forever).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Who are the "other" people mentioned here? customers?

I am not sure what Cargo's auto-upgrade logic is for zero-ver.

I assume cargo wouldn't auto-upgrade from 0.26 to 0.27, since there are a number of breaking changes with that update.

Obviously one day we will need to as well even if that day is not today (can't stay on 0.26 forever).

Agreed, I'm just reluctant to upgrade today 😅 but now that I've written a test, that future upgrade should be easier

Copy link
Member

Choose a reason for hiding this comment

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

Who are the "other" people mentioned here? customers?

Nope just us internally

Agreed, I'm just reluctant to upgrade today

Works for me

@yuandrew yuandrew merged commit 7b3776c into temporalio:master Dec 17, 2024
7 checks passed
@yuandrew yuandrew deleted the otel-tracing-error branch December 17, 2024 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Have OpenTelemetry failure logs go to logger instead of stderr
3 participants