Open ravishankar15 opened 2 days ago
On checking the stream label part. I think its been used in rename case https://github.com/grafana/loki/blob/main/pkg/logql/log/fmt.go#L394
where we fetch the label if it is in base
and send the category as StreamLabel
. On taking a deeper look,
I feel the idea behind the StreamLabel is,
base
will hold the initial set of labels when initialising the builderA
and update its value. When reading the label A
it will be fetched from base and when updating it will be stored in the add[StreamLabel]
. In nut shell the base is used as a readonly list of labels and add[StreamLabel]
is used to hold the current value.This idea can be validated in other methods of the builder,
Reset
does not actually reset the base labels only resets the add
lists https://github.com/grafana/loki/blob/main/pkg/logql/log/labels.go#L207BaseHas
https://github.com/grafana/loki/blob/main/pkg/logql/log/labels.go#L285C25-L285C32Set
method does not update the base labels https://github.com/grafana/loki/blob/main/pkg/logql/log/labels.go#L350Based on my hypothesis,
Instead of merging the base labels whenever we deal with stream labels. When we initialise the builder we can copy all the labels to add[StreamLabel]
and use the add[StreamLabel]
for all cases. For specific cases where we need the initial data we can use the base
as of now we are not doing that,
As we can see in https://github.com/grafana/loki/blob/main/pkg/logql/log/labels.go#L443 we populate the base if its a StreamLabel.
Correct me if my understanding is wrong.
cc: @salvacorts
Is your feature request related to a problem? Please describe. The current labels builder has two list base and
add[StreamLabel]
which is confusing and theadd[StreamLabel]
might not be needed since all the values are available inbase
Describe the solution you'd like https://github.com/grafana/loki/pull/13955#discussion_r1735713847
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.