-
Notifications
You must be signed in to change notification settings - Fork 137
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
Reduce logging repeated code in event server #544
Conversation
Oops, I blindly replaced all the logs with kind+name+namespace 😅 Let me fix this. |
914b3b2
to
a3a7b13
Compare
a3a7b13
to
2df4106
Compare
2df4106
to
c7a50d4
Compare
7f27249
to
811a813
Compare
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.
Left a few minor comments, but overall it looks good to me.
Pasting a sample of the new log for reference and further discussion if needed.
{
"level": "info",
"ts": "2023-06-12T12:59:48.211Z",
"logger": "event-server",
"msg": "Dispatching event: stored artifact for commit 'Merge remote-tracking branch 'origin/master''",
"eventInvolvedObject": {
"kind": "GitRepository",
"namespace": "default",
"name": "test-1",
"uid": "46186684-1dbc-4471-b4af-35ace378737b",
"apiVersion": "source.toolkit.fluxcd.io/v1",
"resourceVersion": "403472"
}
}
A failure log with the alert info:
{
"level": "error",
"ts": "2023-06-12T13:11:23.515Z",
"logger": "event-server",
"msg": "failed to read secret",
"eventInvolvedObject": {
"kind": "GitRepository",
"namespace": "default",
"name": "test-1",
"uid": "46186684-1dbc-4471-b4af-35ace378737b",
"apiVersion": "source.toolkit.fluxcd.io/v1",
"resourceVersion": "405229"
},
"alert": {
"name": "default-alerts",
"namespace": "default"
},
"error": "secrets \"slack-url-foo\" not found"
}
For other reviewers, I'd like to highlight that the involved object in the log is under a new field called |
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
811a813
to
ae6cc4b
Compare
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.
LGTM!
I'll update #540 based on this. Thanks @matheuscscp one less new thing to introduce there 🙂 .
As discussed here, it would be beneficial to have a logger on the request context of the Event Server containing the event's involved object's main metadata, i.e. kind, name and namespace, so that multiple places in the code logging this information don't need to create such verbose three-liner logger every time.
I'm also seizing the opportunity to remove a lot of repeated code for logging events about Provider objects in various places of the Event Handler code.