Repository navigation
fix(ffe): fall back to direct EVP intake in agentless mode #4489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+495
−11
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7aecaff
fix(ffe): deliver agentless events directly when no Agent is available
leoromanovsky ec428b1
fix(ffe): preserve updated EVP tokens and wait for sidecar delivery
leoromanovsky a122cbc
test(ffe): serve concurrent EVP requests without blocking
leoromanovsky cde25b7
Merge latest master into PHP agentless EVP fallback
leoromanovsky 4984b2f
Fix FFE local discovery across agentless setup and tracing modes
leoromanovsky b85fc8d
Merge branch 'master' into leo/php-agentless-evp-fallback-20261112
leoromanovsky 837fb5f
Merge branch 'master' of github.com:DataDog/dd-trace-php into leo/php…
bwoebi a98560d
test(ffe): fix agentless EVP transport tests under valgrind and on Wi…
bwoebi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,27 @@ | ||
| --TEST-- | ||
| FFE keeps local EVP discovery when managed CDN setup fails | ||
| --SKIPIF-- | ||
| <?php | ||
| if (PHP_VERSION_ID < 70200) die('skip: TEST_PHP_EXTRA_ARGS requires PHP 7.2+'); | ||
| if (!function_exists('proc_open') || !function_exists('stream_socket_server')) die('skip: subprocess sockets required'); | ||
| if (!getenv('TEST_PHP_EXECUTABLE')) die('skip: TEST_PHP_EXECUTABLE required'); | ||
| ?> | ||
| --ENV-- | ||
| DD_TRACE_CLI_ENABLED=1 | ||
| DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
| DD_REMOTE_CONFIG_ENABLED=0 | ||
| DD_INSTRUMENTATION_TELEMETRY_ENABLED=0 | ||
| DD_METRICS_OTEL_ENABLED=0 | ||
| DD_TRACE_AGENT_TIMEOUT=5000 | ||
| DD_SERVICE=php-ffe-transport | ||
| DD_FLAGGING_EVALUATION_COUNTS_ENABLED=1 | ||
| --FILE-- | ||
| <?php | ||
| $modes = array('managed-no-key', 'managed-invalid-site'); | ||
| require __DIR__ . '/stubs/agentless_evp_transport.inc'; | ||
| ?> | ||
| --EXPECT-- | ||
| managed-no-key/false: expected streams delivered with PHP identity, token and no API key | ||
| managed-no-key/true: expected streams delivered with PHP identity, token and no API key | ||
| managed-invalid-site/false: expected streams delivered with PHP identity, token and no API key | ||
| managed-invalid-site/true: expected streams delivered with PHP identity, token and no API key |
This file contains hidden or 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,31 @@ | ||
| --TEST-- | ||
| FFE local EVP discovery is independent of trace-agentless mode | ||
| --SKIPIF-- | ||
| <?php | ||
| if (PHP_VERSION_ID < 70200) die('skip: TEST_PHP_EXTRA_ARGS requires PHP 7.2+'); | ||
| if (!function_exists('proc_open') || !function_exists('stream_socket_server')) die('skip: subprocess sockets required'); | ||
| if (!getenv('TEST_PHP_EXECUTABLE')) die('skip: TEST_PHP_EXECUTABLE required'); | ||
| ?> | ||
| --ENV-- | ||
| DD_TRACE_CLI_ENABLED=1 | ||
| DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
| DD_REMOTE_CONFIG_ENABLED=0 | ||
| DD_INSTRUMENTATION_TELEMETRY_ENABLED=0 | ||
| DD_METRICS_OTEL_ENABLED=0 | ||
| DD_TRACE_AGENT_TIMEOUT=5000 | ||
| DD_SERVICE=php-ffe-transport | ||
| DD_FLAGGING_EVALUATION_COUNTS_ENABLED=1 | ||
| --FILE-- | ||
| <?php | ||
| $modes = array('trace-agentless', 'trace-agentless-prefix', 'trace-agentless-token', 'trace-agentless-invalid'); | ||
| require __DIR__ . '/stubs/agentless_evp_transport.inc'; | ||
| ?> | ||
| --EXPECT-- | ||
| trace-agentless/false: expected streams delivered with PHP identity, token and no API key | ||
| trace-agentless/true: expected streams delivered with PHP identity, token and no API key | ||
| trace-agentless-prefix/false: expected streams delivered with PHP identity, token and no API key | ||
| trace-agentless-prefix/true: expected streams delivered with PHP identity, token and no API key | ||
| trace-agentless-token/false: expected streams delivered with PHP identity, token and no API key | ||
| trace-agentless-token/true: expected streams delivered with PHP identity, token and no API key | ||
| trace-agentless-invalid/false: invalid local endpoint handled | ||
| trace-agentless-invalid/true: invalid local endpoint handled |
This file contains hidden or 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,31 @@ | ||
| --TEST-- | ||
| FFE agentless discovers a shared local EVP route while Remote Config keeps EVP v2 | ||
| --SKIPIF-- | ||
| <?php | ||
| if (PHP_VERSION_ID < 70200) die('skip: TEST_PHP_EXTRA_ARGS requires PHP 7.2+'); | ||
| if (!function_exists('proc_open') || !function_exists('stream_socket_server')) die('skip: subprocess sockets required'); | ||
| if (!getenv('TEST_PHP_EXECUTABLE')) die('skip: TEST_PHP_EXECUTABLE required'); | ||
| ?> | ||
| --ENV-- | ||
| DD_TRACE_CLI_ENABLED=1 | ||
| DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
| DD_REMOTE_CONFIG_ENABLED=0 | ||
| DD_INSTRUMENTATION_TELEMETRY_ENABLED=0 | ||
| DD_METRICS_OTEL_ENABLED=0 | ||
| DD_TRACE_AGENT_TIMEOUT=5000 | ||
| DD_SERVICE=php-ffe-transport | ||
| DD_FLAGGING_EVALUATION_COUNTS_ENABLED=1 | ||
| --FILE-- | ||
| <?php | ||
| $modes = array('agentless', 'no-key', 'invalid-site', 'remote-config'); | ||
| require __DIR__ . '/stubs/agentless_evp_transport.inc'; | ||
| ?> | ||
| --EXPECT-- | ||
| agentless/false: expected streams delivered with PHP identity, token and no API key | ||
| agentless/true: expected streams delivered with PHP identity, token and no API key | ||
| no-key/false: expected streams delivered with PHP identity, token and no API key | ||
| no-key/true: expected streams delivered with PHP identity, token and no API key | ||
| invalid-site/false: expected streams delivered with PHP identity, token and no API key | ||
| invalid-site/true: expected streams delivered with PHP identity, token and no API key | ||
| remote-config/false: expected streams delivered with PHP identity, token and no API key | ||
| remote-config/true: expected streams delivered with PHP identity, token and no API key |
This file contains hidden or 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,26 @@ | ||
| --TEST-- | ||
| FFE agentless events use the configured Unix socket | ||
| --SKIPIF-- | ||
| <?php | ||
| if (PHP_OS === 'WINNT') die('skip: Unix sockets required'); | ||
| if (PHP_VERSION_ID < 70200) die('skip: TEST_PHP_EXTRA_ARGS requires PHP 7.2+'); | ||
| if (!function_exists('proc_open') || !function_exists('stream_socket_server')) die('skip: subprocess sockets required'); | ||
| if (!getenv('TEST_PHP_EXECUTABLE')) die('skip: TEST_PHP_EXECUTABLE required'); | ||
| ?> | ||
| --ENV-- | ||
| DD_TRACE_CLI_ENABLED=1 | ||
| DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
| DD_REMOTE_CONFIG_ENABLED=0 | ||
| DD_INSTRUMENTATION_TELEMETRY_ENABLED=0 | ||
| DD_METRICS_OTEL_ENABLED=0 | ||
| DD_TRACE_AGENT_TIMEOUT=5000 | ||
| DD_SERVICE=php-ffe-transport | ||
| DD_FLAGGING_EVALUATION_COUNTS_ENABLED=1 | ||
| --FILE-- | ||
| <?php | ||
| $modes = array('trace-agentless-unix'); | ||
| require __DIR__ . '/stubs/agentless_evp_transport.inc'; | ||
| ?> | ||
| --EXPECT-- | ||
| trace-agentless-unix/false: expected streams delivered with PHP identity, token and no API key | ||
| trace-agentless-unix/true: expected streams delivered with PHP identity, token and no API key |
This file contains hidden or 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,24 @@ | ||
| <?php | ||
| // Drain startup configuration before submitting a best-effort observation. | ||
| // This is a routing test, not a shutdown or load-shedding test. | ||
| dd_trace_synchronous_flush(); | ||
| $failed = getenv('PHP_FFE_TRANSPORT_FAILURE') === 'true'; | ||
| if (!$failed && !\DDTrace\Testing\ffe_load_config(file_get_contents(__DIR__ . '/agentless_evp_config.json'))) { | ||
| throw new RuntimeException('configuration rejected'); | ||
| } | ||
| foreach (explode(',', getenv('PHP_FFE_TRANSPORT_TOKENS')) as $token) { | ||
| ini_set('datadog.trace.agent_test_session_token', $token); | ||
| $result = \DDTrace\ffe_evaluate('transport-flag', \DDTrace\FFE_STRING, 'transport-user-' . $token, array()); | ||
| if (!$failed && (!$result || $result->valueJson !== '"blue"')) throw new RuntimeException('evaluation failed'); | ||
| // Native error code 6 is PROVIDER_NOT_READY. | ||
| if ($failed && (\DDTrace\ffe_has_config() || !$result || $result->errorCode !== 6)) { | ||
| throw new RuntimeException('expected provider-not-ready evaluation'); | ||
| } | ||
| if (!\DDTrace\Internal\record_ffe_flag_evaluation( | ||
| 'transport-flag', $failed ? null : 'blue', null, 'transport-user-' . $token, array(), | ||
| $failed ? 'PROVIDER_NOT_READY' : null, $failed, false, 1700000000123 | ||
| )) throw new RuntimeException('evaluation count submission rejected'); | ||
| if (!$failed && !\DDTrace\Testing\flush_ffe_exposures()) throw new RuntimeException('exposure handoff failed'); | ||
| } | ||
| dd_trace_synchronous_flush(); | ||
| echo "delivered\n"; |
This file contains hidden or 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,17 @@ | ||
| { | ||
| "createdAt": "2026-05-22T00:00:00Z", | ||
| "format": "SERVER", | ||
| "environment": {"name": "test"}, | ||
| "flags": { | ||
| "transport-flag": { | ||
| "key": "transport-flag", | ||
| "enabled": true, | ||
| "variationType": "STRING", | ||
| "variations": {"on": {"key": "on", "value": "blue"}}, | ||
| "allocations": [{ | ||
| "key": "allocation", "rules": [], "doLog": true, | ||
| "splits": [{"variationKey": "on", "serialId": 7, "shards": []}] | ||
| }] | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.