Skip to content

feat(go): Enable flag evaluation metrics E2E tests for Go; fix reason=static#6410

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 14 commits intomainfrom
leo.romanovsky/ffe-eval-metrics
Mar 12, 2026
Merged

feat(go): Enable flag evaluation metrics E2E tests for Go; fix reason=static#6410
gh-worker-dd-mergequeue-cf854d[bot] merged 14 commits intomainfrom
leo.romanovsky/ffe-eval-metrics

Conversation

@leoromanovsky
Copy link
Contributor

@leoromanovsky leoromanovsky commented Mar 2, 2026

Motivation

Per the RFC "Flag evaluations tracking for APM tracers": collect a feature_flag.evaluations OTel counter metric on each flag evaluation to track SDK usage. These system tests validate the end-to-end pipeline: evaluation in the weblog → OTel SDK aggregation → OTLP export to agent → agent forwards to proxy → system tests assert on interfaces.agent.get_metrics().

Changes

  • tests/ffe/test_flag_eval_metrics.py: 5 E2E test classes for Go:
    • Test_FFE_Eval_Metric_Basic: metric exists with correct feature_flag.key, variant, reason=static, allocation_key tags
    • Test_FFE_Eval_Metric_Count: same flag evaluated 5× → metric count ≥ 5
    • Test_FFE_Eval_Metric_Different_Flags: two flags → two separate metric series
    • Test_FFE_Eval_Metric_Error: non-existent flag → reason=error, error.type=flag_not_found
    • Test_FFE_Eval_Metric_Type_Mismatch: STRING flag evaluated as BOOLEAN → reason=error, error.type=type_mismatch
  • manifests/golang.yml: Enable metrics tests for Go at v2.7.0-dev.
  • All other language manifests: missing_feature (pending tracer implementation).
  • utils/_context/_scenarios/__init__.py: Add DD_METRICS_OTEL_ENABLED=true, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, and agent_interface_timeout=30 to the FFE scenario.
  • utils/build/docker/golang/app/_shared/common/ffe.go: Dispatch /ffe by variationType instead of always calling ofClient.Object(), enabling type mismatch errors.

Decisions

reason=static not targeting_match. The UFC engine returns AssignmentReason::Static for a 100% catch-all allocation (empty rules array, single split with shards:[]). The test fixtures use this shape, so the assertion reflects the actual engine output.

agent_interface_timeout=30 at scenario level. The OTLP pipeline (OTel SDK export + agent flush + proxy buffer) needs up to 30s to propagate. Moving the wait to the scenario level via agent_interface_timeout replaces per-test sleep() calls.

OTLP metrics endpoint direct to agent. The FFE scenario's DD_TRACE_AGENT_URL points to the proxy, which has no OTLP receiver. OTEL_EXPORTER_OTLP_METRICS_ENDPOINT is set directly to agent:4318/v1/metrics to bypass the proxy for metric export. The agent then forwards processed metrics to /api/v2/series, where system tests capture them.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

CODEOWNERS have been resolved as:

tests/ffe/test_flag_eval_metrics.py                                     @DataDog/feature-flagging-and-experimentation-sdk @DataDog/system-tests-core
manifests/cpp_httpd.yml                                                 @DataDog/dd-trace-cpp
manifests/cpp_kong.yml                                                  @DataDog/system-tests-core
manifests/cpp_nginx.yml                                                 @DataDog/dd-trace-cpp
manifests/dotnet.yml                                                    @DataDog/apm-dotnet @DataDog/asm-dotnet
manifests/golang.yml                                                    @DataDog/dd-trace-go-guild
manifests/java.yml                                                      @DataDog/asm-java @DataDog/apm-java
manifests/nodejs.yml                                                    @DataDog/dd-trace-js
manifests/php.yml                                                       @DataDog/apm-php @DataDog/asm-php
manifests/python.yml                                                    @DataDog/apm-python @DataDog/asm-python
manifests/ruby.yml                                                      @DataDog/ruby-guild @DataDog/asm-ruby
manifests/rust.yml                                                      @DataDog/apm-rust
utils/_context/_scenarios/__init__.py                                   @DataDog/system-tests-core
utils/build/docker/golang/app/_shared/common/ffe.go                     @DataDog/dd-trace-go-guild @DataDog/system-tests-core

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Mar 3, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0951079 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@leoromanovsky leoromanovsky marked this pull request as ready for review March 3, 2026 22:35
@leoromanovsky leoromanovsky requested review from a team as code owners March 3, 2026 22:35
…test

The Go weblog was calling ofClient.Object() for all evaluations,
ignoring the variationType field. This meant type conversion errors
could never occur, unlike Python/Node.js which dispatch to the
type-specific methods (BooleanValue, StringValue, etc.).

Fix the Go weblog to dispatch based on variationType, matching the
behavior of other language weblogs.

Add Test_FFE_Eval_Metric_Type_Mismatch: configures a STRING flag but
evaluates it as BOOLEAN, triggering a type conversion error that
happens after the core evaluate() returns. This test would fail with
the old evaluate()-level metric recording (which would see
targeting_match / no error) and only passes when metrics are recorded
via a Finally hook (which sees error / type_mismatch).
Only Go supports flag evaluation metrics via OTel so far. Without this,
the test file runs for all FFE-enabled languages and fails.
Replace hardcoded time.sleep(25) in each test setup with
agent_interface_timeout=30 on the FFE scenario. The container
shutdown flushes metrics; the timeout gives the agent time to
receive and process them.
Assert that feature_flag.result.allocation_key tag is present
with value "default-allocation" on successful flag evaluations.
- Enable tests/ffe/test_flag_eval_metrics.py for PHP (>=1.16.0) and Node.js (express4 v6.0.0-pre)
- Fix reason assertion: UFC engine returns AssignmentReason::Static for a 100%
  catch-all allocation (rules:[], splits:[{shards:[]}]), not TargetingMatch
- Add type annotations to test helpers (mypy compliance)
@leoromanovsky leoromanovsky force-pushed the leo.romanovsky/ffe-eval-metrics branch from d342bb1 to a33486a Compare March 11, 2026 19:13
@leoromanovsky leoromanovsky changed the title feat(ffe): add flag evaluation metrics E2E tests (Go + PHP) feat(ffe): add flag evaluation metrics E2E tests (Go + PHP + Node) Mar 11, 2026
…=static

- Enable tests/ffe/test_flag_eval_metrics.py for Go only (PHP and Node.js remain missing_feature)
- Fix reason assertion: UFC engine returns AssignmentReason::Static for a 100%
  catch-all allocation (rules:[], splits:[{shards:[]}]), not TargetingMatch
- Add type annotations to test helpers (mypy compliance)
@leoromanovsky leoromanovsky changed the title feat(ffe): add flag evaluation metrics E2E tests (Go + PHP + Node) feat(go): Enable flag evaluation metrics E2E tests for Go; fix reason=static Mar 11, 2026
@leoromanovsky
Copy link
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351
Copy link

gh-worker-devflow-routing-ef8351 bot commented Mar 12, 2026

View all feedbacks in Devflow UI.

2026-03-12 22:40:28 UTC ℹ️ Start processing command /merge


2026-03-12 22:40:58 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-03-12 23:09:07 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 8m (p90).


2026-03-12 23:09:51 UTC ℹ️ MergeQueue: This merge request was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants