Skip to content

Support async php runtimes#675

Merged
bobstrecansky merged 12 commits into
open-telemetry:mainfrom
Nevay:feature/context-storage
May 24, 2022
Merged

Support async php runtimes#675
bobstrecansky merged 12 commits into
open-telemetry:mainfrom
Nevay:feature/context-storage

Conversation

@Nevay

@Nevay Nevay commented May 14, 2022

Copy link
Copy Markdown
Contributor

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

codecov Bot commented May 14, 2022

Copy link
Copy Markdown

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.

@Nevay
Nevay force-pushed the feature/context-storage branch from e13c0d8 to 53fc3a1 Compare May 15, 2022 13:47
Comment thread src/Context/ScopeBound/ScopeBoundPromise.php Outdated
Comment thread src/Context/Swoole/SwooleContextHandler.php Outdated
- 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
Copy Markdown
Contributor

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