Commit 05d785e
feat(datadog-ffe): server-side EVP flagevaluation payload + bincode-safe sidecar delivery (#2117)
## Motivation
PHP relies on libdatadog and the sidecar for server-side flag-evaluation
delivery, so the shared sidecar path must preserve the same
worker-facing EVP contract as the direct SDK implementations. This
contribution gives PHP a reusable, backend-verifiable flagevaluation
transport without adding a one-off EVP writer in the PHP extension,
which keeps cross-SDK adoption smoother for SDK owners and APM review.
## Changes
- Keeps the sidecar action enum bincode-compatible by appending
`FfeFlagEvaluationBatch` after existing variants.
- Keeps flagevaluation IPC structs bincode-safe; outbound placeholder
stripping happens only in the sidecar flusher before the EVP POST.
- Shares the common Agent EVP proxy endpoint/header/request path between
FFE exposures and flagevaluation delivery.
- Carries `context.evaluation` over IPC as a JSON-object string and
re-expands it to an object for outbound EVP JSON.
- Preserves valid context values such as `false`, `""`, `{}`, and `[]`
in user context.
- Adds the flagevaluation C ABI path without a `reason` argument.
- Supports optional real `targeting_rule.key`.
- Retries reliable enqueue using retained encoded bytes so reconnect
retry does not consume the payload.
- Coalesces PHP flagevaluation batches in the sidecar by schema-visible
dimensions and folds overflow into degraded buckets.
- Splits sidecar EVP POST bodies by encoded uncompressed JSON bytes
under the 5 MiB EVP limit, keeping the existing 512-event chunking as a
secondary guard.
- Degrades an oversized full-tier row by omitting `targeting_key` and
`context`; drops and logs only if the degraded row still cannot fit.
## Decisions
- OpenFeature `reason` is not part of the native ABI, sidecar event,
outbound EVP payload, or aggregation contract.
- Bincode wire compatibility is part of the PHP product path because PHP
reaches EVP through worker-to-sidecar IPC before HTTP.
- FFE exposures and flagevaluation share Agent EVP proxy transport
mechanics; schema-specific payload shaping remains in each flusher
because exposure deduplication and flagevaluation coalescing have
different contracts.
- The flagevaluation sidecar flusher owns worker-facing JSON cleanup so
shared wire structs remain plain enough for positional bincode
serialization.
- Degraded events omit targeting key and context while retaining visible
flag, variant, allocation, error, runtime-default, and targeting-rule
fields.
- Payload splitting happens after sidecar JSON cleanup because that is
where the final uncompressed POST body exists; count-based chunking
alone is not sufficient for the EVP 5 MiB limit.
- PHP consumes this flagevaluation endpoint through the C ABI; the
companion PHP draft points its libdatadog submodule at this PR head.
```mermaid
flowchart TD
A[sidecar receives/coalesces batches] --> B[clean and encode event JSON]
B --> C{candidate POST <= 5 MiB?}
C -- yes --> D[POST through Agent EVP proxy]
C -- no --> E{single full row can degrade?}
E -- yes --> F[omit targeting_key and context]
F --> B
E -- no --> G[drop and log/count]
```
## Validation Evidence
### Dogfooding App
- Companion PHP draft: DataDog/dd-trace-php#3984
- `ffe-dogfooding` `app-php7` and `app-php8-openfeature` were run with
local PHP artifacts using this libdatadog sidecar path.
- Dogfooding ran with the real-backend EVP override: Agent
`DD_EVP_PROXY_CONFIG_ADDITIONAL_ENDPOINTS={}`,
`DD_SKIP_SSL_VALIDATION=false`, and
`DD_REMOTE_CONFIGURATION_NO_TLS_VALIDATION=false`.
- Sent 12 identical evaluations per targeting key for
`ffe-dogfooding-string-flag`:
- `libdd-php7-batch-20260623T020845Z-alpha`
- `libdd-php7-batch-20260623T020845Z-bravo`
- `libdd-php8of-batch-20260623T020845Z-alpha`
- `libdd-php8of-batch-20260623T020845Z-bravo`
- App-side responses returned `variant_2`.
### System Tests
- Companion draft PR: DataDog/system-tests#7187
### Staging End-To-End
- Retriever staging query used `--datacenter us1.staging.dog
--customer-auth=skip` against the `flagevaluation` track for the exact
targeting keys above.
- Retriever returned one backend row per targeting key, each with
`flag.key=ffe-dogfooding-string-flag`, `variant.key=variant_2`,
`allocation.key=allocation-override-392dd7c149f8`, and
`evaluation_count=12`:
- `libdd-php7-batch-20260623T020845Z-alpha`:
`first_evaluation=1782180525878`, `last_evaluation=1782180525985`,
`timestamp=1782180525985`, `evaluation_count=12`
- `libdd-php7-batch-20260623T020845Z-bravo`:
`first_evaluation=1782180525997`, `last_evaluation=1782180526103`,
`timestamp=1782180526103`, `evaluation_count=12`
- `libdd-php8of-batch-20260623T020845Z-alpha`:
`first_evaluation=1782180526245`, `last_evaluation=1782180526344`,
`timestamp=1782180526344`, `evaluation_count=12`
- `libdd-php8of-batch-20260623T020845Z-bravo`:
`first_evaluation=1782180526356`, `last_evaluation=1782180526451`,
`timestamp=1782180526451`, `evaluation_count=12`
---------
Co-authored-by: pr-shepherd-6ad11f[bot] <305617008+pr-shepherd-6ad11f[bot]@users.noreply.github.com>
Co-authored-by: vickie.fridge <vickie.fridge@datadoghq.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent 5876427 commit 05d785e
20 files changed
Lines changed: 3274 additions & 101 deletions
File tree
- .github/workflows
- datadog-sidecar-ffi/src
- datadog-sidecar
- src
- service
- libdd-ffe-test-suite
- benches
- libdd-ffe
- src
- telemetry
- flagevaluation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | | - | |
| 436 | + | |
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
| |||
1011 | 1011 | | |
1012 | 1012 | | |
1013 | 1013 | | |
1014 | | - | |
1015 | 1014 | | |
1016 | 1015 | | |
1017 | 1016 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| |||
1216 | 1221 | | |
1217 | 1222 | | |
1218 | 1223 | | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
1219 | 1243 | | |
1220 | 1244 | | |
1221 | 1245 | | |
| |||
1287 | 1311 | | |
1288 | 1312 | | |
1289 | 1313 | | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
1290 | 1386 | | |
1291 | 1387 | | |
1292 | 1388 | | |
| |||
1351 | 1447 | | |
1352 | 1448 | | |
1353 | 1449 | | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
1354 | 1551 | | |
1355 | 1552 | | |
1356 | 1553 | | |
| |||
1371 | 1568 | | |
1372 | 1569 | | |
1373 | 1570 | | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
1374 | 1582 | | |
1375 | 1583 | | |
1376 | 1584 | | |
| |||
1792 | 2000 | | |
1793 | 2001 | | |
1794 | 2002 | | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
1795 | 2020 | | |
1796 | 2021 | | |
1797 | 2022 | | |
| |||
1825 | 2050 | | |
1826 | 2051 | | |
1827 | 2052 | | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
1828 | 2121 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
0 commit comments