-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed internal function instrumentation if only pre or post hook is g…
…iven. * phpt test for user and internal functions use cases
- Loading branch information
Showing
6 changed files
with
145 additions
and
1 deletion.
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
23 changes: 23 additions & 0 deletions
23
prod/native/extension/phpt/tests/instrumentation_int_func_post_hook_only.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,23 @@ | ||
--TEST-- | ||
instrumentation - internal func post hook only | ||
--ENV-- | ||
ELASTIC_OTEL_LOG_LEVEL_STDERR=INFO | ||
--INI-- | ||
extension=/elastic/elastic_otel_php.so | ||
elastic_otel.bootstrap_php_part_file={PWD}/includes/bootstrap_mock.inc | ||
--FILE-- | ||
<?php | ||
declare(strict_types=1); | ||
|
||
elastic_otel_hook(NULL, "str_contains", NULL, function () { | ||
echo "*** posthook()\n"; | ||
}); | ||
|
||
var_dump(str_contains("elastic obs", "obs")); | ||
|
||
echo "Test completed\n"; | ||
?> | ||
--EXPECTF-- | ||
*** posthook() | ||
bool(true) | ||
Test completed |
23 changes: 23 additions & 0 deletions
23
prod/native/extension/phpt/tests/instrumentation_int_func_pre_hook_only.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,23 @@ | ||
--TEST-- | ||
instrumentation - internal func pre hook only | ||
--ENV-- | ||
ELASTIC_OTEL_LOG_LEVEL_STDERR=INFO | ||
--INI-- | ||
extension=/elastic/elastic_otel_php.so | ||
elastic_otel.bootstrap_php_part_file={PWD}/includes/bootstrap_mock.inc | ||
--FILE-- | ||
<?php | ||
declare(strict_types=1); | ||
|
||
elastic_otel_hook(NULL, "str_contains", function () { | ||
echo "*** prehook()\n"; | ||
}, NULL); | ||
|
||
var_dump(str_contains("elastic obs", "obs")); | ||
|
||
echo "Test completed\n"; | ||
?> | ||
--EXPECTF-- | ||
*** prehook() | ||
bool(true) | ||
Test completed |
29 changes: 29 additions & 0 deletions
29
prod/native/extension/phpt/tests/instrumentation_spl_autoload_register.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,29 @@ | ||
--TEST-- | ||
instrumentation - spl_autoload_register | ||
--ENV-- | ||
ELASTIC_OTEL_LOG_LEVEL_STDERR=INFO | ||
--INI-- | ||
extension=/elastic/elastic_otel_php.so | ||
elastic_otel.bootstrap_php_part_file={PWD}/includes/bootstrap_mock.inc | ||
--FILE-- | ||
<?php | ||
declare(strict_types=1); | ||
|
||
elastic_otel_hook(NULL, "spl_autoload_register", function () { | ||
echo "*** prehook()\n"; | ||
}, function () { | ||
echo "*** posthook()\n"; | ||
}); | ||
|
||
|
||
|
||
|
||
|
||
spl_autoload_register(function () { }, true, false); | ||
|
||
echo "Test completed\n"; | ||
?> | ||
--EXPECTF-- | ||
*** prehook() | ||
*** posthook() | ||
Test completed |
29 changes: 29 additions & 0 deletions
29
prod/native/extension/phpt/tests/instrumentation_user_func_post_hook_only.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,29 @@ | ||
--TEST-- | ||
instrumentation - user func - post hook only | ||
--ENV-- | ||
ELASTIC_OTEL_LOG_LEVEL_STDERR=info | ||
--INI-- | ||
extension=/elastic/elastic_otel_php.so | ||
elastic_otel.bootstrap_php_part_file={PWD}/includes/bootstrap_mock.inc | ||
--FILE-- | ||
<?php | ||
declare(strict_types=1); | ||
|
||
|
||
|
||
function userspace($arg1, $arg2, $arg3) { | ||
echo "* userspace() called.\n"; | ||
} | ||
|
||
elastic_otel_hook(NULL, "userspace", NULL, function () { | ||
echo "*** posthook userspace()\n"; | ||
}); | ||
|
||
userspace("first", 2, 3); | ||
|
||
echo "Test completed\n"; | ||
?> | ||
--EXPECTF-- | ||
* userspace() called. | ||
*** posthook userspace() | ||
Test completed |
29 changes: 29 additions & 0 deletions
29
prod/native/extension/phpt/tests/instrumentation_user_func_pre_hook_only.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,29 @@ | ||
--TEST-- | ||
instrumentation - user func - pre hook only | ||
--ENV-- | ||
ELASTIC_OTEL_LOG_LEVEL_STDERR=info | ||
--INI-- | ||
extension=/elastic/elastic_otel_php.so | ||
elastic_otel.bootstrap_php_part_file={PWD}/includes/bootstrap_mock.inc | ||
--FILE-- | ||
<?php | ||
declare(strict_types=1); | ||
|
||
|
||
|
||
function userspace($arg1, $arg2, $arg3) { | ||
echo "* userspace() called.\n"; | ||
} | ||
|
||
elastic_otel_hook(NULL, "userspace", function () { | ||
echo "*** prehook userspace()\n"; | ||
}, NULL); | ||
|
||
userspace("first", 2, 3); | ||
|
||
echo "Test completed\n"; | ||
?> | ||
--EXPECTF-- | ||
*** prehook userspace() | ||
* userspace() called. | ||
Test completed |