Skip to content

fix: add missing variant dimension in MetricsHook metrics#742

Merged
askpt merged 1 commit into
mainfrom
askpt/issue741
Apr 17, 2026
Merged

fix: add missing variant dimension in MetricsHook metrics#742
askpt merged 1 commit into
mainfrom
askpt/issue741

Conversation

@askpt
Copy link
Copy Markdown
Member

@askpt askpt commented Apr 15, 2026

Summary

Fixes #741

The MetricsHook.AfterAsync method was not including feature_flag.result.variant as a dimension/tag on the feature_flag.evaluation_success_total metric. This is inconsistent with:

Changes

  • src/OpenFeature/Hooks/MetricsHook.cs: Added details.Variant to the tag list in AfterAsync, guarded by a null check (matching the Java SDK pattern). Uses the existing TelemetryConstants.Variant constant.
  • test/OpenFeature.Tests/Hooks/MetricsHookTests.cs:
    • Updated After_Test to assert the variant tag is present on success metrics.
    • Added Without_Variant_After_Test_Does_Not_Include_Variant test to verify the tag is omitted when variant is null.

Notes

Metrics now include the missing variant. See screenshot:
Screenshot 2026-04-15 at 16 28 28

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
@askpt askpt requested a review from a team as a code owner April 15, 2026 15:30
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.47%. Comparing base (98c394f) to head (6f9c8e9).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #742   +/-   ##
=======================================
  Coverage   93.46%   93.47%           
=======================================
  Files          68       68           
  Lines        2952     2956    +4     
  Branches      350      351    +1     
=======================================
+ Hits         2759     2763    +4     
  Misses        135      135           
  Partials       58       58           

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the MetricsHook to include the evaluation variant in telemetry tags when it is available. It also includes corresponding unit tests to verify that the variant tag is correctly added when present and omitted when null. I have no feedback to provide.

@askpt askpt added this pull request to the merge queue Apr 17, 2026
Merged via the queue into main with commit dad175d Apr 17, 2026
26 of 27 checks passed
@askpt askpt deleted the askpt/issue741 branch April 17, 2026 05:45
This was referenced Apr 30, 2026
This was referenced May 12, 2026
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.

[BUG] Missing Variant in MetricsHook Metrics

3 participants