Skip to content

[Blazor] Consider enabling MetricsSupport and EventSourceSupport by default for WebAssembly #64575

@javiercn

Description

@javiercn

Summary

Consider enabling MetricsSupport and EventSourceSupport MSBuild properties by default for Blazor WebAssembly projects to support OpenTelemetry metrics instrumentation out of the box.

Background

Currently, to enable OpenTelemetry metrics in Blazor WebAssembly, developers must manually add MSBuild properties to their .csproj:

<PropertyGroup>
    <!-- Enable WebAssembly diagnostics for OpenTelemetry metrics -->
    <!-- See: https://learn.microsoft.com/aspnet/core/blazor/performance/webassembly-event-pipe-diagnostics -->
    <MetricsSupport>true</MetricsSupport>
    <EventSourceSupport>true</EventSourceSupport>
</PropertyGroup>

Without these properties, runtime instrumentation and metrics don't work in WebAssembly, making Aspire integration incomplete.

Proposal

Consider enabling these properties by default in the Blazor WebAssembly SDK, similar to how other diagnostic features are enabled by default in ASP.NET Core projects.

Options

  1. Enable by default for all WASM projects - Simplest, but may have size/performance implications
  2. Enable by default when OpenTelemetry packages are referenced - Conditional enablement
  3. Enable by default in Aspire-integrated projects - Scoped to Aspire scenarios only

Considerations

  • App size impact: These properties may increase the final WASM bundle size
  • Performance: Need to measure any runtime overhead
  • Discoverability: Currently, developers often don't know these are required until metrics don't work

Documentation

Related Issues

Part of .NET 11.0 Blazor + Aspire integration improvements

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing one

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions