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

Use instrument in generated call_ functions #9263

Merged

Conversation

elliottt
Copy link
Member

@elliottt elliottt commented Sep 17, 2024

Following on from #9217, generate call_* functions that use tracing::Instrument instead of Span::enter.

To test this change I added an additional set of generated files that corresponds to the combination of async: true and tracing: true. This way we can verify that the changes in #9217 and this PR remove uses of Span::enter from the code generated by the bindgen! macro.

The additional exp files add an awful lot to this diff, and I think it would be reasonable to remove them before merging. The meat of the changes is in the middle commit, 4c1a4f0, and the final commit shows the differences to the generated code that the middle commit introduces. I believe this catches all outstanding uses of enter for the combination of async: true and tracing: true.

@elliottt elliottt requested a review from a team as a code owner September 17, 2024 03:37
@elliottt elliottt requested review from alexcrichton and pchickey and removed request for a team September 17, 2024 03:37
Comment on lines +2847 to +2861
let instrument = if is_async && self.gen.opts.tracing {
".instrument(span.clone())"
} else {
""
};
uwriteln!(self.src, ")){instrument}{await_}?;");

let instrument = if is_async && self.gen.opts.tracing {
".instrument(span)"
} else {
""
};
uwriteln!(
self.src,
"callee.post_return{async__}(store.as_context_mut()){await_}?;"
"callee.post_return{async__}(store.as_context_mut()){instrument}{await_}?;"
Copy link
Member Author

Choose a reason for hiding this comment

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

This all feels a bit verbose, but it seemed slightly easier to read than the version where I inlined the conditional into the args to the format string. Happy to add the inlined version if that's preferred.

@alexcrichton alexcrichton added this pull request to the merge queue Sep 17, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 17, 2024
@elliottt elliottt added this pull request to the merge queue Sep 17, 2024
Merged via the queue into bytecodealliance:main with commit 78b1eb4 Sep 17, 2024
39 checks passed
@elliottt elliottt deleted the trevor/instrument-call-functions branch September 17, 2024 05:19
elliottt added a commit to elliottt/wasmtime that referenced this pull request Sep 17, 2024
* Add async tracing versions of the component-macro tests

* Use instrument when generating async call functions with tracing

* Update tests
alexcrichton pushed a commit that referenced this pull request Sep 17, 2024
* Use `instrument` in generated `call_` functions (#9263)

* Add async tracing versions of the component-macro tests

* Use instrument when generating async call functions with tracing

* Update tests

* Update release notes
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