Repository navigation
Preserve upstream rate funcs as _rate when REPLACE_RATE_FUNCS is set - #26
ColinDKelley wants to merge 2 commits into
Conversation
4bf7c40 to
fc4e2f3
Compare
82a7847 to
ce30e19
Compare
| 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?
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
| 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?
fc4e2f3 to
e577fe0
Compare
643268b to
9ee96b3
Compare
04db8ae to
ac82c0a
Compare
ffaebb7 to
db768cb
Compare
ac82c0a to
366ca82
Compare
When 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>
3a55e7c to
66de80a
Compare
366ca82 to
8e94af7
Compare
|
🤖 AI-generated — not written by the account holder. Re-checked my earlier notes from ce30e19. Both are addressed: the copy/repoint twins are now Nit: the test only covers This is not a GitHub approve. Approve is still waiting on you. The owning team's expectations apply. Review automation: ready for manual approve. Head: 66de80a |
|
🤖 AI-generated — not written by the account holder. Heads up on CI for 66de80a: Buildkite Sent from my review automation. |
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