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

Fix OpenTelemetry graceful shutdown. #6738

Conversation

David-Wobrock
Copy link

@David-Wobrock David-Wobrock commented May 7, 2024

Why the changes in this PR are needed?

When running OPA with the distributed tracing option enabled, the OpenTelemetry trace exporter is not gracefully shut down when the server is stopped.

What are the changes in this PR?

This PR fixes that issues by moving the trace exporter shutdown in the gracefulServerShutdown function.

Notes to assist PR review:

Picked up from #6664

Further comments:

Fixes #6651.
This bug seems to have been introduced by this commit.

@David-Wobrock David-Wobrock force-pushed the fix-opentelemetry-graceful-shutdown branch 10 times, most recently from 10a5921 to a802c52 Compare May 7, 2024 15:34
@David-Wobrock David-Wobrock changed the title Fix opentelemetry graceful shutdown Fix OpenTelemetry graceful shutdown. May 7, 2024
@David-Wobrock David-Wobrock marked this pull request as ready for review May 7, 2024 15:43
@ashutosh-narkar ashutosh-narkar force-pushed the fix-opentelemetry-graceful-shutdown branch from a802c52 to 1092a10 Compare May 8, 2024 16:55
Copy link
Member

@ashutosh-narkar ashutosh-narkar left a comment

Choose a reason for hiding this comment

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

@David-Wobrock the change looks good. Just one comment on the test.

When running OPA with the distributed tracing option enabled,
the OpenTelemetry trace exporter is not gracefully shut down
when the server is stopped.

This PR fixes that issues by moving the trace exporter shutdown
in the gracefulServerShutdown function.

Fixes: open-policy-agent#6651
Signed-off-by: Nicolas Chotard <nicolas.chotard@backmarket.com>
Signed-off-by: David Wobrock <david.wobrock@backmarket.com>
@David-Wobrock David-Wobrock force-pushed the fix-opentelemetry-graceful-shutdown branch from 1092a10 to de44f77 Compare May 10, 2024 06:36
@David-Wobrock
Copy link
Author

Thanks for the review @ashutosh-narkar 🙏

I pushed the edits. Let me know if I can do further changes :)

}()
<-done

expected := "Failed to shutdown OpenTelemetry trace exporter gracefully."
Copy link
Member

Choose a reason for hiding this comment

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

Can we also have a test where the trace exporter does not shutdown gracefully?

Copy link
Author

Choose a reason for hiding this comment

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

I guess the variable is misnamed, since we don't expected this message to be present in the logs - and thus test that the trace exporter did shutdown gracefully.

But anyway, I wouldn't know how to write a test where the trace exporter doesn't shutdown gracefully 😕

I'd need some help here :)
Or we could add such a test in a later PR, and start with this fix for now.

Copy link
Member

Choose a reason for hiding this comment

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

Sure we can do that.

@ashutosh-narkar ashutosh-narkar merged commit d7ebb3a into open-policy-agent:main May 10, 2024
28 checks passed
@David-Wobrock David-Wobrock deleted the fix-opentelemetry-graceful-shutdown branch May 13, 2024 07:35
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.

Failed to shutdown OpenTelemetry trace exporter gracefully.
3 participants