-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b3e1bf
commit 996e2ab
Showing
4 changed files
with
229 additions
and
15 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,93 @@ | ||
--TEST-- | ||
Backtrace do not contains datadog frames | ||
--ENV-- | ||
DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
--INI-- | ||
extension=ddtrace.so | ||
--FILE-- | ||
<?php | ||
namespace DDTrace { | ||
use function datadog\appsec\testing\generate_backtrace; | ||
|
||
class SomeIntegration { | ||
public function init() | ||
{ | ||
install_hook("ltrim", self::hooked_function(), null); | ||
} | ||
|
||
private static function hooked_function() | ||
{ | ||
return static function (HookData $hook) { | ||
var_dump(generate_backtrace("some id")); | ||
}; | ||
} | ||
} | ||
} | ||
namespace { | ||
include __DIR__ . '/inc/ddtrace_version.php'; | ||
|
||
ddtrace_version_at_least('0.79.0'); | ||
|
||
function two($param01, $param02) | ||
{ | ||
var_dump(ltrim(" Verify the wrapped function works")); | ||
} | ||
|
||
function one($param01) | ||
{ | ||
two($param01, "other"); | ||
} | ||
|
||
$integration = new DDTrace\SomeIntegration(); | ||
$integration->init(); | ||
|
||
DDTrace\start_span(); | ||
$root = DDTrace\active_span(); | ||
one("foo01"); | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
array(3) { | ||
["language"]=> | ||
string(3) "php" | ||
["id"]=> | ||
string(7) "some id" | ||
["frames"]=> | ||
array(3) { | ||
[0]=> | ||
array(4) { | ||
["line"]=> | ||
int(26) | ||
["function"]=> | ||
string(5) "ltrim" | ||
["file"]=> | ||
string(25) "generate_backtrace_06.php" | ||
["id"]=> | ||
int(1) | ||
} | ||
[1]=> | ||
array(4) { | ||
["line"]=> | ||
int(31) | ||
["function"]=> | ||
string(3) "two" | ||
["file"]=> | ||
string(25) "generate_backtrace_06.php" | ||
["id"]=> | ||
int(2) | ||
} | ||
[2]=> | ||
array(4) { | ||
["line"]=> | ||
int(39) | ||
["function"]=> | ||
string(3) "one" | ||
["file"]=> | ||
string(25) "generate_backtrace_06.php" | ||
["id"]=> | ||
int(3) | ||
} | ||
} | ||
} | ||
string(33) "Verify the wrapped function works" |
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,83 @@ | ||
--TEST-- | ||
Functions are fully qualified names | ||
--ENV-- | ||
DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
--INI-- | ||
extension=ddtrace.so | ||
--FILE-- | ||
<?php | ||
namespace Some\NameSpace { | ||
use function datadog\appsec\testing\generate_backtrace; | ||
|
||
class Foo { | ||
static function three () { | ||
var_dump(generate_backtrace("some id")); | ||
} | ||
|
||
function two($param01, $param02) | ||
{ | ||
self::three(); | ||
} | ||
|
||
function one($param01) | ||
{ | ||
$this->two($param01, "other"); | ||
} | ||
} | ||
} | ||
|
||
namespace { | ||
include __DIR__ . '/inc/ddtrace_version.php'; | ||
|
||
ddtrace_version_at_least('0.79.0'); | ||
|
||
DDTrace\start_span(); | ||
$root = DDTrace\active_span(); | ||
|
||
$class = new Some\NameSpace\Foo(); | ||
$class->one("foo01"); | ||
} | ||
?> | ||
--EXPECTF-- | ||
array(3) { | ||
["language"]=> | ||
string(3) "php" | ||
["id"]=> | ||
string(7) "some id" | ||
["frames"]=> | ||
array(3) { | ||
[0]=> | ||
array(4) { | ||
["line"]=> | ||
int(12) | ||
["function"]=> | ||
string(25) "Some\NameSpace\Foo::three" | ||
["file"]=> | ||
string(25) "generate_backtrace_07.php" | ||
["id"]=> | ||
int(0) | ||
} | ||
[1]=> | ||
array(4) { | ||
["line"]=> | ||
int(17) | ||
["function"]=> | ||
string(23) "Some\NameSpace\Foo::two" | ||
["file"]=> | ||
string(25) "generate_backtrace_07.php" | ||
["id"]=> | ||
int(1) | ||
} | ||
[2]=> | ||
array(4) { | ||
["line"]=> | ||
int(31) | ||
["function"]=> | ||
string(23) "Some\NameSpace\Foo::one" | ||
["file"]=> | ||
string(25) "generate_backtrace_07.php" | ||
["id"]=> | ||
int(2) | ||
} | ||
} | ||
} |