Skip to content

Plugins: Chore: Renamed instrumentation middleware to metrics middleware - #8

Open
ShashankFC wants to merge 1 commit into
mainfrom
plugins/rename-instrumentation-middleware-to-metrics-middleware
Open

Plugins: Chore: Renamed instrumentation middleware to metrics middleware#8
ShashankFC wants to merge 1 commit into
mainfrom
plugins/rename-instrumentation-middleware-to-metrics-middleware

Conversation

@ShashankFC

Copy link
Copy Markdown

Test 3nn

Summary by CodeRabbit

  • New Features

    • Added context-aware logging that enriches request logs with plugin ID, endpoint name, data source information, and user login details for improved plugin operation visibility and debugging.
  • Refactor

    • Refactored plugin middleware architecture to better separate logging and metrics concerns, improving code maintainability and clarity.

✏️ 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)*

…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
@ShashankFC
ShashankFC requested a review from Copilot January 30, 2026 10:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 InstrumentationMiddleware to MetricsMiddleware to better reflect its focused responsibility of collecting metrics
  • Extracted contextual logging logic into a new ContextualLoggerMiddleware that enriches request contexts with plugin and user information
  • Updated LoggerMiddleware to 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants