Add Image Diagnostics Metrics Tracking to MAUI Applications #31497
+1,029
−8
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.
Description of Change
This PR implements a comprehensive image loading performance metrics infrastructure for .NET MAUI, following the established diagnostics pattern used by layout metrics. The implementation provides zero-allocation, struct-based instrumentation to monitor image loading performance across all platforms with success and failure monitoring.
Metrics
maui.image.load_duration
(Histogram, ms): Total duration of image loading operationsmaui.image.file_size
(Histogram, bytes): Original file size of loaded imagesmaui.image.width
(Histogram, pixels): Width of loaded imagesmaui.image.height
(Histogram, pixels): Height of loaded imagesmaui.image.load_success
(Counter): Number of successful image load operationsmaui.image.load_failures
(Counter): Number of failed image load operationsTags
Each metric supports contextual tags for richer analysis:
image.source
: The source type (e.g., "File", "Uri", "Stream", "EmbeddedResource")image.format
: File format such as "png", "jpeg", "gif", etc.control.type
: The consuming control type ("Image", "ImageButton", etc.)error.type
: (on failures) The classification of the error (e.g., "FileNotFound", "DecodeError")error.message
: (on failures) Optional descriptive error messageIssues Fixed
Related with #29065