You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] OFREP endpoints never record flag evaluation metrics (feature_flag.flagd.impression / .result.reason) #2015
flagd's OFREP HTTP handlers (/ofrep/v1/evaluate/flags/{key} and the bulk endpoint) never emit the feature_flag.flagd.impression and feature_flag.flagd.result.reason metrics, even though /metrics is healthy and these metrics work correctly for the same flags evaluated over Connect/gRPC.
NewOfrepHandler (line 40) accepts a metricsRecorder telemetry.IMetricsRecorder parameter, but only passes it into metricsmw.NewHTTPMetric(...) (lines 58-63, 67-72) for generic HTTP request count/duration middleware.
The handler struct (line 32) never stores the recorder as a field.
HandleFlagEvaluation (line 78) and HandleBulkEvaluation (line 120) call h.evaluator.ResolveAsAnyValue / h.evaluator.ResolveAllValues directly and return, without ever calling RecordEvaluation.
Compare this to the Connect/gRPC evaluation path, which does call it after every resolve:
flagd/pkg/service/flag-evaluation/flag_evaluator_v2.go:257 — same pattern
flagd/pkg/service/flag-evaluation/flag_evaluator.go:92,386 — same pattern
So any flag evaluated only through OFREP is invisible to the impression/result.reason metrics, while identical flags evaluated over gRPC record correctly. Since these two metrics are flagd's primary evaluation-rate/error-rate signal, this makes evaluation observability silently incomplete for any OFREP-only client — with no error or log to indicate it.
Expected behavior
HandleFlagEvaluation should call RecordEvaluation once per evaluation, and HandleBulkEvaluation should call it once per flag in the batch — mirroring the gRPC handlers.
Suggested fix
Store the metricsRecorder on the handler struct in NewOfrepHandler, then call h.metricsRecorder.RecordEvaluation(ctx, evaluation.Error, evaluation.Reason, evaluation.Variant, flagKey) after ResolveAsAnyValue in HandleFlagEvaluation, and loop over each result calling the same in HandleBulkEvaluation.
How we found this
Confirmed by deploying a real OpenFeature-Operator-injected sidecar (flagd v0.15.4-patched) and comparing: a client evaluating the same three flags over OFREP showed zero feature_flag.flagd.impression/.result.reason samples, while switching the same client to the gRPC/Connect provider produced correct metrics immediately, with no other configuration change.
The OFREP handler takes a metricsRecorder but only uses it for the generic HTTP request middleware, never calls RecordEvaluation, so impression/result.reason never fire for OFREP-only clients. gRPC path calls it correctly. Good catch, and thanks for the report.
Fix is as you described: store the recorder on the handler struct, call RecordEvaluation after ResolveAsAnyValue in the single handler, and once per flag in the bulk handler.
One thing for whoever picks this up: in the bulk loop, pass each flag's own error/reason/variant/key (not the top-level batch error), so per-flag results record accurately.
Activity
toddbaert commentedon Aug 12, 2026
Confirmed.
The OFREP handler takes a metricsRecorder but only uses it for the generic HTTP request middleware, never calls RecordEvaluation, so impression/result.reason never fire for OFREP-only clients. gRPC path calls it correctly. Good catch, and thanks for the report.
Fix is as you described: store the recorder on the handler struct, call RecordEvaluation after ResolveAsAnyValue in the single handler, and once per flag in the bulk handler.
One thing for whoever picks this up: in the bulk loop, pass each flag's own error/reason/variant/key (not the top-level batch error), so per-flag results record accurately.
Removing "needs triage", PR welcome.
fix: record OFREP evaluation metrics (open-feature#2016)