-
Notifications
You must be signed in to change notification settings - Fork 140
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
partial support expand #663
Conversation
I guess as the title have "WIP" in the name it is considered to be work-in-progress (that means I won't review it in-depth). One note, however. Current PR expect backend to have native expand handler. However I currently do not aware of any backend that implements that. If you have your own custom backend, please consider implementing some sort of feature flags that would mark that backend implements that type of query. For example carbonapi_v3_pb have a support for Capability Message, so you should send a PR to protocols repo here adding there ExpandMsg support (also feel free to add specific data types to make it easier to use, of course if it's actually needed) and then in your PR bump a revision of protocols repo required and guard that handler with capability request (like how it's done for Victoria Metrics backend) |
Alternatively it might be worth do a find request and post-process the response, if of course find message have enough data. |
Thank you for your comments. I would like to implement this feature, but have some confusion and would like to ask for your help.
|
I guess in that case it is ok to use the same structure as for find.
In that case the most effective approach would be to implement that on a backend side and indeed use a different handler on a backend. Generic approach here is also possible but it would be less effective, e.x. doing requests for each and every glob that you see and implement all that logic on carbonapi side. Overall it might be easier to approach it from a backend side (I'm not sure what you are using - go-carbon or graphite-clickhouse or something else as a backend). Once you have a working backend it will be easier to test your changes on carbonapi side. |
89bbb4f
to
8fc9584
Compare
DeepSource execution failed, but it was not introduced by this pr. Should I fix it? |
10e95d9
to
6c47d1d
Compare
About DeepSource - sometimes it provide false-positive (pointing to problems that were already there or ignoring exclusion of vendored dependencies). In that case you can leave it as-is. However sometimes it detects something new - in that case it would be great if you'll be able to fix it before you mark the PR as ready (when it detects something new sometimes it shows all the problems that were there even in vendored deps, so unfortunately it's not very easy to read) |
Got it. I will only fix the problem introduced by this pr in order to avoid too many changes. |
6c47d1d
to
0107a08
Compare
@Civil This pr is ready, can you help to review it? |
I will likely have some time reading it during the weekend and I'll try not to forget that I have it waiting for the review. |
@guidao: Are you OK if I pick up your PR? If you have any updates - it would be great. Thanks! |
@@ -186,6 +186,36 @@ | |||
return &globs, stats, nil | |||
} | |||
|
|||
func (c *ClientProtoV3Group) Expand(ctx context.Context, request *protov3.MultiGlobRequest) (*protov3.MultiGlobResponse, *types.Stats, merry.Error) { | |||
logger := c.logger.With(zap.String("type", "expand"), zap.Strings("request", request.Metrics)) |
Check failure
Code scanning / CodeQL
Log entries created from user input
@@ -255,6 +258,79 @@ | |||
return &r, stats, nil | |||
} | |||
|
|||
func (c *GraphiteGroup) Expand(ctx context.Context, request *protov3.MultiGlobRequest) (*protov3.MultiGlobResponse, *types.Stats, merry.Error) { | |||
logger := c.logger.With(zap.String("type", "expand"), zap.Strings("request", request.Metrics)) |
Check failure
Code scanning / CodeQL
Log entries created from user input
@@ -494,6 +494,115 @@ | |||
return &r, stats, nil | |||
} | |||
|
|||
func (c *PrometheusGroup) Expand(ctx context.Context, request *protov3.MultiGlobRequest) (*protov3.MultiGlobResponse, *types.Stats, merry.Error) { | |||
logger := c.logger.With(zap.String("type", "expand"), zap.Strings("request", request.Metrics)) |
Check failure
Code scanning / CodeQL
Log entries created from user input
Please feel free to do so. We solved this problem using other means, so there is nothing new in this PR. |
FYI here: IMO this approach is very flexible and gives ability to override expand in every backend but IMO it's a bit overkill, I'll create separate PR similar to bookingcom/carbonapi#449 - which will just implement separate encoder for expand results, but results will be collected by same call as find does. IMO that should be good enough implementation. |
Thanks. Yeah, as it seems not a lot of people need it, it doesn't need to be especially efficient if that would take too much time to implement. |
It has some usecases, like grafana/grafana#33694 - but not widely used, no. |
Closed in the favor of #748 |
It's been a bit long and my memory is a bit fuzzy, I remember I also tried to implement Expend through the Find interface. But there was some semantics that could not be covered. Does it support |
@guidao : well, in graphite-web it's implemented in exactly that way - just another wrapper around same results which find returns. Could you please elaborate why it should have different semantics and how exactly |
PS: you probably mean grafana/grafana#33694 ? I implemented having exact that use case in mind: |
Good, I also think the new PR is better. |
Implement issue: #245