-
Notifications
You must be signed in to change notification settings - Fork 0
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
Allow passing logger into k8s controller | improve logs structure #35
base: main
Are you sure you want to change the base?
Conversation
@@ -42,25 +44,27 @@ type K8SEvent struct { | |||
} | |||
|
|||
func (c *K8SController) mainloop(item interface{}) { | |||
log.Debug().Str("queue_addr", fmt.Sprintf("%p", &c.queue)).Int("queue_len", c.queue.Len()).Msg("mainloop: running from top") |
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.
queue_addr is not really useful since it's ephemeral, I added this a while ago when I was debugging and learning about the repo.
@@ -42,25 +44,27 @@ type K8SEvent struct { | |||
} | |||
|
|||
func (c *K8SController) mainloop(item interface{}) { | |||
log.Debug().Str("queue_addr", fmt.Sprintf("%p", &c.queue)).Int("queue_len", c.queue.Len()).Msg("mainloop: running from top") | |||
log := c.log.With().Str("where", "mainloop").Int("queue_len", c.queue.Len()).Logger() |
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.
Create a local logger here with info that's relevant to the scope of the function.
return | ||
} | ||
event := item.(K8SEvent) | ||
log = log.With().Str("k8s_event_key", event.Key).Str("k8s_event_type", string(event.Type)).Logger() |
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.
updates scope for the rest of the function here
if !ready { | ||
runtime.HandleError(fmt.Errorf("[%s] Timed out waiting for caches to sync", c.id)) | ||
return | ||
} | ||
log.Info().Msgf("[%s] Informer is ready and synced", c.id) |
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.
not really info worthy, lowered this to debug.
- golangci-lint run | ||
- nilaway -test=false -include-pkgs='github.com/opslevel/opslevel-k8s-controller' ./... |
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 noticed nilaway was missing, so I added it in. no changes are required 👍
Issues
https://github.com/OpsLevel/team-platform/issues/214
Changelog
log
as a controller property that can be passed by dependents on instantiationchangie
entryTophatting