Repository navigation
Conversation
prometheus#17977 replaced the package-level parser flags with parser.Options and, in doing so, removed parser.WithFunctions (added in prometheus#12170). Since then the only way for a downstream PromQL engine to parse its own functions is to add them to the global parser.Functions map, which also makes them parseable by every other parser in the process, including the one used by the Prometheus engine. Add a Functions field to parser.Options. When set, it replaces the default function set for that parser, as WithFunctions did; when nil, the default parser.Functions set is used. NewParser copies the map so later changes by the caller cannot affect or race with parsing, and RegisterFeatures now reports the functions the parser actually accepts. TestParseCustomFunctions used the internal newParserWithFunctions helper and added its function to the global Functions map, leaking it into the other tests of the package. It now uses the public API with its own map, and the helper is removed. Signed-off-by: Sandy Chen <[email protected]> (cherry picked from commit f57e5af)
|
Hi, thanks for raising this; given it takes a certain amount of work to do a patch release I expect it will wait for the 3.16. Unless you can explain better why using a commit off |
|
I think the tagging issue is because 3.15.0 release branch has not been merged to main yet. |
|
@bboreham @roidelapluie would it be possible to make a minor patch release for this? i was trying to work on XOR2 adoption in thanos but bumping the prometheus dep to 0.315.0 changes how we interact with the parser since we have Options now and #19830 didn't make that release. so right now we will have to register our custom functions (xrate/xincrease/xdelta) by mutating the global parser.Functions map :((( if we can make a release and bump dependency to minor release it would make thing much cleaner thanks! |
Backport of #19830 to
release-3.15, for the next 3.15 patch release. #19830 was approved by roidelapluie and merged tomain.Why backport this
parser.WithFunctionswithout deprecation. Downstream PromQL engines used it to parse their own functions without adding them to the globalparser.Functionsmap. promql/parser: allow custom functions via parser.Options #19830 adds the replacement,parser.Options.Functions, so for library users this is a regression fix rather than a new feature. Until a release contains it, thanos-io/promql-engine can only move past Prometheus 3.10 by mutating the globalparser.Functionsmap. The same goes for Thanos and Cortex, which depend on promql-engine. That is what the open upgrade PRs, Prometheus 3.11 upstream thanos-io/promql-engine#706 and Prometheus 3.11 upstream thanos-io/thanos#8774, currently do.maincommit doesn't work in the meantime. The highest tag reachable frommainis currentlyv0.314.0-rc.0. Amaincommit therefore resolves to a pseudo-version such asv0.314.0-rc.0.0.20260925142636-270db2915054, which sorts belowv0.314.0. As soon as any other dependency requiresv0.314.0or later, minimal version selection picks that release, and it doesn't have the change. For example, the current prom-label-proxy release, v0.15.1, requiresv0.314.0, and Thanos will need a newer prom-label-proxy once it moves past 3.10. Areplacedirective only takes effect in the top-level module, and it means building against unreleased code. By contrast, a commit onrelease-3.15resolves tov0.315.1-0.<timestamp>-<hash>, and v3.15.1 to module versionv0.315.1. Both sort abovev0.315.0, so downstream can use them right away.Risk
parser.Options. A nilFunctionskeeps the current behavior. Nothing in Prometheus sets it, so the Prometheus binary behaves exactly as before.parser.Optionsis no longer comparable with==. The new field is a map. Nothing in the repository comparesOptionsor uses it as a map key, and Go APIs are outside the stability guarantees.Optionsstruct: onrelease-3.15it still hasExperimentalDurationExprandEnableExtendedRangeSelectors, and both are kept.release-3.15is merged back intomain, that same struct will conflict (two fields onmain, four here). Keepmain's side.go test ./promql/... ./rules/... ./model/rulefmt/... ./web/api/...andgo test -race ./promql/parser/pass, andgolangci-lintreports no issues.cc @jan--f as the 3.15 release shepherd.
🤖 Generated with Claude Code