-
Notifications
You must be signed in to change notification settings - Fork 47
Panel-level performance attribution system #1265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…rics - Add optional panelMetrics array to performance events - Include comprehensive panel timing and performance data - Maintain backward compatibility with existing profiling - Part of panel-level performance attribution implementation
…l performance tracking - Add VizPanelRenderProfiler behavior to track individual panel performance metrics - Integrate with PanelPerformanceCollector for metrics collection - Track plugin load, query, data processing, and render phases - Add comprehensive test coverage - Support long frame detection per panel - Fix startPanelTracking call in activation to resolve 'Panel not found' error
…ormance-attribution
- Remove enableLongFrameDetection from interface and constructor - Remove updateLongFrameMetrics from PanelPerformanceCollectorLike - Remove _setupLongFrameDetection() method and _longFrameObserver - Update tests to remove Long Frame Detection test suite - Simplify cleanup method and constructor defaults - Long frame detection to be implemented in later project phase
- Add plugin loading tracking in VizPanel._loadPlugin() - Implement field config processing tracking with data metrics - Add dual render measurement (React Profiler + manual timing) - Integrate query execution tracking via registerQueryWithController - Add comprehensive panel re-render and state change handling - Implement type-safe instanceof checks (no 'as any') - Add localStorage debug flags for React Profiler and render comparison - Add comprehensive test coverage (16/16 tests passing) - Add performance marks for Chrome DevTools visibility - Support SceneDataTransformer query tracking
- Add findPanelProfiler() shared utility to eliminate code duplication - Make VizPanelRenderProfiler implement QueryProfilerLike interface - Add comprehensive transformation timing in SceneDataTransformer - Add transformation complexity metrics (simple/moderate/complex) - Add centralized logging through VizPanelRenderProfiler methods - Add performance marks for Chrome DevTools visibility - Add error handling with proper timing tracking - Add manual reprocessing support for reprocessTransformations() - Integrate with PanelLifecyclePhase.DataProcessing phase
…rProfiler correlation with InteractionBridge - Enhanced SceneRenderProfiler to notify InteractionBridge of dashboard interactions - Added correlation context tracking to VizPanelRenderProfiler for all performance phases - Implemented _logWithCorrelation method for consistent correlation logging - Added correlation context to panel metrics data for analytics integration - Enhanced interruption detection and logging when interactions are cancelled - Fixed timing synchronization between dashboard and panel profilers
…s for analytics - Enhanced SceneRenderProfiler to collect panel metrics from VizPanelRenderProfiler instances - Added collectPanelMetrics() method to discover and aggregate panel performance data - Include panel metrics in SceneInteractionProfileEvent for complete analytics correlation - Added comprehensive unit tests for panel metrics collection functionality - Handles error cases gracefully (no query controller, missing profilers, etc.) - Complete end-to-end analytics flow now includes both dashboard and panel metrics
- Improved collectPanelMetrics() to traverse to scene root before searching - Added debug logging to show search root and found panel count - Ensures VizPanel instances are discovered correctly in dashboard hierarchy
S4.0: Interaction Correlation - Add interactionContext field to SceneInteractionProfileEvent interface - Enhance correlationContext in panel metrics with full interaction details - Fix timing race condition: get interaction context before clearing - Enable complete dashboard-to-panel correlation traceability S5.0: Metrics Aggregation - Add collectPanelMetrics() method to SceneRenderProfiler - Implement robust scene graph traversal with proper root detection - Include panel metrics array in SceneInteractionProfileEvent - Enable panel-level performance attribution in analytics events Technical fixes: - Resolved interaction clearing before analytics event timing issue - Fixed scene graph search to traverse from query controller to scene root - Added comprehensive correlation context to both dashboard and panel levels Result: Complete end-to-end correlation from user interaction to analytics with panel attribution
- Remove legacy PanelPerformanceCollectorLike interface from all files - Update VizPanelRenderProfiler tests to use EnhancedPanelPerformanceCollector - Fix all TypeScript lint errors in test files - Complete unified collector implementation cleanup All tests passing, ready for human verification.
…based operation tracking - Remove all direct performance.mark() and performance.measure() calls from VizPanelRenderProfiler - Implement observer pattern with ScenePerformanceTracker for centralized event management - Refactor all operation tracking (render, transform, fieldconfig, plugin, query) to use callback pattern - Ensure guaranteed correlation of start/end events using operation IDs in closures - Remove legacy PanelPerformanceCollector and consolidate into clean observer architecture - Update all tests to reflect new callback-based API patterns - Add proper TypeScript interfaces for performance data (Dashboard, Panel, Query)
- Remove InteractionBridge imports and usage from VizPanelRenderProfiler and SceneRenderProfiler - Remove SceneInteractionProfileEvent interface and onProfileComplete callback - Extract render comparison logic into reusable utility - Clean up verbose comments and simplify code structure - Update tests to work with observer pattern - Remove unused correlation context and logging methods - All performance tracking now uses ScenePerformanceTracker observer pattern
- Simplified and updated comments across all performance tracking files - Updated ScenePerformanceTracker file header to be more concise - Cleaned up SceneRenderProfiler comments and removed commented code - Removed unnecessary comments about removed functionality in SceneDataTransformer - Fixed findPanelProfiler function to use SceneObject instead of SceneObjectBase<any> - Removed PanelLifecyclePhase import from VizPanelRenderProfiler test - All TypeScript compilation errors resolved - All tests passing (70 total test cases)
…mposition - Create PanelProfilingManager class for managing VizPanelRenderProfiler instances - Integrate PanelProfilingManager into SceneRenderProfiler via composition - Add watchStateKey configuration for efficient state change monitoring - Remove legacy onProfileComplete and SceneInteractionProfileEvent interfaces - Clean up type exports and index files
… logging - Remove dashboardUIDs from PanelProfilingConfig interface - Remove queryController parameter from SceneRenderProfiler constructor - Refactor SceneRenderProfiler to use generic metadata instead of dashboard-specific properties - Remove unused registerPanelMetrics and clearPanelMetricsRegistry methods - Create BasePerformanceEvent interface to reduce duplication across performance data types - Remove legacy React Profiler integration and render comparison utilities - Remove legacy 'component-to-effects' string and renderType metadata from render tracking - Replace all writeSceneLog calls with conditional writePerformanceLog function - Add writePerformanceLog utility for conditional performance logging based on localStorage flag
…te file - Create interactionConstants.ts to hold all dashboard interaction constants - Update SceneTimeRange, variables, and components to import from new location - Re-export constants from index files for backward compatibility - Remove unused imports from SceneRenderProfiler - Resolves 'Cannot access before initialization' errors in tests
- Add longFramesCount and longFramesTotalTime as required properties - These values are always tracked by SceneRenderProfiler during interactions - Provides better structure for performance event data
- Split PerformanceEventData into three specific interfaces: - DashboardInteractionStartData: interactionType + base properties - DashboardInteractionMilestoneData: interactionType, milestone + base properties - DashboardInteractionCompleteData: interactionType, networkDuration, longFramesCount, longFramesTotalTime + base properties - Update ScenePerformanceObserver interface methods to use specific types - Update ScenePerformanceTracker notify methods with proper type signatures - Update SceneRenderProfiler to use DashboardInteractionCompleteData for completion events - Export new interfaces in behaviors/index.ts and main index.ts - Provides better type safety and clearer data contracts for each event phase
…tadata - Remove onPanelLifecycleStart/Complete methods, use consistent notifyPanelOperationStart/Complete for all panel operations including render - Remove unnecessary type guards from discriminated union handlers (TypeScript provides automatic type narrowing) - Comment out FieldConfigMetadata and RenderMetadata fields for now (interfaces preserved for future use) - Update VizPanelRenderProfiler to use empty metadata objects for render and fieldConfig operations - Remove lifecycle method mocks from test files - Update DashboardAnalyticsAggregator to use simplified fieldConfigOperations type - Maintain selective migration approach for panel vs non-panel query tracking - Plugin-load remains as direct operation type (no longer lifecycle phase)
- Remove SceneInteractionProfileEvent from behaviors/types.ts - Interface now only exists locally in grafana DashboardProfiler.ts - Simplifies interface duplication and maintains clean API surface
…improvements - Fix corrupted startInteraction method name in SceneRenderProfiler - Update comment references from ScenePerformanceService to ScenePerformanceLogger - Simplify interaction completion logs to single-line format - Remove commented dead code in SceneRenderProfiler - Update VizPanelRenderProfiler docs for ScenePerformanceLogger - Clean up SceneRenderProfiler.test.ts with correct service references
- Remove unnecessary boolean return type from attachProfilerToPanel methods - Change return type from boolean to void since return value was never used - Simplify SceneRenderProfiler delegation to PanelProfilingManager - Clean up API surface by removing unused success/failure indicators
- Standardize logging in LongFrameDetector to use writePerformanceLog - Remove deprecated getPanelMetrics method from VizPanelRenderProfiler - Clean up unused VizPanelRenderProfilerLike interface - Update related test cases to reflect observer pattern usage - Maintain consistency with ScenePerformanceTracker design
let operationCounter = 0; | ||
export function generateOperationId(prefix = 'op'): string { | ||
return `${prefix}-${Date.now()}-${++operationCounter}`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
treat this as more of a nit, I reckon it won't cause any issues anywhere, but for extra safety and not having that global counter there, maybe we can use a uuid instead?
this.observers.push(observer); | ||
|
||
// Return unsubscribe function | ||
return () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this used anywhere currently? do we need it or would we just rely on clearObservers
?
/** | ||
* Track data transformation with operation ID correlation | ||
*/ | ||
public onDataTransformStart( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also a nit, but I think adding types for this methods params and return would help as it is a bit confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left some comments, mostly nits, code looks amazing, the new observer arch looks really good, I'll also test this together with the core PR soon.
Tested and commented here. I think this is amazing and with some small changes this is good to land! |
Description
This PR introduces comprehensive panel-level performance attribution that provides granular visibility into individual panel performance within dashboard interactions. The system enables precise identification of performance bottlenecks and optimization opportunities through observer pattern architecture.
Panel-level performance tracking
Modern observer architecture
Developer experience improvements
API modernization
How to test
localStorage.setItem('grafana.debug.sceneProfiling', 'true')
registerPerformanceObserver()
, verify event distributionyarn test VizPanelRenderProfiler SceneRenderProfiler PanelProfilingManager
📦 Published PR as canary version:
6.40.0--canary.1265.18325783397.0
✨ Test out this PR locally via: