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

Reduce locking in the implementation of Layer::on_close #173

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

mzabaluev
Copy link
Contributor

In the implementation of the on_close method, only hold the lock on span's extension to retrieve the extension data, but release it before processing and exporting.

Motivation

To achieve optimal performance, span locks should be held for as little time as possible.
It's especially troublesome to hold the lock while arbitrary code in the generic OpenTelemetry span and exporter is called to export the span.

Solution

Reduce the locked code section to what's needed to remove the data of interest from the extension map.

Only hold the lock on span's extension to retrieve
the extension data, but release it before processing and exporting.
Copy link
Collaborator

@djc djc left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@djc djc merged commit 515fe00 into tokio-rs:v0.1.x Oct 14, 2024
14 checks passed
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.

2 participants