Skip to content

Conversation

@LukeAVanDrie
Copy link
Contributor

What type of PR is this?
/kind feature
/kind cleanup

What this PR does / why we need it:
This PR enhances the observability of the experimental Flow Control layer to support advanced autoscaling scenarios, specifically Scale-from-Zero and per-model scaling.

Previously, Flow Control metrics (flow_control_queue_size, flow_control_request_queue_duration_seconds) only included flow keys (fairness_id, priority) which are orthogonal to model labels. This made it impossible for an external autoscaler (HPA) to distinguish which specific Pool or Model was experiencing pressure/saturation.

Key Changes:

  1. Metric Enrichment: Added inference_pool, model_name, and target_model_name labels to Flow Control metrics. This allows autoscalers to correlate queue metrics with specific pools or models.
  2. Context Propagation: Updated the FlowControlRequest interface and the Admission Controller to capture and propagate this context from the incoming request down to the metrics layer.
  3. Metrics Refactoring: Refactored pkg/epp/metrics/metrics.go to deduplicate label definitions, extract magic strings to constants, and optimize recorder performance (switched to .WithLabelValues to reduce allocations on the hot path).

Which issue(s) this PR fixes:
Fixes #1920

Does this PR introduce a user-facing change?:

Added `inference_pool`, `model_name`, and `target_model_name` labels to Flow Control metrics (`flow_control_queue_size`, `flow_control_request_queue_duration_seconds`) to support fine-grained autoscaling.

Refactors `pkg/epp/metrics/metrics.go` to improve performance and
maintainability.

Changes include:
- Centralize label keys and bucket definitions into package-level
  constants to remove duplication.
- Switch from `.With(prometheus.Labels)` to ``.WithLabelValues()` in
  recorder functions to avoid map allocations on the hot path.
- Extract magic strings for metric types into constants to prevent
  typos.
Updates the Flow Control layer metrics to include InferencePool, Model,
and TargetModel labels, enabling better correlation between queuing
behavior and backend demand.

Changes include:
- Update `FlowControlRequest` interface to expose observability context.
- Propagate pool name, model name, and target model name through
  Admission Controller and Flow Controller.
- Update `metrics.go` to include the new labels in the Flow Control
  metric definitions.
- Update mocks and tests to reflect these API changes.
@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Dec 16, 2025
@netlify
Copy link

netlify bot commented Dec 16, 2025

Deploy Preview for gateway-api-inference-extension ready!

Name Link
🔨 Latest commit d715289
🔍 Latest deploy log https://app.netlify.com/projects/gateway-api-inference-extension/deploys/6941ccb51daae20008bdce70
😎 Deploy Preview https://deploy-preview-2010--gateway-api-inference-extension.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 16, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @LukeAVanDrie. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 16, 2025
@LukeAVanDrie
Copy link
Contributor Author

cc' @dumb0002

I did not add a second aggregate version of each metric as that would break away from the existing project convention. But, you should be able to aggregate from the existing metrics now. Let me know if this is sufficient.

}
go registry.Run(ctx)
admissionController = requestcontrol.NewFlowControlAdmissionController(fc)
admissionController = requestcontrol.NewFlowControlAdmissionController(fc, opts.PoolName)
Copy link
Contributor Author

@LukeAVanDrie LukeAVanDrie Dec 16, 2025

Choose a reason for hiding this comment

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

I can also get this from the data layer via PoolGet (e.g., in requestcontrol/director.go or handlers/server.go). My understanding is that this is a static value though, so this should be sufficient and avoids a lookup.

@dumb0002
Copy link

cc' @dumb0002

I did not add a second aggregate version of each metric as that would break away from the existing project convention. But, you should be able to aggregate from the existing metrics now. Let me know if this is sufficient.

@LukeAVanDrie, sounds good. Thanks!

@ahg-g
Copy link
Contributor

ahg-g commented Dec 20, 2025

/ok-to-test
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 20, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 20, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahg-g, LukeAVanDrie

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 20, 2025
@k8s-ci-robot
Copy link
Contributor

@LukeAVanDrie: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-gateway-api-inference-extension-test-unit-main d715289 link true /test pull-gateway-api-inference-extension-test-unit-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flow Control] Prometheus Metrics labels missing 'InferencePool' label

4 participants