From 8482d1deb51781a3f8eaddd782f9a4bc4c29d196 Mon Sep 17 00:00:00 2001 From: Colin Kelley Date: Thu, 20 Jul 2023 11:47:59 -0700 Subject: [PATCH 1/4] temporarily drop orig_ aliases --- promql/functions.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/promql/functions.go b/promql/functions.go index 366c68c8c37..9401a2160f2 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -1398,25 +1398,27 @@ func init() { fmt.Println("Successfully replaced rate/increase/delta with xrate/xincrease/xdelta (and left the latter names available as well, and original functions callable as orig_rate/orig_increase/orig_delta).") case "2", "y", "Y": - copyParserFunction("delta", "orig_delta") - copyParserFunction("increase", "orig_increase") - copyParserFunction("rate", "orig_rate") - repointFunction("delta", "ydelta", "orig_delta") - repointFunction("increase", "yincrease", "orig_increase") - repointFunction("rate", "yrate", "orig_rate") - - fmt.Println("Successfully replaced rate/increase/delta with yrate/yincrease/ydelta (and left the latter names available as well, and original functions callable as orig_rate/orig_increase/orig_delta).") + // copyParserFunction("delta", "orig_delta") + // copyParserFunction("increase", "orig_increase") + // copyParserFunction("rate", "orig_rate") + repointFunction("delta", "ydelta" /*, "orig_delta"*/) + repointFunction("increase", "yincrease" /*, "orig_increase" */) + repointFunction("rate", "yrate" /*, "orig_rate"*/) + + fmt.Println("Successfully replaced rate/increase/delta with yrate/yincrease/ydelta (and left the latter names available as well).") } } +/* func copyParserFunction(fromName, toName string) { - fromFunction := *parser.Functions[fromName] - fromFunction.Name = toName - parser.Functions[toName] = &fromFunction + functionCopy := *parser.Functions[fromName] + functionCopy.Name = toName + parser.Functions[toName] = &functionCopy } +*/ -func repointFunction(name, newName, origName string) { - FunctionCalls[origName] = FunctionCalls[name] +func repointFunction(name, newName string /*, origName string */) { + // FunctionCalls[origName] = FunctionCalls[name] FunctionCalls[name] = FunctionCalls[newName] } From 38b23c2445d834a89b8285a44e3ed6ac93446173 Mon Sep 17 00:00:00 2001 From: Colin Kelley Date: Thu, 20 Jul 2023 15:57:37 -0700 Subject: [PATCH 2/4] temporarily drop orig_ aliases for 'x' as well --- promql/functions.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/promql/functions.go b/promql/functions.go index 9401a2160f2..6854dc184c9 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -1388,12 +1388,12 @@ func init() { fmt.Println("Successfully replaced rate & friends with xrate & friends (and removed xrate & friends function keys).") case "x", "X": - copyParserFunction("delta", "orig_delta") - copyParserFunction("increase", "orig_increase") - copyParserFunction("rate", "orig_rate") - repointFunction("delta", "xdelta", "orig_delta") - repointFunction("increase", "xincrease", "orig_increase") - repointFunction("rate", "xrate", "orig_rate") + // copyParserFunction("delta", "orig_delta") + // copyParserFunction("increase", "orig_increase") + // copyParserFunction("rate", "orig_rate") + repointFunction("delta", "xdelta" /*, "orig_delta" */) + repointFunction("increase", "xincrease" /*, "orig_increase" */) + repointFunction("rate", "xrate" /*, "orig_rate" */) fmt.Println("Successfully replaced rate/increase/delta with xrate/xincrease/xdelta (and left the latter names available as well, and original functions callable as orig_rate/orig_increase/orig_delta).") @@ -1401,9 +1401,9 @@ func init() { // copyParserFunction("delta", "orig_delta") // copyParserFunction("increase", "orig_increase") // copyParserFunction("rate", "orig_rate") - repointFunction("delta", "ydelta" /*, "orig_delta"*/) + repointFunction("delta", "ydelta" /*, "orig_delta" */) repointFunction("increase", "yincrease" /*, "orig_increase" */) - repointFunction("rate", "yrate" /*, "orig_rate"*/) + repointFunction("rate", "yrate" /*, "orig_rate" */) fmt.Println("Successfully replaced rate/increase/delta with yrate/yincrease/ydelta (and left the latter names available as well).") } From 68bf68c1271d08bd5cbdcaab8b1b1ca3252a6fc3 Mon Sep 17 00:00:00 2001 From: Dan Pramann Date: Fri, 21 Jul 2023 15:30:14 -0500 Subject: [PATCH 3/4] include a repointParserFunctions() function versus copyParserFunction() --- promql/functions.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/promql/functions.go b/promql/functions.go index 6854dc184c9..36bb383cc4e 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -1391,6 +1391,9 @@ func init() { // copyParserFunction("delta", "orig_delta") // copyParserFunction("increase", "orig_increase") // copyParserFunction("rate", "orig_rate") + repointParserFunctions("delta", "xdelta") + repointParserFunctions("increase", "xincrease") + repointParserFunctions("rate", "xrate") repointFunction("delta", "xdelta" /*, "orig_delta" */) repointFunction("increase", "xincrease" /*, "orig_increase" */) repointFunction("rate", "xrate" /*, "orig_rate" */) @@ -1401,6 +1404,9 @@ func init() { // copyParserFunction("delta", "orig_delta") // copyParserFunction("increase", "orig_increase") // copyParserFunction("rate", "orig_rate") + repointParserFunctions("delta", "ydelta") + repointParserFunctions("increase", "yincrease") + repointParserFunctions("rate", "yrate") repointFunction("delta", "ydelta" /*, "orig_delta" */) repointFunction("increase", "yincrease" /*, "orig_increase" */) repointFunction("rate", "yrate" /*, "orig_rate" */) @@ -1417,6 +1423,11 @@ func copyParserFunction(fromName, toName string) { } */ +func repointParserFunctions(name, newName string) { + parser.Functions[name] = parser.Functions[newName] + parser.Functions[name].Name = newName +} + func repointFunction(name, newName string /*, origName string */) { // FunctionCalls[origName] = FunctionCalls[name] FunctionCalls[name] = FunctionCalls[newName] From fc65ddf4f2c15857a96240f3255c12806c7f9f4a Mon Sep 17 00:00:00 2001 From: Colin Kelley Date: Thu, 27 Jul 2023 15:22:00 -0700 Subject: [PATCH 4/4] add TODO --- promql/functions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/promql/functions.go b/promql/functions.go index 36bb383cc4e..aa41b0ffe36 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -1425,7 +1425,7 @@ func copyParserFunction(fromName, toName string) { func repointParserFunctions(name, newName string) { parser.Functions[name] = parser.Functions[newName] - parser.Functions[name].Name = newName + parser.Functions[name].Name = newName // TODO: This line feels redundant since the Name should already be newName. Hoping we can drop it. -Colin } func repointFunction(name, newName string /*, origName string */) {