-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding test for post hook type error (#119)
* adding test for post hook type error if an invalid typehint is provided for first param of post callback, this would previously cause a hang. fixed by #118, this test confirms the fix works in this scenario. * improve test, add to package.xml * remove try/catch
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--TEST-- | ||
Check if type error in post hook is handled | ||
--EXTENSIONS-- | ||
opentelemetry | ||
--FILE-- | ||
<?php | ||
class Foo | ||
{ | ||
public function bar(): void | ||
{ | ||
var_dump('bar'); | ||
} | ||
} | ||
|
||
\OpenTelemetry\Instrumentation\hook( | ||
Foo::class, | ||
'bar', | ||
fn() => var_dump('pre'), | ||
fn(string $scope, array $params, mixed $returnValue, ?Throwable $throwable) => var_dump('post')); //NB invalid type for $scope | ||
|
||
(new Foo())->bar(); | ||
var_dump('baz'); | ||
--EXPECTF-- | ||
string(3) "pre" | ||
string(3) "bar" | ||
|
||
Warning: Foo::bar(): OpenTelemetry: post hook threw exception, class=Foo function=bar message=%sArgument #1 ($scope) must be of type string, Foo given%s | ||
string(3) "baz" |