Skip to content

Conversation

@nirrozenbaum
Copy link
Contributor

@nirrozenbaum nirrozenbaum commented May 12, 2025

This PR renames the struct Metrics (under backend/metrics) to MetricsState and move it to a separate file (extracted from types.go).

currently in the repo there are many different places that uses the terminology 'metrics', which makes it confusing to a newcomer to understand where do we define what metrics we collect, and where is the metrics latest state.
This PR aims to solve this issue, as the changed struct holds the state of the scraped metrics from a pod (the values may change every scraping interval).

Additionally, not only this change improves readability of current code, it's also a first PR out of a bigger change.
on follow up PRs, the concept of ServerState (a general purpose interface) will be introduced and is representing a state of data that is collected/scraped from a pod (this is part of data layer and extensible pod scrapers).
MetricsState will the first use of that interface once the interface is introduced.

This PR has NO LOGIC CHANGE.

@netlify
Copy link

netlify bot commented May 12, 2025

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

Name Link
🔨 Latest commit aa85778
🔍 Latest deploy log https://app.netlify.com/sites/gateway-api-inference-extension/deploys/6822363f63573300082b2e1a
😎 Deploy Preview https://deploy-preview-822--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 site configuration.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 12, 2025
@k8s-ci-robot k8s-ci-robot requested review from danehans and liu-cong May 12, 2025 17:56
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 12, 2025
@nirrozenbaum
Copy link
Contributor Author

CC: @kfswain @ahg-g @liu-cong

@nirrozenbaum
Copy link
Contributor Author

/retest

String() string
}

type Metrics struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we are going to pull this out of the types file. Should we pull the factory out as well? If we want a type per file, should we turn types into a directory?

Copy link
Contributor Author

@nirrozenbaum nirrozenbaum May 12, 2025

Choose a reason for hiding this comment

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

the direction I was thinking of can be seen in #783 that was closed in favor of splitting the changes into a series of smaller PRs. I think each data scraper should have a directory and inside that directory the structs should be flattened. if it's more convenient you can see in the PR branch an example here:
https://github.com/nirrozenbaum/gateway-api-inference-extension/tree/model-scraper/pkg/epp/backend/metrics

so, at the end of this bigger change, I don't think we'll need types directory nor types.go file.

Copy link
Contributor Author

@nirrozenbaum nirrozenbaum May 12, 2025

Choose a reason for hiding this comment

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

factory has to go through more changes than extracting from types, so that's for another PR

@kfswain
Copy link
Collaborator

kfswain commented May 12, 2025

Small comment about repo structure, also I'm not sold on MetricsState as the name, but that doesn't have to block. Are we just trying to use the -State suffix to indicate that struct is intended to be generalized data storage?

@nirrozenbaum
Copy link
Contributor Author

nirrozenbaum commented May 12, 2025

Small comment about repo structure, also I'm not sold on MetricsState as the name, but that doesn't have to block. Are we just trying to use the -State suffix to indicate that struct is intended to be generalized data storage?

in the previous (and bigger) PR that was closed I called it xxx-data. but as I was thinking about that more, suffix -state sounds better to me, since it's the CURRENT STATE of the scraped data. and this state can change in next scraping iteration.
I thought about this difference (but maybe it's just my interpretation):
data is something I collect and accumulate, while latest state is struct I just update with latest values.

anyway, I'm open to any name that makes sense.
the name is just a small detail here as long as we agree on the end goal.

@kfswain
Copy link
Collaborator

kfswain commented May 12, 2025

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 12, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kfswain, nirrozenbaum

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

The pull request process is described here

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 May 12, 2025
@k8s-ci-robot k8s-ci-robot merged commit 519bee8 into kubernetes-sigs:main May 12, 2025
8 checks passed
@nirrozenbaum nirrozenbaum deleted the metrics-state branch May 13, 2025 02:55
nayihz pushed a commit to nayihz/gateway-api-inference-extension that referenced this pull request May 14, 2025
kaushikmitr pushed a commit to kaushikmitr/llm-instance-gateway that referenced this pull request May 15, 2025
irar2 pushed a commit to irar2/gateway-api-inference-extension that referenced this pull request Jun 3, 2025
rlakhtakia pushed a commit to rlakhtakia/gateway-api-inference-extension that referenced this pull request Jun 11, 2025
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

3 participants