Skip to content

Blazor - rendering metrics #61516

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

Merged
merged 4 commits into from
Apr 17, 2025

Conversation

pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Apr 16, 2025

Blazor - rendering metrics

new Microsoft.AspNetCore.Components.Rendering meter

  • has component.type which is GetType().FullName of the component being rendered
  • aspnetcore.components.rendering.count
    • this is total count, always growing. The viewer could calculate "component render/minute"
  • aspnetcore.components.rendering.active_renders
    • render in flight at any moment. Only non-zero under heavy load.
  • aspnetcore.components.rendering.duration
    • per component

new Microsoft.AspNetCore.Components.Server.Circuits meter

  • aspnetcore.components.circuits.count
    • this is total count, always growing. The viewer could calculate "new circuits/minute"
  • aspnetcore.components.circuits.active_circuits
    • in server memory
  • aspnetcore.components.circuits.connected_circuits
    • with connected signalR
  • aspnetcore.components.circuits.duration
    • from creation until GC

How to enable with OpenTelemetry/Aspire

builder.Services.ConfigureOpenTelemetryMeterProvider(meterProvider =>
{
    meterProvider.AddMeter("Microsoft.AspNetCore.Components.Rendering");
    meterProvider.AddMeter("Microsoft.AspNetCore.Components.Server.Circuits");
});

Fixes #53613

image

@pavelsavara pavelsavara added feature-diagnostics Diagnostic middleware and pages (except EF diagnostics) area-blazor Includes: Blazor, Razor Components labels Apr 16, 2025
@pavelsavara pavelsavara added this to the 10.0-preview5 milestone Apr 16, 2025
@pavelsavara pavelsavara self-assigned this Apr 16, 2025
@pavelsavara pavelsavara force-pushed the blazor_rendering_metrics branch from 6f6a498 to 51c936d Compare April 16, 2025 21:31
@@ -90,6 +92,10 @@ public Renderer(IServiceProvider serviceProvider, ILoggerFactory loggerFactory,
_logger = loggerFactory.CreateLogger("Microsoft.AspNetCore.Components.RenderTree.Renderer");
_componentFactory = new ComponentFactory(componentActivator, this);

// TODO register RenderingMetrics as singleton in DI
Copy link
Member Author

Choose a reason for hiding this comment

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

It would be good to register RenderingMetrics as singleton. But I think it should be done in one of the "Extensions" helpers and I'm not sure which. This could be done in next PR when @javiercn is back.

Copy link
Member

Choose a reason for hiding this comment

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

@pavelsavara pavelsavara marked this pull request as ready for review April 17, 2025 09:27
@pavelsavara pavelsavara requested a review from a team as a code owner April 17, 2025 09:27
@@ -90,6 +92,10 @@ public Renderer(IServiceProvider serviceProvider, ILoggerFactory loggerFactory,
_logger = loggerFactory.CreateLogger("Microsoft.AspNetCore.Components.RenderTree.Renderer");
_componentFactory = new ComponentFactory(componentActivator, this);

// TODO register RenderingMetrics as singleton in DI
Copy link
Member

Choose a reason for hiding this comment

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

@pavelsavara pavelsavara enabled auto-merge (squash) April 17, 2025 11:11
@pavelsavara
Copy link
Member Author

/ba-g CI timeout is #60989

@pavelsavara pavelsavara disabled auto-merge April 17, 2025 12:43
@pavelsavara pavelsavara enabled auto-merge (squash) April 17, 2025 12:44
@akoeplinger akoeplinger disabled auto-merge April 17, 2025 12:46
@pavelsavara pavelsavara enabled auto-merge (squash) April 17, 2025 12:47
@pavelsavara pavelsavara merged commit 183c128 into dotnet:main Apr 17, 2025
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components feature-diagnostics Diagnostic middleware and pages (except EF diagnostics)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Metrics for Blazor
2 participants