Migrate HTTP request logging from go-kit/log to slog - #39729
Conversation
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
WalkthroughThis pull request implements a large-scale migration of the Fleet server codebase from go-kit/log to Go's standard library slog. The changes update logging middleware and handler signatures to use Possibly related PRs
🚥 Pre-merge checks | ✅ 1 | ❌ 4❌ Failed checks (3 warnings, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (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
This PR advances the slog migration by switching HTTP request/end-of-request logging and the contexts/logging request logging context from go-kit/log patterns to log/slog, while keeping existing middleware and handlers working via the adapter.
Changes:
- Updated
contexts/logging.LoggingContextto log via*slog.Loggerand switchedWithLevelto acceptslog.Level. - Migrated request logging middleware/hooks (
LogRequestEnd,LogResponseEndMiddleware,NewLoggingMiddleware) and key call sites to uselogger.SlogLogger(). - Updated affected tests and a few handlers (debug handler, enroll endpoints, SCIM/conditional access) to pass slog loggers.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| server/contexts/logging/logging.go | Switch request logging context to emit via *slog.Logger and slog.Level. |
| server/contexts/logging/logging_test.go | Update tests to validate slog records via a test handler instead of parsing logfmt output. |
| server/service/middleware/log/log.go | Update request logging middleware APIs to accept *slog.Logger. |
| server/service/handler.go | Pass logger.SlogLogger() into LogRequestEnd for go-kit transport ServerAfter. |
| server/service/debug_handler.go | Convert debug handler logging to slog (ErrorContext, slog logger param). |
| cmd/fleet/serve.go | Pass logger.SlogLogger() to MakeDebugHandler. |
| server/service/testing_utils.go | Pass logger.SlogLogger() to MakeDebugHandler in test server setup. |
| server/service/sessions.go | Replace request-level WithLevel(..., level.Info) with slog.LevelInfo. |
| server/service/osquery.go | Replace request-level WithLevel(..., level.Info) with slog.LevelInfo in enroll path. |
| server/service/orbit.go | Replace request-level WithLevel(..., level.Info) with slog.LevelInfo in enroll path. |
| server/service/microsoft_mdm.go | Replace request-level WithLevel(..., level.Info) with slog.LevelInfo for SOAP fault logging. |
| ee/server/service/mdm.go | Replace request-level WithLevel(..., level.Info) with slog.LevelInfo for MDM SSO endpoints. |
| ee/server/service/condaccess/idp.go | Switch conditional access IdP raw-handler logging middleware to slog. |
| ee/server/scim/scim.go | Switch SCIM response-end logging middleware to slog. |
| server/service/osquery_test.go | Update request logging test to call lCtx.Log(ctx, logger.SlogLogger()). |
| server/service/endpoint_utils_test.go | Update tests to use a slog logger for LogRequestEnd. |
| server/mdm/android/tests/testing_utils.go | Use platformlogging.NewLogfmtLogger and update request-end logging hook to slog. |
💡 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 #39729 +/- ##
=======================================
Coverage 66.26% 66.27%
=======================================
Files 2439 2439
Lines 195437 195409 -28
Branches 8550 8528 -22
=======================================
- Hits 129512 129506 -6
+ Misses 54197 54174 -23
- Partials 11728 11729 +1
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:
|
# Conflicts: # server/service/osquery.go
# Conflicts: # server/mdm/android/tests/testing_utils.go
Related issue: Resolves #38889
Checklist for submitter
changes/,orbit/changes/oree/fleetd-chrome/changes.Testing
Summary by CodeRabbit