Skip to content

feat: Add opt-in feature_service label to feature server request metrics - #7218

Open
rahulremany wants to merge 1 commit into
feast-dev:masterfrom
rahulremany:feat/feature-service-metrics-label
Open

rahulremany wants to merge 1 commit into
feast-dev:masterfrom
rahulremany:feat/feature-service-metrics-label

Conversation

@rahulremany

@rahulremany rahulremany commented Nov 24, 2026 •

Copy link
Copy Markdown

What this PR does / why we need it:

Requests to /get-online-features are often made through a named feature service, but the feature server's request metrics only break down by endpoint, feature_count and feature_view_count. That makes it impossible to see latency or error rate per feature service.

This adds a feature_service label to feast_feature_server_request_total and feast_feature_server_request_latency_seconds, behind a new opt-in flag:

feature_server:
  metrics:
    enabled: true
    feature_service_label: true
  • Off by default. Each feature service adds its own set of histogram series, so this should only be enabled when the number of feature services is bounded. When off, the label is always "".
  • Set only after the feature service resolves. The label is populated after _get_features succeeds, so a request naming an unknown service (404) can't mint new series from client input.
  • Requests that list features directly, and all other endpoints, get "".
  • Follows the existing feature_count_bins pattern: the handler reads the flag from MetricsConfig and sets it on the RequestMetricsContext.

Left for follow-ups (both marked optional in the issue): an allowlist of feature service names, and a feature_service label on online_features_status_total.

Note for dashboards: existing series gain an empty feature_service label. Queries that aggregate with sum by (...) are unaffected.

Which issue(s) this PR fixes:

Fixes #6639

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

Added test_feature_service_label (enabled/disabled) covering the /get-online-features handler end to end; existing label lookups in test_metrics.py updated for the new label. tests/unit/test_metrics.py, tests/unit/test_feature_server.py and tests/unit/infra/feature_servers pass (206 tests); ruff and mypy clean.

Misc

Docs updated in docs/reference/feature-servers/python-feature-server.md.


Devin Review

Label feast_feature_server_request_total and
feast_feature_server_request_latency_seconds with the feature service a
/get-online-features request was made through, gated by a new
MetricsConfig.feature_service_label flag (default off) to keep histogram
cardinality bounded.

Closes feast-dev#6639

Signed-off-by: Rahul Remany <rahulremany@gmail.com>
@rahulremany
rahulremany requested a review from a team as a code owner November 24, 2026 03:06

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 potential issue.

3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment on lines +687 to +688
if feature_service_label:
metrics_ctx.feature_service = request.feature_service or ""

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.

🟨 Client spellings inflate metrics cardinality

With labeling enabled, get_online_features uses the submitted name rather than the resolved name. An uncached MySQL registry with a case-insensitive collation accepts different spellings for the same service. An authorized caller can create separate counter and histogram series for that one service.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@franciscojavierarceo franciscojavierarceo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we need to address the existing client-spelling cardinality finding before merging. _get_features already returns the resolved FeatureService, but the metric uses request.feature_service. with cache_mode='none' and a MySQL case-insensitive collation, multiple submitted spellings resolve to that one object and create separate histogram series. we should label with the resolved object's canonical name and cover alternate spellings without creating extra series.

This branch has not been deployed

No deployments
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.

feat: Add feature_service label to Feature Server RED metrics

2 participants