Uh oh!
There was an error while loading. Please reload this page.
Preserve upstream rate funcs as _rate when REPLACE_RATE_FUNCS is set - #26
Open
ColinDKelley wants to merge 2 commits into
Open
Conversation
This was referenced Jul 8, 2026
ColinDKelleyforce-pushed
the
invoca-2.55.1/align-yrate-to-3x-range-boundary
branch
from
July 8, 2026 23:16
4bf7c40 to
fc4e2f3CompareColinDKelleyforce-pushed
the
invoca-2.55.1/replace-rate-funcs-keep-orig
branch
from
July 8, 2026 23:18
82a7847 to
ce30e19CompareColinDKelley
marked this pull request as ready for review
July 9, 2026 00:16
24 tasks
ttstarck
reviewed
Jul 9, 2026
Comment on lines
+1971
to
+1975
| func copyParserFunction(fromName, toName string) { | ||
| result := *parser.Functions[fromName] | ||
| result.Name = toName | ||
| parser.Functions[toName] = &result | ||
| } |
There was a problem hiding this comment.
This is a copy of repointParserFunctions but the arguments are reversed in how they are used? Maybe we consolidate them?
Author
There was a problem hiding this comment.
Good call. I had asked the same thing! Cursor said they were different, so I moved on. But yeah, they're only different because of argument order. I pushed harder and now it's a lot simpler: 188621d
Comment on lines
+1977
to
+1979
| func copyFunctionCall(fromName, toName string) { | ||
| FunctionCalls[toName] = FunctionCalls[fromName] | ||
| } |
There was a problem hiding this comment.
This is a copy of repointFunction right, only difference is the order of the arguments?
ColinDKelleyforce-pushed
the
invoca-2.55.1/align-yrate-to-3x-range-boundary
branch
from
July 9, 2026 22:27
fc4e2f3 to
e577fe0CompareColinDKelleyforce-pushed
the
invoca-2.55.1/replace-rate-funcs-keep-orig
branch
2 times, most recently
from
July 9, 2026 23:15
643268b to
9ee96b3CompareColinDKelleyforce-pushed
the
invoca-2.55.1/align-yrate-to-3x-range-boundary
branch
2 times, most recently
from
July 10, 2026 00:04
04db8ae to
ac82c0aCompareColinDKelleyforce-pushed
the
invoca-2.55.1/replace-rate-funcs-keep-orig
branch
2 times, most recently
from
July 10, 2026 00:22
ffaebb7 to
db768cbCompareColinDKelleyforce-pushed
the
invoca-2.55.1/align-yrate-to-3x-range-boundary
branch
from
July 10, 2026 00:22
ac82c0a to
366ca82CompareWhen REPLACE_RATE_FUNCS=x or =2, copy the original rate/increase/delta parser and evaluator entries to _rate/_increase/_delta before repointing the standard names at the xrate or yrate family. Fix repointParserFunctions to copy the target struct so the source entry is not aliased. Add TestReplaceRateFuncs2 to verify the registration layout in a subprocess (REPLACE_RATE_FUNCS runs once at init). Co-authored-by: Cursor <cursoragent@cursor.com>
Unify copyParserFunction/copyFunctionCall with repointParserFunctions/ repointFunction via setParserFunctionFrom and setFunctionCallFrom, then call those helpers directly from init(). Co-authored-by: Cursor <cursoragent@cursor.com>
ColinDKelleyforce-pushed
the
invoca-2.55.1/replace-rate-funcs-keep-orig
branch
from
July 10, 2026 02:27
3a55e7c to
66de80aCompareColinDKelleyforce-pushed
the
invoca-2.55.1/align-yrate-to-3x-range-boundary
branch
from
July 10, 2026 02:27
366ca82 to
8e94af7Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
REPLACE_RATE_FUNCSisx/Xor2/y/Y, keep the upstream Prometheus implementations available as_rate/_increase/_deltabefore repointing the standard names at the xrate or yrate family. Note that the xrate and yrate families are callable under their prefixed names in all cases.Stacked on top of #20 (
invoca-2.55.1/align-yrate-to-3x-range-boundary).Why
With
REPLACE_RATE_FUNCS=2, Grafana and existing queries callingrate/increase/deltaget yrate semantics (desired). Operators still sometimes need a way to evaluate the original Prometheus extrapolators for comparison or escape hatches. Preserving them under underscored names keeps both available without inventing new function families.Also fixes
repointParserFunctionsto copy the parser function struct instead of aliasing the pointer, so flipping the displayed name onratedoes not rewrite theyrateentry's.Name.Behavior with
REPLACE_RATE_FUNCS=2rate/increase/deltayrate/yincrease/ydeltaxrate/xincrease/xdelta_rate/_increase/_deltaWhat changes
promql/functions.go:preserveOriginalRateFuncs+ copy helpers; call them before repointing for thex/Xand2/y/Ycases;repointParserFunctionscopies the struct.promql/replace_rate_funcs_test.go: subprocess test that boots withREPLACE_RATE_FUNCS=2and asserts the repoint / preserve pointers.Test plan
go test -count=1 ./promql/...(includes new subprocess test)_increasefor upstream semantics