Skip to content
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

LogQL: add __line__ function to | line_format template #4879

Merged
merged 7 commits into from
Jan 10, 2022

Conversation

cyriltovena
Copy link
Contributor

This PRs introduce a new __line__ function for the LogQL line_format pipeline.

This function returns the current log line in case the users wants to enrich it.

Signed-off-by: Cyril Tovena [email protected]

Which issue(s) this PR fixes:
Fixes #4878

Checklist

  • Documentation added
  • Tests updated
  • Add an entry in the CHANGELOG.md about the changes.

Signed-off-by: Cyril Tovena <[email protected]>
Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

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

I like the addition, but it doesn't look thread safe. Is there something I'm missing?

buf: bytes.NewBuffer(make([]byte, 4096)),
}
functionMap[functionLineName] = func() string {
return unsafeGetString(lf.currentLine)
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem thread safe 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can add a test for the race but I think it's fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well let me rephrase that, it's not thread safe but this whole code of LogQL is never run multiple line at a time.

Copy link
Member

Choose a reason for hiding this comment

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

We can have multiple querier workers which can call this concurrently, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Each worker initialized this once and execute it line by line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we're good @owen-d, I can try it in dev if that would make you more confident.

Copy link
Member

Choose a reason for hiding this comment

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

functionMap is globally defined variable, so even if we have multiple workers, this looks like a problem. Am I missing something?

Copy link
Contributor Author

@cyriltovena cyriltovena Jan 7, 2022

Choose a reason for hiding this comment

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

Ho yeah I was focused on something else the log line, I need to copy this map fn

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call it's cloned !

Copy link
Contributor

@KMiller-Grafana KMiller-Grafana left a comment

Choose a reason for hiding this comment

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

The documentation of this new function looks good to me now.

@cyriltovena
Copy link
Contributor Author

@owen-d we should be good now, can you confirm and merge ?

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.

Include line in LogQL template
4 participants