-
Notifications
You must be signed in to change notification settings - Fork 4
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
chore(server): add logging to copier #1351
Conversation
WalkthroughThe pull request focuses on enhancing logging capabilities in two key components: the GCP TaskRunner and the Model interactor. The changes introduce detailed log statements in the Changes
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for reearth-cms canceled.
|
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.
Actionable comments posted: 2
🔭 Outside diff range comments (2)
server/internal/infrastructure/gcp/taskrunner.go (1)
Line range hint
153-203
: Improve logging implementation in copy function.Several improvements can be made to the logging implementation:
- Add error context to log messages
- Consolidate redundant log messages
- Include more context in log messages
-log.Info("copy: copy event running") +log.Info("copy: initiating copy operation", log.Fields{"collection": p.Copy.Collection}) -log.Infof("copy: project %v, region %v", project, region) +log.Info("copy: configuring build", log.Fields{ + "project": project, + "region": region, + "disk_size_gb": defaultDiskSizeGb, +}) -log.Info("copy: call build with region!") -log.Info("copy: call build without region!") +log.Info("copy: submitting build", log.Fields{ + "with_region": region != "", + "project": project, +}) if err != nil { + log.Error("copy: build submission failed", log.Fields{"error": err}) return rerror.ErrInternalBy(err) } -log.Info("copy: cloud build done!") +log.Info("copy: build submitted successfully", log.Fields{ + "project": project, + "region": region, +})server/internal/usecase/interactor/model.go (1)
Line range hint
457-472
: Fix format specifiers and standardize logging.There are several issues with the logging implementation:
- Incorrect format specifiers ('s%' instead of '%s')
- Inconsistent use of Info/Infof
- String formatting should be replaced with structured logging
-log.Infof("copy: copy event triggered. collection: s%, filter: s%, changes: s%", collection, filter, changes) +log.Info("copy: triggering copy event", log.Fields{ + "collection": collection, + "filter": filter, + "changes": changes, +}) -log.Infof("copy: task payload created: %v", taskPayload) +log.Info("copy: created task payload", log.Fields{ + "payload": taskPayload, +}) -log.Infof("model: successfully triggered copy event for collection %s, filter: %s, changes: %s", collection, filter, changes) +log.Info("model: copy event triggered successfully", log.Fields{ + "collection": collection, + "filter": filter, + "changes": changes, +})
🧹 Nitpick comments (3)
server/internal/infrastructure/gcp/taskrunner.go (2)
40-40
: Enhance log message with structured fields.Consider using structured logging fields to improve log searchability and consistency:
-log.Info("copy: run cloud build!") +log.Info("copy: running cloud build", log.Fields{"operation": "cloud_build"})
78-78
: Enhance log message with structured fields.Consider using structured logging fields for better observability:
-log.Info("copy: run copy!") +log.Info("copy: running copy operation", log.Fields{"operation": "copy"})server/internal/usecase/interactor/model.go (1)
Line range hint
368-387
: Replace string formatting with structured logging.Use structured logging instead of string formatting for better log management:
-log.Infof("copy: old model with id %v found", oldModel.ID().String()) +log.Info("copy: found source model", log.Fields{ + "model_id": oldModel.ID(), + "name": oldModel.Name(), + "project": oldModel.Project(), +}) -log.Infof("copy: new model with id %v created", newModel.ID().String()) +log.Info("copy: created target model", log.Fields{ + "model_id": newModel.ID(), + "name": newModel.Name(), + "project": newModel.Project(), +})
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
server/internal/infrastructure/gcp/taskrunner.go
(5 hunks)server/internal/usecase/interactor/model.go
(8 hunks)
Overview
This PR adds logging to copier
Summary by CodeRabbit