Skip to content

Conversation

@PradyumnaKrishna
Copy link
Contributor

Adds ExplainOutputNode struct with OperatorName and Children, A method explainVector generates ExplainOutputNode for the provided VectorOperator.

This explainVector method is used by Explain method of query to get an explaination of the query.

Adds ExplainOutputNode struct with OperatorName and Children, A
method `explainVector` generates `ExplainOutputNode` for the
provided `VectorOperator`.

This `explainVector` method is used by `Explain` method of query
to get an explaination of the query.

Signed-off-by: Pradyumna Krishna <git@onpy.in>
engine/engine.go Outdated
func explainVector(v model.VectorOperator) *ExplainOutputNode {
name, vectors := v.Explain()

var childs []ExplainOutputNode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var childs []ExplainOutputNode
var children []ExplainOutputNode

engine/engine.go Outdated

var childs []ExplainOutputNode
for _, vector := range vectors {
childs = append(childs, *explainVector(vector))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can explainVector return nil?

Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could add some tests for this e.g. Explain() on a query that hasn't been executed yet, Explain() on a query that has one operator, Explain() on a "regular" query like sum(up) by (job).

Adds json key `name` to `OperatorName` and `children` to
`Children` in `ExplainOutputNode`.
Variable name correction in `explainVector` method.

Signed-off-by: Pradyumna Krishna <git@onpy.in>
Test cases are added to Query Explain method to ensure working
of the new query explain method.

Signed-off-by: Pradyumna Krishna <git@onpy.in>
@PradyumnaKrishna
Copy link
Contributor Author

I guess the query Explain() method produce output according to no of processors available (concurrencyOperator ). That's the cause of failing test.

@GiedriusS
Copy link
Member

I guess the query Explain() method produce output according to no of processors available (concurrencyOperator ). That's the cause of failing test.

I think we could use runtime.GOMAXPROCS(0) / 2 to calculate the number of concurrency operators.

Calculate concurrencyOperators according to max available CPUs.

Signed-off-by: Pradyumna Krishna <git@onpy.in>
@GiedriusS GiedriusS merged commit 97f42f6 into thanos-io:main May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants