-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Support matchers in rules API #1843
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
Conversation
Similar to the older change on Labels API (prometheus#828), this adds `matches` to the `Rules` API. This is a breaking change Signed-off-by: Joel Takvorian <jtakvori@redhat.com>
Snapshot(ctx context.Context, skipHead bool) (SnapshotResult, error) | ||
// Rules returns a list of alerting and recording rules that are currently loaded. | ||
Rules(ctx context.Context) (RulesResult, error) | ||
Rules(ctx context.Context, matches []string) (RulesResult, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker, how about making matches
a variadic argument? It would make it neater
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do it if desired, but I also see some cons:
- it's less consistent with other API functions that also use
matches []string
, such asLabelNames
- if the signature has to change again later to add more arguments, depending on what those new arguments are, variadic may have to be reconsidered (e.g. if another
[]string
-like argument is added)
I don't really have an opinion here, let me know what's best
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I only proposed to add matches
because it's the use-case I'm interested in, but there are a bunch of other arguments that could be relevant, according to the doc. I guess I'm trying to avoid a bigger refactoring, if that makes sense. But a more future-proof change would be to accept a parameters struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, never mind. I was lazy, and I hadn't checked the other parameters.
Even though we consider the API package as experimental, let's stick to the existing conventions.
We can add Option
s if needed.
When it comes to making it future-proof, maybe we can have the type
as a first-order parameter as well and make the rest optional.
Any thoughts? cc @bwplotka
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would vote for sticking to consistency and breaking ppl here, as we historically did on this experimental package. We should likely deprecate and move to exp or api module to make it clearer that it's experimental... (or make OpenAPI/swagger flow possible finally)
I would say LGTM for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Similar to the older change on Labels API (#828), this adds
matches
to theRules
API.This is a breaking change. If sending breaking changes is an issue, we could create another function signature - but that would be less consistent with the existing code base.
breaking change migration:
Compilation will fail for client callers who use
api.Rules(ctx)
.Simply change it to
api.Rules(ctx, nil)
to keep the same behaviour.