-
Notifications
You must be signed in to change notification settings - Fork 3.6k
refactor(stringlabels): Support stringlabels in log.StreamPipeline #17216
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
refactor(stringlabels): Support stringlabels in log.StreamPipeline #17216
Conversation
@@ -87,7 +87,7 @@ func (d *DeleteRequest) FilterFunction(lbls labels.Labels) (filter.Func, error) | |||
return false | |||
} | |||
|
|||
result, _, skip := f(0, s, structuredMetadata...) | |||
result, _, skip := f(0, s, labels.Labels(structuredMetadata)) // TODO: is this a copy? |
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.
@chaudum it should only make a copy of the slice header, right?
func (b *LabelsBuilder) Add(category LabelCategory, labels ...labels.Label) *LabelsBuilder { | ||
for _, l := range labels { | ||
func (b *LabelsBuilder) Add(category LabelCategory, lbs labels.Labels) *LabelsBuilder { | ||
lbs.Range(func(l labels.Label) { |
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.
Should we benchmark this?
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.
› benchstat before.log after.log
goos: darwin
goarch: arm64
pkg: github.com/grafana/loki/v3/pkg/logql/log
cpu: Apple M2 Pro
│ before.log │ after.log │
│ sec/op │ sec/op vs base │
LabelsBuilder_Add/size_10-10 186.5n ± 0% 204.5n ± 2% +9.65% (p=0.000 n=10)
LabelsBuilder_Add/size_100-10 8.262µ ± 2% 9.049µ ± 1% +9.53% (p=0.000 n=10)
LabelsBuilder_Add/size_1000-10 769.8µ ± 0% 786.9µ ± 2% +2.22% (p=0.000 n=10)
LabelsBuilder_Add/size_10000-10 76.47m ± 0% 76.54m ± 0% ~ (p=0.739 n=10)
geomean 97.59µ 102.7µ +5.28%
So range is around 10%.
What this PR does / why we need it:
This is a next step of support Prometheus
stringlabels
implementation in Loki. It adds support inlog.StreamPipeline
.Special notes for your reviewer:
The tests should compile with build tag
stringlabels
.Checklist
CONTRIBUTING.md
guide (required)feat
PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.docs/sources/setup/upgrade/_index.md
deprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR