Plugins: Chore: Renamed instrumentation middleware to metrics middleware - #8
Open
ShashankFC wants to merge 1 commit into
Open
Conversation
…are (#76186) * Plugins: Chore: Renamed instrumentation middleware to metrics middleware * Removed repeated logger attributes in middleware and contextual logger * renamed loggerParams to logParams * PR review suggestion * Add contextual logger middleware * Removed unused params from logRequest * Removed unwanted changes * Safer FromContext method * Removed traceID from logParams
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the plugin middleware architecture by renaming InstrumentationMiddleware to MetricsMiddleware and extracting contextual logging functionality into a new dedicated ContextualLoggerMiddleware. This separation of concerns improves code maintainability by clearly distinguishing between metrics collection and logging responsibilities.
Changes:
- Renamed
InstrumentationMiddlewaretoMetricsMiddlewareto better reflect its focused responsibility of collecting metrics - Extracted contextual logging logic into a new
ContextualLoggerMiddlewarethat enriches request contexts with plugin and user information - Updated
LoggerMiddlewareto use contextual logger from context instead of manually building log parameters
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/services/pluginsintegration/pluginsintegration.go | Updated middleware registration to use renamed NewMetricsMiddleware and added new NewContextualLoggerMiddleware |
| pkg/services/pluginsintegration/clientmiddleware/metrics_middleware.go | Renamed InstrumentationMiddleware to MetricsMiddleware and removed contextual logging logic |
| pkg/services/pluginsintegration/clientmiddleware/metrics_middleware_test.go | Updated test to use renamed newMetricsMiddleware function |
| pkg/services/pluginsintegration/clientmiddleware/logger_middleware.go | Simplified logging by using contextual logger from context instead of building log parameters inline |
| pkg/services/pluginsintegration/clientmiddleware/contextual_logger_middleware.go | New middleware that adds contextual logger with plugin and request details to the context |
| pkg/plugins/log/logger.go | Added FromContext method to retrieve contextual logger from context |
| pkg/plugins/log/ifaces.go | Added FromContext method to Logger interface and updated parameter types from interface{} to any |
| pkg/plugins/log/fake.go | Implemented FromContext method in test logger |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Test 3nn
Summary by CodeRabbit
New Features
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.
nn---n*Replicated from [ai-code-review-evaluation/grafana-coderabbit#3](https://github.com/ai-code-review-evaluation/grafana-coderabbit/pull/3)*