Skip to content

fix(evaluation): gate metrics recording behind WithMetrics option#6042

Merged
kodiakhq[bot] merged 4 commits into
v2from
rd/v2/perf-metrics
Jun 25, 2026
Merged

fix(evaluation): gate metrics recording behind WithMetrics option#6042
kodiakhq[bot] merged 4 commits into
v2from
rd/v2/perf-metrics

Conversation

@erka

@erka erka commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Evaluation metrics (evaluations total, results, errors, latency) were
previously recorded unconditionally for every flag evaluation. This adds
a WithMetrics(bool) option to the evaluation server, gating all metric
recording behind cfg.Metrics.Enabled.

  • Add WithMetrics(bool) option and metricsEnabled field to Server
  • Gate all metric recording in variant() and boolean() behind the flag
  • Extract baseMetricSet to eliminate duplicate attribute.NewSet calls
  • Lift segmentKeys/matched/reason/segmentMatches out of rule loop
    scope to fix shadowed := assignments
  • Order metric attributes by OTel key name (alphabetical)
  • Wire option in grpc.go with cfg.Metrics.Enabled
  • Add OTel ManualReader test infrastructure and error-path metric tests

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.75%. Comparing base (4ca4191) to head (066658a).

Additional details and impacted files
@@            Coverage Diff             @@
##               v2    #6042      +/-   ##
==========================================
+ Coverage   61.65%   61.75%   +0.10%     
==========================================
  Files         142      142              
  Lines       14430    14442      +12     
==========================================
+ Hits         8897     8919      +22     
+ Misses       4790     4784       -6     
+ Partials      743      739       -4     
Flag Coverage Δ
integrationtests 34.30% <84.26%> (+0.02%) ⬆️
unittests 52.97% <98.87%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erka
erka force-pushed the rd/v2/perf-metrics branch from d601e40 to 6932ddb Compare June 16, 2026 18:09

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approve

Clean change — the metrics gating is correctly wired, the shadowed-variable fix is safe, and the new error-path metric tests cover the important cases. No changes requested.

🤖 Automated review by the Flipt PR review agent.

erka added 2 commits June 23, 2026 14:48
Evaluation metrics (evaluations total, results, errors, latency) were
previously recorded unconditionally for every flag evaluation. This adds
a `WithMetrics(bool)` option to the evaluation server, gating all metric
recording behind `cfg.Metrics.Enabled`.

- Add `WithMetrics(bool)` option and `metricsEnabled` field to Server
- Gate all metric recording in variant() and boolean() behind the flag
- Extract `baseMetricSet` to eliminate duplicate attribute.NewSet calls
- Lift `segmentKeys`/`matched`/`reason`/`segmentMatches` out of rule loop
  scope to fix shadowed := assignments
- Order metric attributes by OTel key name (alphabetical)
- Wire option in grpc.go with `cfg.Metrics.Enabled`
- Add OTel ManualReader test infrastructure and error-path metric tests

Signed-off-by: Roman Dmytrenko <[email protected]>
Signed-off-by: Roman Dmytrenko <[email protected]>
@erka
erka force-pushed the rd/v2/perf-metrics branch from 558ab2f to 7dd0722 Compare June 23, 2026 13:48
@erka
erka marked this pull request as ready for review June 23, 2026 20:02
@erka
erka requested a review from a team as a code owner June 23, 2026 20:02
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 23, 2026

@markphelps markphelps left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one

@erka erka added automerge Used by Kodiak bot to automerge PRs v2 Flipt v2 labels Jun 25, 2026
@kodiakhq
kodiakhq Bot merged commit a01f91b into v2 Jun 25, 2026
35 checks passed
@kodiakhq
kodiakhq Bot deleted the rd/v2/perf-metrics branch June 25, 2026 15:20
@github-project-automation github-project-automation Bot moved this to Done in Flipt V2 Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Used by Kodiak bot to automerge PRs size:L This PR changes 100-499 lines, ignoring generated files. v2 Flipt v2

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants