Plugins: Chore: Renamed instrumentation middleware to metrics middleware #3
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.
User description
PR #3
PR Type
Enhancement, Other
Description
Renamed
InstrumentationMiddlewaretoMetricsMiddlewarefor claritySeparated concerns: metrics tracking and contextual logging into distinct middleware
Added
FromContext()method to Logger interface for context-based logger retrievalSimplified
LoggerMiddlewareby removing duplicate context attributesUpdated all type signatures to use
anyinstead ofinterface{}Diagram Walkthrough
File Walkthrough
ifaces.go
Add FromContext method and modernize type hintspkg/plugins/log/ifaces.go
contextimport for newFromContextmethodinterface{}type hints toanyfor consistencyFromContext(ctx context.Context) Loggermethod to Loggerinterface
anyinstead ofinterface{}logger.go
Implement FromContext method for wrapperpkg/plugins/log/logger.go
contextimportFromContext()method ongrafanaInfraLogWrapperlogger_middleware.go
Simplify logger middleware and use FromContextpkg/services/pluginsintegration/clientmiddleware/logger_middleware.go
tracingimport (no longer needed)logRequest()signature by removingpluginCtxandendpointparameters
datasource, traceID)
FromContext()to retrieve contextual logger fromcontext
contextual_logger_middleware.go
New middleware for contextual loggingpkg/services/pluginsintegration/clientmiddleware/contextual_logger_middleware.go
attributes
NewContextualLoggerMiddleware()factory functionuname) to context
CollectMetrics endpoints
metrics_middleware.go
Rename to MetricsMiddleware and remove loggingpkg/services/pluginsintegration/clientmiddleware/metrics_middleware.go
InstrumentationMiddlewaretoMetricsMiddlewarethroughoutnewInstrumentationMiddleware()tonewMetricsMiddleware()NewInstrumentationMiddleware()toNewMetricsMiddleware()logimport (no longer needed)instrumentContext()function (moved to contextual loggermiddleware)
MetricsMiddlewareinstead ofInstrumentationMiddlewareinstrumentPluginRequest()methodfake.go
Add FromContext to test loggerpkg/plugins/log/fake.go
contextimportFromContext()method onTestLoggerfor test compatibilitymetrics_middleware_test.go
Update test for renamed functionpkg/services/pluginsintegration/clientmiddleware/metrics_middleware_test.go
newMetricsMiddleware()instead ofnewInstrumentationMiddleware()pluginsintegration.go
Update middleware registration and orderingpkg/services/pluginsintegration/pluginsintegration.go
NewMetricsMiddleware()insteadof
NewInstrumentationMiddleware()NewContextualLoggerMiddleware()to middleware stackmiddleware