Skip to content

feat(openfeature): parse observeFullEvaluationData and hash targeting_key in flagevaluations events - #5151

Open
vjfridge wants to merge 3 commits into
mainfrom
vickie/ffl-2962-protecting-pii-in-flagevaluations-track
Open

feat(openfeature): parse observeFullEvaluationData and hash targeting_key in flagevaluations events#5151
vjfridge wants to merge 3 commits into
mainfrom
vickie/ffl-2962-protecting-pii-in-flagevaluations-track

Conversation

@vjfridge

@vjfridge vjfridge commented Aug 5, 2026

Copy link
Copy Markdown

Motivation

A server SDK upgrade must not silently ship subject PII (emails, account IDs, evaluation context) to the flagevaluations track. The product metric — unique-subject counts per (flag, allocation) — needs a stable per-subject identifier, not the raw subject. This PR sends a one-way SHA-256 fingerprint by default and makes full-fidelity collection an explicit per-environment opt-in.

Tracked by FFL-2962, under the server-SDK fan-out FFL-2784. The Java pilot is dd-trace-java#12042. The base track for Go was #4886. Cross-SDK contract tests were merged in system-tests#7316.

What does this PR do?

This PR makes the no-PII path the default for server-side flagevaluation events. A new UFC boolean observeFullEvaluationData selects the path.

observeFullEvaluationData targeting_key on the wire context.evaluation on the wire
true raw, verbatim included, raw
false or absent (default) sha256_ + 64-char lowercase hex (71 chars total) omitted

User impact:

  • Upgraded SDKs stop shipping raw subject PII to the flagevaluations track unless the environment opts in.
  • Unique-subject counts per (flag, allocation) stay accurate. Every SDK produces a byte-identical digest for the same subject, so hashed values join across languages.
  • Any dashboard or query that reads targeting_key as the raw subject must accept the sha256_ prefix on the default path.
  • The DD_FLAGGING_EVALUATION_COUNTS_ENABLED kill switch is unchanged. It still disables the track entirely.

Key design points:

  • UFC read. observeFullEvaluationData sits at the root of the UFC, a sibling of environment. The custom UnmarshalJSON copies only the fields its shadow struct lists, so the field is added to both the struct and the shadow struct. Absent and explicit null both fail closed to false.
  • Consent lifecycle. The evaluator snapshots consent from the exact configuration it evaluated against and stamps the value on evaluation metadata under the cross-SDK key observe_full_evaluation_data. Nothing downstream of the evaluator reads live configuration, so a Remote Config update between evaluation and flush cannot retroactively apply another environment's policy. The Java pilot hit this bug. A regression test guards both directions.
  • Hashing. Unsalted SHA-256 over the raw UTF-8 bytes as received. No trimming, no case folding, no Unicode normalization. The hash runs once per aggregation bucket at flush cadence, not per evaluation.
  • Aggregation. Consent is part of the full-tier bucket key, so mixed-consent evaluations never merge. The bucket entry also AND-folds consent as defense in depth. When consent is off, the context is dropped from the bucket key and never captured — the key must carry only dimensions that survive serialization.

No new configuration keys, no dependency changes, no generated files affected.

QA

L1 — Unit tests: done.

L2 — Dogfooding: done. Ran this branch against ffe-dogfooding with the staging org (dd.datad0g.com). Tracer built as v2.11.0-dev.1.

observeFullEvaluationData targeting_key (wire) context.evaluation mock-intake pii_class evaluations observed
true (default staging state) raw (user-xxx) present, raw full ~100+
false (flipped for ~2 min) sha256_<64 hex> (71 chars) absent protected 165 protected vs 5 full

The 5 "full" entries under the consent-off flip are the last flush cycle before Remote Config delivered the new UFC. Every event after the RC refresh is protected. The staging environment was restored to true after verification.

L3 — System-tests: done locally, still owed in CI. Ran the FEATURE_FLAGGING_AND_EXPERIMENTATION scenario from DataDog/system-tests locally against this branch (golang@2.11.0-dev.1, weblog variant net-http).
Results: 26 passed, 2 skipped, 0 failed.

  • tests/ffe/test_flag_eval_evp.py: 11/11 passed, including the three tests unlocked by this PR and Test_FFE_EVP_Flagevaluation_Degradation (previously flaky, now clean).
  • tests/ffe/test_flag_eval_metrics.py: 15 passed, 2 skipped (pre-existing irrelevant markers, unrelated to this PR).

A companion system-tests PR must remove the four manifest lines above to enable these tests in CI for Go.

How to reproduce the L2 verification yourself

Run the tracer against ffe-dogfooding with the staging org:

DD_TRACE_GO_PATH=/path/to/dd-trace-go dd-auth --domain dd.datad0g.com -- env DD_SITE=datad0g.com \
  docker compose -f docker-compose.yml -f local/docker-compose.go.yml up -d --build
# wait ~60s for first flush
curl -s "http://localhost:8090/logs?service=ffe-dogfooding-go&limit=1" | jq .
# open http://localhost:8080 for the dashboard

Flip consent (requires app and API keys with feature_flag_environment_config_write):

# fetch current, then PUT with observe_full_evaluation_data flipped
curl -s -H "DD-API-KEY: $DD_API_KEY" -H "DD-APPLICATION-KEY: $DD_APP_KEY" \
  "https://api.datad0g.com/api/v2/feature-flags/environments/<env-id>"

The flip touches the shared Staging environment on dd.datad0g.com. Anything else running under DD_ENV=staging picks up the change too. Flip back promptly.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag. Tests already exist from system-tests#7316. The manifest activation is a companion PR. See "QA" above.
  • There is a benchmark for any new code, or changes to existing code. Hashing runs once per bucket at flush cadence, off the evaluation hot path. The existing BenchmarkFlagEvaluationOTelPlusEVPParallel still covers the aggregation path.
  • If this interacts with the agent in a new way, a system test has been added. No new agent interaction. Same EVP endpoint and payload shape.
  • New code is free of linting errors. Run make lint locally.
  • New code does not break existing tests. Run make test locally.
  • Add an appropriate team label so this PR goes to the right release notes.
  • All generated files are up to date. Run make generate locally. No generated files or configuration keys touched.
  • Non-trivial go.mod changes: none. crypto/sha256 and encoding/hex are stdlib.

🤖 Generated with Claude Code

…_key in flagevaluations events

Make the no-PII path the default for server-side EVP flagevaluation events,
driven by the new top-level UFC boolean observeFullEvaluationData.

Without consent, targeting_key is emitted as an unsalted SHA-256 fingerprint
prefixed with "sha256_" (71 chars) and context.evaluation is omitted entirely
(absent key, not null, not {}). With consent, both are emitted verbatim. Absent
or null consent fails closed. The digest is taken over the raw UTF-8 bytes with
no trim, case folding, or Unicode normalization so digests join across SDKs.

Consent is snapshotted in the evaluator from the exact configuration the
evaluation ran against and stamped onto evaluation metadata under the
cross-SDK key observe_full_evaluation_data. Nothing downstream of the
evaluator reads live configuration, so a Remote Config update landing between
evaluation and flush cannot retroactively apply another environment's policy.

Consent is part of the full-tier bucket key so mixed-consent evaluations never
merge, with an AND-fold on the bucket's consent field as defense in depth. When
consent is off the context is dropped from the key and never captured, because
the key must carry exactly the dimensions that survive serialization; keying on
a discarded context would burn the per-flag bucket cap on precisely the
privacy-protected traffic. Consent is deliberately not a degraded-tier
dimension: that tier emits neither targeting_key nor context, so it would add
cardinality with no privacy gain.

