Skip to content

[API Proposal] Diagnostic metrics for Blazor #62555

Open
@pavelsavara

Description

@pavelsavara

Background and Motivation

In Net10 we are adding new diagnostic metrics for Blazor. This is not C# API but about OTEL names.

Implementation is in #61609 and #62286

There was already feedback about names in both implementation PRs
There is also feedback in external OTEL repo that guides the naming conventions open-telemetry/semantic-conventions#2235

Proposed API

new meter Microsoft.AspNetCore.Components

  • Instrument name: aspnetcore.components.navigation
    • Description: Total number of route changes.
    • Unit: {route}
    • Type: Counter<long>
    • Tag: aspnetcore.components.type - class name of the Page component
    • Tag: aspnetcore.components.route - URL path pattern of the Blazor page
    • Tag: error.type - exception type full name, optional
    • Usage: how many different Blazor pages users visited ?
  • Instrument name: aspnetcore.components.event_handler
    • Description: Duration of processing browser event. It includes business logic of the component but not affected child components.
    • Unit: s
    • Type: Histogram<double>
    • Tag: aspnetcore.components.type - full name of target C# component that receives the event
    • Tag: aspnetcore.components.method - C# method name of the handler
    • Tag: aspnetcore.components.attribute.name - name of the HTML attribute that triggers the event, i.e. onClick
    • Tag: error.type - exception type full name, optional
    • Usage: click to which component is slow ?
    • Usage: which buttons are clicked often ?

new meter Microsoft.AspNetCore.Components.Lifecycle

  • Instrument name: aspnetcore.components.update_parameters
    • Description: Duration of processing component parameters. It includes business logic of the component.
    • Unit: s
    • Type: Histogram<double>
    • Tag: aspnetcore.components.type - C# full name of Blazor component receiving parameters
    • Tag: error.type - exception type full name, optional
    • Usage: which components are slow to update ?
    • Usage: which components are updated often ?
  • Instrument name: aspnetcore.components.render_diff
    • Description: Duration of rendering component tree and producing HTML diff. It includes business logic of the changed components.
    • Unit: s
    • Type: Histogram<double>
    • Tag: aspnetcore.components.diff.length - size of the batch, bucketed
    • Tag: error.type - exception type full name, optional
    • Usage: is (server) rendering slow ?
    • Usage: do I render too large diffs ? (network bandwidth, DOM update)

new meter Microsoft.AspNetCore.Components.Server.Circuits

  • Instrument name: aspnetcore.components.circuit.active
    • Description: Number of active circuits in memory.
    • Unit: {circuit}
    • Type: UpDownCounter<long>
    • Usage: how much memory the sessions state holds ?
  • Instrument name: aspnetcore.components.circuit.connected
    • Description: Number of circuits connected to client.
    • Unit: {circuit}
    • Type: UpDownCounter<long>
    • Usage: how many signalR connections are open ?
  • Instrument name: aspnetcore.components.circuit.duration
    • Description: Duration of circuit lifetime and their total count.
    • Unit: s
    • Type: Histogram<double>
    • Usage: how many sessions I processed today ?
    • Usage: how long my users keep the session/tab open ?

Alternatives

  • OTEL feedback was that they don't use plurals in names and that our namespace aspnetcore.components is breaking that rule.
    • I prefer to stick to existing .NET namespace.

Usage Examples

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

Risks

Small perf impact when enabled/subscribed to.

Metadata

Metadata

Assignees

Labels

api-ready-for-reviewAPI is ready for formal API review - https://github.com/dotnet/apireviewsapi-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-blazorIncludes: Blazor, Razor Components

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions