Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unify time parsing logic in prometheus codec; clarify labels-series compatibility #10117

Conversation

francoposa
Copy link
Member

@francoposa francoposa commented Dec 3, 2024

What this PR does

With an eye towards early request validation, I set out to implement endpoint param parsing for the series endpoints.

To start, this unifies time parsing logic using the promTimeParamDecodable type.
This could be reviewed on its own but I got a bit carried away.

I also chased down that we have already implemented this for the series endpoint, it was just unclear from the interface because everything is called a "labels request".
I have renamed types to reflect the fact that they are for both labels and series, as well as added comments on DecodeLabelsSeriesQueryTimeParams about how the Prometheus HTTP API spec makes it appear as though the labels and series start/end processing is incompatible, but it actually is compatible per the implementation.

Renaming is a bit disruptive but I prefer it to just leaving misleading naming. In any case, if we were to pick one name to cover "Labels and Series" requests, the more general and accurate name would be Series.

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@francoposa francoposa requested a review from a team as a code owner December 3, 2024 23:45
@francoposa francoposa changed the title Francoposa/prometheus codec separate labels and series validation unify time parsing logic in prometheus codec; clarify labels-series compatibility Dec 3, 2024
@francoposa francoposa force-pushed the francoposa/prometheus-codec-separate-labels-and-series-validation branch from a8aee76 to 4897225 Compare December 3, 2024 23:57
@francoposa
Copy link
Member Author

related PR: Early Request Validation in Query Frontend #10093

pkg/frontend/querymiddleware/codec.go Outdated Show resolved Hide resolved
pkg/frontend/querymiddleware/codec.go Show resolved Hide resolved
pkg/frontend/querymiddleware/codec.go Show resolved Hide resolved
pkg/frontend/querymiddleware/codec.go Outdated Show resolved Hide resolved
pkg/util/time.go Show resolved Hide resolved
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov left a comment

Choose a reason for hiding this comment

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

thankss! LGTM

@@ -531,10 +536,10 @@ func DecodeRangeQueryTimeParams(reqValues *url.Values) (start, end, step int64,
}

func instantTimeParamNow() int64 {
return time.Now().UnixMilli()
return time.Now().UTC().UnixMilli()
Copy link
Contributor

Choose a reason for hiding this comment

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

is the UTC() necessary? I thought UnixMilli is only defined in UTC

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yeah true. I am just in the habit of making sure anything with time gets UTC-ed

Copy link
Contributor

@zenador zenador left a comment

Choose a reason for hiding this comment

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

LGTM, no concerns from my end

@francoposa francoposa force-pushed the francoposa/prometheus-codec-separate-labels-and-series-validation branch from 35830da to a880464 Compare December 5, 2024 19:13
@francoposa francoposa merged commit 96c6ca5 into main Dec 5, 2024
29 checks passed
@francoposa francoposa deleted the francoposa/prometheus-codec-separate-labels-and-series-validation branch December 5, 2024 20:49
bjorns163 pushed a commit to bjorns163/mimir that referenced this pull request Dec 30, 2024
…ompatibility (grafana#10117)

* unify time parsing logic in prometheus codec; clarify labels-series req
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.

3 participants