DoLog does not gate this behavior, and the
DD_FLAGGING_EVALUATION_COUNTS_ENABLED kill switch still disables the track
entirely.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vjfridge
vjfridge requested a review from a team as a code owner August 5, 2026 18:20
@vjfridge
vjfridge requested review from dd-oleksii and leoromanovsky and removed request for a team August 5, 2026 18:20
@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Aug 5, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 95.59%
Overall Coverage: 64.61% (+12.28%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1346e7e | Docs | Datadog PR Page | Give us feedback!

@vjfridge

vjfridge commented Aug 5, 2026

Copy link
Copy Markdown
Author

System-tests results against this PR

Ran the FEATURE_FLAGGING_AND_EXPERIMENTATION scenario from DataDog/system-tests locally against this branch (golang@2.11.0-dev.1, weblog variant net-http).

To exercise the new behavior end-to-end, I locally removed the following markers from manifests/golang.yml:

  • tests/ffe/test_flag_eval_evp.py::Test_FFE_EVP_Flagevaluation_ObserveFullData_Absent_Hashed: missing_feature (FFL-2784)
  • tests/ffe/test_flag_eval_evp.py::Test_FFE_EVP_Flagevaluation_ObserveFullData_False_Hashed: missing_feature (FFL-2784)
  • tests/ffe/test_flag_eval_evp.py::Test_FFE_EVP_Flagevaluation_ObserveFullData_True_Unhashed: missing_feature (FFL-2784)
  • tests/ffe/test_flag_eval_evp.py::Test_FFE_EVP_Flagevaluation_Degradation::test_ffe_evp_flagevaluation_degradation: flaky (FFL-2676)

Results: 26 passed, 2 skipped, 0 failed

tests/ffe/test_flag_eval_evp.py: 11/11 passed, including the three tests unlocked by this PR:

  • Test_FFE_EVP_Flagevaluation_ObserveFullData_Absent_Hashed
  • Test_FFE_EVP_Flagevaluation_ObserveFullData_False_Hashed
  • Test_FFE_EVP_Flagevaluation_ObserveFullData_True_Unhashed
  • Test_FFE_EVP_Flagevaluation_Degradation (previously marked flaky — passed cleanly)
  • Plus: Basic, Count, Context_Bounds, Runtime_Default, Load_Aggregation, Burst_Aggregation, High_Cardinality_Aggregation

tests/ffe/test_flag_eval_metrics.py: 15 passed, 2 skipped

  • The 2 skips are pre-existing irrelevant markers unrelated to this PR (Invalid_Regex — Go validates at config load time; Nested_Attributes_Ignored).

Follow-up

A companion system-tests PR should remove the four manifest lines above to enable these tests in CI for Go.

@pr-commenter

pr-commenter Bot commented Aug 5, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-05 22:03:49

Comparing candidate commit 1346e7e in PR branch vickie/ffl-2962-protecting-pii-in-flagevaluations-track with baseline commit f0c4277 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 326 metrics, 0 unstable metrics, 1 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

Known flaky benchmarks without significant changes:

  • scenario:BenchmarkOTLPTraceWriterFlush

@vjfridge

vjfridge commented Aug 5, 2026

Copy link
Copy Markdown
Author

L2 dogfooding — both consent paths verified end-to-end ✅

Ran this branch against ffe-dogfooding with the staging org (dd.datad0g.com). Tracer built as v2.11.0-dev.1.

observeFullEvaluationData targeting_key (wire) context.evaluation mock-intake pii_class evals observed
true (default staging state) raw (user-xxx) present, raw full ~100+
false (flipped for ~2 min) sha256_<64 hex> (71 chars) absent protected 165 protected vs 5 full

The 5 "full" entries under the consent-off flip are the last flush cycle that occurred before RC delivered the new UFC — everything after the RC refresh is protected. Restored the environment to true after verification.

Behaviors observed exactly matching the PR's contract table:

  • Root-level observeFullEvaluationData is picked up by the shadow-struct unmarshaller
  • Consent snapshot from the config-under-evaluation is preserved through flush (no config-update race)
  • Bucket keys carry consent — mixed-consent evaluations don't merge
  • Unsalted SHA-256 over raw UTF-8 targeting_key bytes; no trim/case-fold/normalization
  • context.evaluation is entirely omitted from the wire payload when consent is off
  • The 5→165 transition happened cleanly at the RC refresh boundary; no partial or corrupted payloads observed in between

Reproduce

DD_TRACE_GO_PATH=/path/to/dd-trace-go dd-auth --domain dd.datad0g.com -- env DD_SITE=datad0g.com \
  docker compose -f docker-compose.yml -f local/docker-compose.go.yml up -d --build
# wait ~60s for first flush
curl -s "http://localhost:8090/logs?service=ffe-dogfooding-go&limit=1" | jq .
# open http://localhost:8080 for the dashboard

To flip consent (requires app+api keys with feature_flag_environment_config_write):

# fetch current, then PUT with observe_full_evaluation_data flipped
curl -s -H "DD-API-KEY: $DD_API_KEY" -H "DD-APPLICATION-KEY: $DD_APP_KEY" \
  "https://api.datad0g.com/api/v2/feature-flags/environments/<env-id>"

Note: this touches the shared "Staging" environment on dd.datad0g.com — anything else running under DD_ENV=staging will pick up the change too. Flip back promptly.

L3 system-tests still owed per the PR's Validation status section. L1 already covers the hashed vector exhaustively (jane.doe@datadoghq.comsha256_b4698f9b…c99e51b).

Condense the added rationale comments to <=3 lines while preserving the
load-bearing "why": consent snapshot must travel with the evaluation,
AND-fold defense against key drift, empty-targeting-key must not hash,
shadow struct is sole populator, fail-closed default.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant