Skip to content

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

Merged
merged 4 commits into from
Apr 15, 2025

Conversation

jeschkies
Copy link
Contributor

What this PR does / why we need it:
This is a next step of support Prometheus stringlabels implementation in Loki. It adds support in log.StreamPipeline.

Special notes for your reviewer:
The tests should compile with build tag stringlabels.

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@jeschkies jeschkies requested a review from chaudum April 14, 2025 14:41
@jeschkies jeschkies requested a review from a team as a code owner April 14, 2025 14:41
@@ -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?
Copy link
Contributor Author

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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we benchmark this?

Copy link
Contributor Author

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%.

@jeschkies jeschkies mentioned this pull request Apr 14, 2025
30 tasks
@jeschkies jeschkies enabled auto-merge (squash) April 15, 2025 10:03
@jeschkies jeschkies merged commit a864f8b into grafana:main Apr 15, 2025
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants