Skip to content

feat: add support for http-based ofrep metrics#1803

Merged
beeme1mr merged 4 commits into
mainfrom
ofrep-metrics
Sep 23, 2025
Merged

feat: add support for http-based ofrep metrics#1803
beeme1mr merged 4 commits into
mainfrom
ofrep-metrics

Conversation

@beeme1mr

Copy link
Copy Markdown
Member

This PR

  • adds support for HTTP-based OFREP metrics

Notes

The middleware to capture HTTP-based metrics was never registered in OFREP service. This PR leverages the same metric configuration used for RPC evaluations.

The original question came from Slack:

https://cloud-native.slack.com/archives/C03J36ZP020/p1758305815794859

How to test

Run flagd locally and use a local Prometheus instance.

https://flagd.dev/reference/monitoring/

Here's a screenshot of the results.

image

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
@beeme1mr beeme1mr requested review from a team as code owners September 22, 2025 17:24
@netlify

netlify Bot commented Sep 22, 2025

Copy link
Copy Markdown

Deploy Preview for polite-licorice-3db33c canceled.

Name Link
🔨 Latest commit f1ac1ed
🔍 Latest deploy log https://app.netlify.com/projects/polite-licorice-3db33c/deploys/68d19f657043ca0008c4ac70

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Sep 22, 2025
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @beeme1mr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a gap in the OFREP service by enabling HTTP-based metrics. Previously, the necessary middleware for capturing these metrics was not registered, hindering observability for HTTP flag evaluations. By integrating the existing metrics configuration and middleware, this change ensures that the OFREP service now properly records and exposes HTTP-related metrics, aligning its monitoring capabilities with those of RPC evaluations.

Highlights

  • HTTP Metrics Enabled: Enabled HTTP-based metrics for the OFREP service by registering the previously missing metrics middleware, ensuring better observability for HTTP flag evaluations.
  • Service Configuration Update: Extended the SvcConfiguration struct for the OFREP service to include ServiceName and MetricsRecorder fields, allowing for proper metric collection and integration.
  • Middleware Integration: Integrated the HTTPMetric middleware into the OFREP service's HTTP handler chain, ensuring that all HTTP requests are now subject to metric capture alongside CORS handling.
  • Test Coverage: Updated unit tests for the OFREP service to correctly initialize the SvcConfiguration with a NoopMetricsRecorder, maintaining test integrity with the new metric capabilities.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request adds support for HTTP-based metrics to the OFREP service by registering a metrics middleware. The implementation is mostly correct, but it misses passing the service name to the OFREP service configuration. This would lead to a missing service.name attribute in the generated metrics. I've added suggestions to fix this in both the runtime configuration and the associated test file.

Comment thread flagd/pkg/runtime/from_config.go
Comment thread flagd/pkg/service/flag-evaluation/ofrep/ofrep_service_test.go
Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
@beeme1mr

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request adds support for HTTP-based metrics to the OFREP service by registering a metrics middleware. The implementation correctly wires up the existing metrics configuration. However, I've identified a couple of issues with how the metrics middleware is used that could lead to high cardinality in metrics and incorrect status code reporting. My review includes a detailed comment on how to address these potential problems.

Comment thread flagd/pkg/service/flag-evaluation/ofrep/ofrep_service.go Outdated
Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Sep 22, 2025
Comment thread flagd/pkg/service/flag-evaluation/ofrep/handler.go
Comment thread flagd/pkg/service/flag-evaluation/ofrep/handler.go
@beeme1mr

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request adds support for HTTP-based OFREP metrics by registering the metrics middleware. The changes look good and correctly wire up the metrics recorder from the configuration down to the HTTP handlers. I've found one area for improvement regarding code duplication in the handler registration, which can be refactored for better maintainability.

Comment thread flagd/pkg/service/flag-evaluation/ofrep/handler.go
@beeme1mr beeme1mr merged commit fcd19b3 into main Sep 23, 2025
15 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 23, 2025
toddbaert added a commit that referenced this pull request Dec 24, 2025
🤖 I have created a release *beep* *boop*
---


<details><summary>flagd: 0.13.0</summary>

##
[0.13.0](flagd/v0.12.9...flagd/v0.13.0)
(2025-12-23)


### 🐛 Bug Fixes

* fixing sync return format missing flag layer, adding full e2e suite
([#1827](#1827))
([570693d](570693d))
* **security:** update module github.com/go-viper/mapstructure/v2 to
v2.4.0 [security]
([#1784](#1784))
([037e30b](037e30b))
* **security:** update module golang.org/x/crypto to v0.45.0 [security]
([#1826](#1826))
([7e0762b](7e0762b))


### ✨ New Features

* add support for http-based ofrep metrics
([#1803](#1803))
([fcd19b3](fcd19b3))
* cleanup evaluator interface
([#1793](#1793))
([aa504f7](aa504f7))
* enable parsing of array flag configurations for flagd
([#1797](#1797))
([97c6ffa](97c6ffa))
* multi-project support via selectors and flagSetId namespacing
([#1702](#1702))
([f9ce46f](f9ce46f))
* normalize selector in sync (use header as in OFREP and RPC)
([#1815](#1815))
([c1f06cb](c1f06cb))


### 🧹 Chore

* **refactor:** use memdb for flag storage
([#1697](#1697))
([5c5c1cf](5c5c1cf))


### 🔄 Refactoring

* store cleanup
([#1705](#1705))
([bcff8d7](bcff8d7))
</details>

<details><summary>flagd-proxy: 0.8.1</summary>

##
[0.8.1](flagd-proxy/v0.8.0...flagd-proxy/v0.8.1)
(2025-12-23)


### 🐛 Bug Fixes

* **security:** update module github.com/go-viper/mapstructure/v2 to
v2.4.0 [security]
([#1784](#1784))
([037e30b](037e30b))
* **security:** update module golang.org/x/crypto to v0.45.0 [security]
([#1826](#1826))
([7e0762b](7e0762b))
</details>

<details><summary>core: 0.13.0</summary>

##
[0.13.0](core/v0.12.1...core/v0.13.0)
(2025-12-23)


### ⚠ BREAKING CHANGES

* enable parsing of array flag configurations for flagd
([#1797](#1797))
* cleanup evaluator interface
([#1793](#1793))
* removes the `fractionalEvaluation` operator since it has been replaced
with `fractional`.
([#1704](#1704))

### 🐛 Bug Fixes

* **security:** update module github.com/go-viper/mapstructure/v2 to
v2.4.0 [security]
([#1784](#1784))
([037e30b](037e30b))
* **security:** update module golang.org/x/crypto to v0.45.0 [security]
([#1825](#1825))
([44edcc9](44edcc9))
* **security:** update module golang.org/x/crypto to v0.45.0 [security]
([#1826](#1826))
([7e0762b](7e0762b))


### ✨ New Features

* Add OAuth support for HTTP Sync
([#1791](#1791))
([268fd75](268fd75))
* Add OTEL default variables
([#1812](#1812))
([c2e3fc6](c2e3fc6))
* allow null flagSetId Selector, restrict Selector to single
key-value-pairs
([#1708](#1708))
([#1811](#1811))
([c12a0ae](c12a0ae))
* change jsonschema parser
([#1794](#1794))
([bf3f722](bf3f722))
* cleanup evaluator interface
([#1793](#1793))
([aa504f7](aa504f7))
* enable parsing of array flag configurations for flagd
([#1797](#1797))
([97c6ffa](97c6ffa))
* multi-project support via selectors and flagSetId namespacing
([#1702](#1702))
([f9ce46f](f9ce46f))


### 🧹 Chore

* **refactor:** use memdb for flag storage
([#1697](#1697))
([5c5c1cf](5c5c1cf))
* removes the `fractionalEvaluation` operator since it has been replaced
with `fractional`.
([#1704](#1704))
([3228ad8](3228ad8))


### 🔄 Refactoring

* remove deprecated bearerToken option
([#1816](#1816))
([efda06a](efda06a))
* removed unused Selector from Flag and Store.
([#1747](#1747))
([1083005](1083005))
* store cleanup
([#1705](#1705))
([bcff8d7](bcff8d7))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants