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

Support async php runtimes #675

Merged
merged 12 commits into from
May 24, 2022

Conversation

Nevay
Copy link
Contributor

@Nevay Nevay commented May 14, 2022

This PR adds support for async userland implementations (resolves #671, replaces #674):

  • Event loops can wrap callables in ScopeBoundCallables to preserve the original scope.
  • Promises can propagate the scope based on the approach outlined in ScopeBoundPromise. (Instrumentation returning promises should not ::detach() the scope as promises are chained and not nested.)

Additionally includes an experimental context storage to support execute_data switches performed by Swoole, should be moved out of src/Context into a contrib package or similar in the future.

Other changes:

  • Allows accessing the currently active scope and adds a scope-local storage to simplify usage with pre- + post-hook observer autoinstrumentation.
  • Reduces warnings when using fibers without fiber support, now warnings are only triggered when crossing fiber boundaries.

@codecov
Copy link

codecov bot commented May 14, 2022

Codecov Report

Merging #675 (8e5cbbb) into main (85282b5) will decrease coverage by 1.30%.
The diff coverage is 35.50%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #675      +/-   ##
============================================
- Coverage     86.07%   84.77%   -1.31%     
- Complexity     1151     1213      +62     
============================================
  Files           128      136       +8     
  Lines          2794     2936     +142     
============================================
+ Hits           2405     2489      +84     
- Misses          389      447      +58     
Flag Coverage Δ
7.4 84.77% <35.54%> (-1.26%) ⬇️
8.0 84.82% <35.54%> (-1.25%) ⬇️
8.1 84.82% <35.54%> (-1.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/Context/ContextStorageHead.php 100.00% <ø> (+100.00%) ⬆️
src/Context/FiberBoundContextStorage.php 0.00% <0.00%> (ø)
src/Context/FiberBoundContextStorageScope.php 0.00% <0.00%> (ø)
...Contrib/Context/Swoole/SwooleContextDestructor.php 0.00% <0.00%> (ø)
...rc/Contrib/Context/Swoole/SwooleContextHandler.php 0.00% <0.00%> (ø)
src/Contrib/Context/Swoole/SwooleContextScope.php 0.00% <0.00%> (ø)
...rc/Contrib/Context/Swoole/SwooleContextStorage.php 0.00% <0.00%> (ø)
src/Context/ScopeBound/ScopeBoundPromise.php 96.29% <96.29%> (ø)
src/Context/Context.php 82.92% <100.00%> (ø)
src/Context/ContextStorage.php 100.00% <100.00%> (+100.00%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 85282b5...8e5cbbb. Read the comment docs.

- move Swoole context storage to Contrib/Context/Swoole
- use self instead of classname
@Nevay Nevay marked this pull request as ready for review May 19, 2022 07:06
@brettmc brettmc mentioned this pull request May 19, 2022
@bobstrecansky bobstrecansky merged commit 1326f17 into open-telemetry:main May 24, 2022
@WyriHaximus
Copy link

Came across this yesterday, and it looks really interesting for my @reactphp apps. But how do I use this? Is there any documentation or examples how to integrate this with an event loop, or an existing fibers implementation for awaiting promises?

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.

tracing with async php runtimes
4 participants