-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Isolate exception state for hooks (#118)
* Isolate exception state for hooks * Consistent naming. * Fix formatting and test typo * Fixed test list in PECL package.xml * Save and restore execute_data->opline
- Loading branch information
1 parent
745fe0c
commit d4e11b6
Showing
6 changed files
with
159 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--TEST-- | ||
Check if exceptions thrown in hooks are isolated and logged | ||
--EXTENSIONS-- | ||
opentelemetry | ||
--FILE-- | ||
<?php | ||
\OpenTelemetry\Instrumentation\hook(null, 'helloWorld', pre: fn() => throw new Exception('thrown in pre'), post: fn() => throw new Exception('thrown in post')); | ||
|
||
function helloWorld() { | ||
var_dump('function'); | ||
throw new Exception('original'); | ||
} | ||
|
||
try { | ||
helloWorld(); | ||
} catch (Exception $e) { | ||
var_dump($e->getMessage()); | ||
var_dump($e->getPrevious()); | ||
} | ||
?> | ||
--EXPECTF-- | ||
|
||
Warning: helloWorld(): OpenTelemetry: pre hook threw exception, class=null function=helloWorld message=thrown in pre in %s | ||
string(8) "function" | ||
|
||
Warning: helloWorld(): OpenTelemetry: post hook threw exception, class=null function=helloWorld message=thrown in post in %s | ||
string(8) "original" | ||
NULL |
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,32 @@ | ||
--TEST-- | ||
Check if exceptions thrown in hooks interfere with internal exceptions | ||
--EXTENSIONS-- | ||
opentelemetry | ||
--FILE-- | ||
<?php | ||
function helloWorld($argument) { | ||
var_dump('inside'); | ||
} | ||
\OpenTelemetry\Instrumentation\hook( | ||
null, | ||
'helloWorld', | ||
pre: static function () : void { | ||
throw new \Exception('pre'); | ||
}, | ||
post: static function () : void { | ||
throw new \Exception('post'); | ||
} | ||
); | ||
helloWorld(); | ||
?> | ||
--EXPECTF-- | ||
|
||
Warning: helloWorld(): OpenTelemetry: pre hook threw exception, class=null function=helloWorld message=pre in %s | ||
|
||
Warning: helloWorld(): OpenTelemetry: post hook threw exception, class=null function=helloWorld message=post in %s | ||
|
||
Fatal error: Uncaught ArgumentCountError: Too few arguments to function helloWorld(), 0 passed in %s | ||
Stack trace: | ||
#0 %s: helloWorld() | ||
#1 {main} | ||
thrown in %s |
This file was deleted.
Oops, something went wrong.
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