refactor: centralize HTTP logging middleware in shared package#2021
Open
refactor: centralize HTTP logging middleware in shared package#2021
Conversation
Move LoggingMiddleware and related types to packages/shared/pkg/middleware to enable reuse across services. Both API and dashboard-api now import from the shared package instead of maintaining duplicate implementations. Simplify logging middleware registration in both services using Config.Context for team ID enrichment and Config.Skipper for path exclusion, eliminating the need for ExcludeRoutes wrapper in the logging setup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves LoggingMiddleware and types to packages/shared/pkg/middleware to eliminate duplicate implementations between API and dashboard-api services.
Both services now import from the shared package. The logging registration is simplified using Config.Context for team ID enrichment and Config.Skipper for path exclusion, removing the need for the ExcludeRoutes wrapper in log setup.
The middleware implementation remains unchanged—this is purely a refactor to promote code reuse.
Note
Low Risk
Low risk refactor limited to request logging behavior, but changes to skip-path matching (e.g.,
FullPath()vs raw URL path) could slightly alter which endpoints get logged and how team context is attached.Overview
Both services switch to the shared
LoggingMiddlewareand configure per-request team ID enrichment viaConfig.Context, while replacing the API’s priorExcludeRoutes-wrapped logger with the shared middleware’sSkipper/SkipPathscontrols for excluding noisy endpoints; the shared logging config is also lightly clarified with a comment tweak aroundSkipper.Written by Cursor Bugbot for commit 9f5a315. This will update automatically on new commits. Configure here.