Migrate platform/endpointer and platform/middleware/ratelimit to slog. - #39928
Conversation
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
WalkthroughThis PR migrates logging infrastructure across multiple server components from go-kit/log to Go's standard slog library. It replaces the custom Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Migrates Fleet’s platform endpointer error logging and the IP-based rate limit error middleware from go-kit/log to log/slog, while removing a custom discard handler in favor of the stdlib discard handler.
Changes:
- Switch
platform/endpointer.ErrorHandlerto use*slog.Loggerand slog-style attribute logging. - Switch
platform/middleware/ratelimit.ErrorMiddlewarelogging to*slog.Logger+WarnContext. - Remove
platform/logging.DiscardHandlerand update tests/callers to useslog.DiscardHandler.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| server/platform/endpointer/endpoint_utils.go | Migrates ErrorHandler from go-kit/log to *slog.Logger and updates error logging implementation. |
| server/platform/middleware/ratelimit/ratelimit.go | Migrates error-rate-limit middleware logging from go-kit/log to slog. |
| server/platform/logging/logging.go | Removes custom DiscardHandler and uses slog.DiscardHandler in NewNopLogger. |
| server/service/handler.go | Updates handler wiring to pass logger.SlogLogger() into endpointer error handler and rate limit middleware. |
| server/service/endpoint_utils_test.go | Updates tests to use slog discard logger and removes now-unused go-kit/platform logging imports. |
| server/service/integration_android_certificate_templates_test.go | Updates integration test to use slog.DiscardHandler instead of the removed custom discard handler. |
| server/mdm/android/tests/testing_utils.go | Updates Android test server wiring to pass logger.SlogLogger() into endpointer error handler. |
| server/mdm/android/service/profiles_test.go | Updates Android service tests to use slog.DiscardHandler instead of the removed custom discard handler. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #39928 +/- ##
==========================================
- Coverage 66.27% 66.27% -0.01%
==========================================
Files 2439 2439
Lines 195446 195454 +8
Branches 8514 8514
==========================================
- Hits 129540 129536 -4
- Misses 54175 54187 +12
Partials 11731 11731
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Well hello there, neighbor! I took a nice careful look through all the changes in this PR, and I'm happy to say everything looks just wonderful. This PR cleanly migrates the Files Reviewed (8 files)
|
| // Use this in tests instead of kitlog.NewNopLogger() to maintain type safety. | ||
| func NewNopLogger() *Logger { | ||
| return NewLogger(slog.New(DiscardHandler{})) | ||
| return NewLogger(slog.New(slog.DiscardHandler)) |
| "ip", publicIP, | ||
| "msg", "limit exceeded", | ||
| ) | ||
| logger.WarnContext(ctx, "limit exceeded", "ip", publicIP) |
There was a problem hiding this comment.
Are you grabbing anything from this context elsewhere in the logging stack, or is adding context here more for opening possibilities for future use?
There was a problem hiding this comment.
Yes, we're logging trace_id and span_id from context. So, in dogfood logs, you'll be able to search by the trace_id to get all the logs belonging to a specific API call or cron job run. Or, you can go to our OTEL backend and see the trace by the trace_id.
jacobshandling
left a comment
There was a problem hiding this comment.
LGTM, left a couple clarifying questions
Related issue: Resolves #38889
Also delete the unnecessary logging.DiscardHandler and replace it with slog.DiscardHandler
Checklist for submitter
If some of the following don't apply, delete the relevant line.
changes/,orbit/changes/oree/fleetd-chrome/changes.Testing
Summary by CodeRabbit
Chores
Refactor