Plugins: Chore: Renamed instrumentation middleware to metrics middleware - #8
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
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
|
|
||
| func (f *TestLogger) FromContext(_ context.Context) Logger { | ||
| return NewTestLogger() | ||
| } |
There was a problem hiding this comment.
TestLogger.FromContext discards logs to ephemeral instance
Medium Severity
TestLogger.FromContext returns a brand-new TestLogger via NewTestLogger() instead of the receiver. Since LoggerMiddleware.logRequest now calls m.logger.FromContext(ctx).Info(...), any test using TestLogger to verify log output will silently see zero calls — the .Info() writes to a throwaway instance that is immediately discarded.
Additional Locations (1)
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update or ping for review. Thank you for your contributions! |


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)*Note
Medium Risk
Touches the plugin request middleware chain and logging interfaces, so mis-ordering or incorrect context propagation could reduce log/metric fidelity, but behavior changes are localized to observability.
Overview
Adds a context-aware logging flow for plugin backend requests by introducing
Logger.FromContext(ctx)and a newContextualLoggerMiddlewarethat injects plugin/request attributes into thecontext.Context, then updatesLoggerMiddlewareto emit logs via the context-derived logger.Refactors the existing plugin request instrumentation middleware into
MetricsMiddleware(rename + responsibility split), removing context enrichment from metrics collection and updating middleware wiring/tests to useNewMetricsMiddlewareand place the new contextual logger middleware in the stack.Written by Cursor Bugbot for commit 00393c2. Configure here.