You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/performance/index.md
+86-2Lines changed: 86 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
---
2
2
title: ASP.NET Core Blazor performance best practices
3
3
author: guardrex
4
-
description: Tips for increasing the performance of ASP.NET Core Blazor apps and avoiding common performance problems.
4
+
description: Guidance on ASP.NET Core Blazor metrics and tracing, improving app performance, and avoiding common performance problems.
5
5
monikerRange: '>= aspnetcore-3.1'
6
6
ms.author: wpickett
7
7
ms.custom: mvc
8
-
ms.date: 04/16/2025
8
+
ms.date: 06/08/2025
9
9
uid: blazor/performance/index
10
10
---
11
11
# ASP.NET Core Blazor performance best practices
@@ -24,3 +24,87 @@ Blazor is optimized for high performance in most realistic application UI scenar
24
24
Ahead-of-time (AOT) compilation compiles a Blazor app's .NET code directly into native WebAssembly for direct execution by the browser. AOT-compiled apps result in larger apps that take longer to download, but AOT-compiled apps usually provide better runtime performance, especially for apps that execute CPU-intensive tasks. For more information, see <xref:blazor/tooling/webassembly#ahead-of-time-aot-compilation>.
25
25
26
26
:::moniker-end
27
+
28
+
:::moniker range=">= aspnetcore-10.0"
29
+
30
+
## Metrics and tracing
31
+
32
+
Metrics and tracing capabilities help you monitor and diagnose app performance, track user interactions, and understand component behavior in production environments.
33
+
34
+
### Configuration
35
+
36
+
To enable Blazor metrics and tracing in your app, configure [OpenTelemetry](https://github.com/open-telemetry/opentelemetry-dotnet) with the following meters and activity sources in the app's `Program` file where services are registered:
In server-side Blazor apps, additional circuit-specific metrics include:
67
+
68
+
*`aspnetcore.components.circuit.active`: Shows the number of active circuits currently in memory.
69
+
*`aspnetcore.components.circuit.connected`: Tracks the number of circuits connected to clients.
70
+
*`aspnetcore.components.circuit.duration`: Measures circuit lifetime duration and provides total circuit count.
71
+
72
+
### Blazor tracing
73
+
74
+
The new activity tracing capabilities use the `Microsoft.AspNetCore.Components` activity source and provide three main types of tracing activities: circuit lifecycle, navigation, and event handling.
75
+
76
+
Circuit lifecycle tracing:
77
+
78
+
`Microsoft.AspNetCore.Components.CircuitStart`: Traces circuit initialization with the format `Circuit {circuitId}`.
79
+
80
+
* Tag: `aspnetcore.components.circuit.id`
81
+
* Link: HTTP activity
82
+
83
+
Navigation tracing:
84
+
85
+
`Microsoft.AspNetCore.Components.RouteChange`: Tracks route changes with the format `Route {route} -> {componentType}`.
86
+
87
+
* Tags
88
+
*`aspnetcore.components.circuit.id`
89
+
*`aspnetcore.components.route`
90
+
*`aspnetcore.components.type`
91
+
* Links
92
+
* HTTP trace
93
+
* Circuit trace
94
+
95
+
Event handling tracing:
96
+
97
+
`Microsoft.AspNetCore.Components.HandleEvent`: Traces event handling with the format `Event {attributeName} -> {componentType}.{methodName}`.
Copy file name to clipboardExpand all lines: aspnetcore/release-notes/aspnetcore-10/includes/blazor.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -416,3 +416,9 @@ Blazor now provides an improved way to display a "Not Found" page when navigatin
416
416
The Blazor project template now includes a `NotFound.razor` page by default. This page automatically renders whenever `NavigationManager.NotFound` is called in your app, making it easier to handle missing routes with a consistent user experience.
417
417
418
418
For more information, see <xref:blazor/fundamentals/routing#not-found-responses>.
419
+
420
+
### Metrics and tracing
421
+
422
+
This release introduces comprehensive metrics and tracing capabilities for Blazor apps, providing detailed observability of the component lifecycle, navigation, event handling, and circuit management.
423
+
424
+
For more information, see <xref:blazor/performance/index#metrics-and-tracing>.
0 commit comments