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

@ShashankFC ShashankFC commented Jan 22, 2026

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

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 new ContextualLoggerMiddleware that injects plugin/request attributes into the context.Context, then updates LoggerMiddleware to 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 use NewMetricsMiddleware and place the new contextual logger middleware in the stack.

Written by Cursor Bugbot for commit 00393c2. Configure here.

…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

Copy link
Copy Markdown
Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread pkg/plugins/log/fake.go

func (f *TestLogger) FromContext(_ context.Context) Logger {
return NewTestLogger()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)

Fix in Cursor Fix in Web

@github-actions

Copy link
Copy Markdown
Contributor

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!

@github-actions github-actions Bot added the stale label Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant