-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Conversation
Signed-off-by: Cyril Tovena <[email protected]>
Signed-off-by: Cyril Tovena <[email protected]>
Co-authored-by: Karen Miller <[email protected]>
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.
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) |
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.
This doesn't seem thread safe 🤔
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.
I can add a test for the race but I think it's fine
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.
Well let me rephrase that, it's not thread safe but this whole code of LogQL is never run multiple line at a time.
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.
We can have multiple querier workers which can call this concurrently, no?
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.
Each worker initialized this once and execute it line by line.
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.
I think we're good @owen-d, I can try it in dev if that would make you more confident.
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.
functionMap
is globally defined variable, so even if we have multiple workers, this looks like a problem. Am I missing something?
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.
Ho yeah I was focused on something else the log line, I need to copy this map fn
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.
Good call it's cloned !
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.
The documentation of this new function looks good to me now.
Signed-off-by: Cyril Tovena <[email protected]>
Signed-off-by: Cyril Tovena <[email protected]>
@owen-d we should be good now, can you confirm and merge ? |
This PRs introduce a new
__line__
function for the LogQLline_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
CHANGELOG.md
about the changes.