-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(otel): Missing
addLink
method and Fiber handling (#2849)
* fix(otel): Missing method and Fiber handling * tests: `test_opentelemetry_{1|beta}` * tests: Properly set composer to 1.0.* * fix: remove `cleanup_opentelemetry` * fix: php 7.4 unpacking issue * tests: skip fiber test on coverage * style: remove useless require * remove comment * perf: condition check * perf: Class lookup optimization Co-authored-by: Bob Weinand <bob.weinand@datadoghq.com> --------- Co-authored-by: Bob Weinand <bob.weinand@datadoghq.com>
- Loading branch information
Showing
11 changed files
with
223 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
tests/OpenTelemetry/Integration/Context/Fiber/test_context_switching_ffi_observer.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--TEST-- | ||
Context switches on execution context switch. | ||
--SKIPIF-- | ||
<?php if (PHP_VERSION_ID < 80100 || !extension_loaded('ffi') || getenv('PHPUNIT_COVERAGE')) die('skip requires PHP8.1 and FFI'); ?> | ||
--ENV-- | ||
OTEL_PHP_FIBERS_ENABLED=1 | ||
--FILE-- | ||
<?php | ||
use OpenTelemetry\Context\Context; | ||
|
||
require_once './tests/OpenTelemetry/vendor/autoload.php'; | ||
|
||
$key = Context::createKey('-'); | ||
$scope = Context::getCurrent() | ||
->with($key, 'main') | ||
->activate(); | ||
|
||
$fiber = new Fiber(function() use ($key) { | ||
$scope = Context::getCurrent() | ||
->with($key, 'fiber') | ||
->activate(); | ||
|
||
echo 'fiber:' . Context::getCurrent()->get($key), PHP_EOL; | ||
|
||
Fiber::suspend(); | ||
echo 'fiber:' . Context::getCurrent()->get($key), PHP_EOL; | ||
|
||
$scope->detach(); | ||
}); | ||
|
||
echo 'main:' . Context::getCurrent()->get($key), PHP_EOL; | ||
|
||
$fiber->start(); | ||
echo 'main:' . Context::getCurrent()->get($key), PHP_EOL; | ||
|
||
$fiber->resume(); | ||
echo 'main:' . Context::getCurrent()->get($key), PHP_EOL; | ||
|
||
$scope->detach(); | ||
?> | ||
--EXPECT-- | ||
main:main | ||
fiber:fiber | ||
main:main | ||
fiber:fiber | ||
main:main |
Oops, something went wrong.