-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid reporting filesytem integration on telemetry
- Loading branch information
1 parent
2e94092
commit f8a0af2
Showing
4 changed files
with
128 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--TEST-- | ||
Filesystem integration depends on RASP. If RASP enabled, integration is enabled | ||
--SKIPIF-- | ||
<?php | ||
if (getenv('PHP_PEAR_RUNTESTS') === '1') die("skip: pecl run-tests does not support {PWD}"); | ||
if (PHP_OS === "WINNT" && PHP_VERSION_ID < 70400) die("skip: Windows on PHP 7.2 and 7.3 have permission issues with synchronous access to telemetry"); | ||
if (getenv('USE_ZEND_ALLOC') === '0' && !getenv("SKIP_ASAN")) die('skip timing sensitive test - valgrind is too slow'); | ||
require __DIR__ . '/../includes/clear_skipif_telemetry.inc' | ||
?> | ||
--ENV-- | ||
DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
_DD_LOAD_TEST_INTEGRATIONS=1 | ||
DD_INSTRUMENTATION_TELEMETRY_ENABLED=1 | ||
DD_APPSEC_RASP_ENABLED=1 | ||
--INI-- | ||
datadog.trace.agent_url="file://{PWD}/integration-telemetry.out" | ||
--FILE-- | ||
<?php | ||
|
||
namespace DDTrace\Test | ||
{ | ||
class TestSandboxedIntegration implements \DDTrace\Integration | ||
{ | ||
function init(): int | ||
{ | ||
dd_trace_method("Test", "public_static_method", function() { | ||
echo "test_access hook" . PHP_EOL; | ||
}); | ||
return self::LOADED; | ||
} | ||
} | ||
} | ||
|
||
namespace | ||
{ | ||
class Test | ||
{ | ||
public static function public_static_method() | ||
{ | ||
echo "PUBLIC STATIC METHOD\n"; | ||
} | ||
} | ||
|
||
Test::public_static_method(); | ||
|
||
dd_trace_internal_fn("finalize_telemetry"); | ||
|
||
for ($i = 0; $i < 100; ++$i) { | ||
usleep(100000); | ||
if (file_exists(__DIR__ . '/integration-telemetry.out')) { | ||
foreach (file(__DIR__ . '/integration-telemetry.out') as $l) { | ||
if ($l) { | ||
$json = json_decode($l, true); | ||
$batch = $json["request_type"] == "message-batch" ? $json["payload"] : [$json]; | ||
foreach ($batch as $json) { | ||
if ($json["request_type"] == "app-integrations-change") { | ||
var_dump($json["payload"]); | ||
break 3; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
PUBLIC STATIC METHOD | ||
test_access hook | ||
array(1) { | ||
["integrations"]=> | ||
array(2) { | ||
[0]=> | ||
array(5) { | ||
["name"]=> | ||
string(37) "ddtrace\test\testsandboxedintegration" | ||
["enabled"]=> | ||
bool(true) | ||
["version"]=> | ||
NULL | ||
["compatible"]=> | ||
NULL | ||
["auto_enabled"]=> | ||
NULL | ||
} | ||
[1]=> | ||
array(5) { | ||
["name"]=> | ||
string(4) "logs" | ||
["enabled"]=> | ||
bool(false) | ||
["version"]=> | ||
string(0) "" | ||
["compatible"]=> | ||
NULL | ||
["auto_enabled"]=> | ||
NULL | ||
} | ||
} | ||
} | ||
--CLEAN-- | ||
<?php | ||
|
||
@unlink(__DIR__ . '/integration-telemetry.out'); |