Skip to content

API proposal for Blazor diagnostics DI #62376

@javiercn

Description

@javiercn

Background and Motivation

We are adding metrics and distributed tracing for Blazor.
We need to add the new services to the dependency injection.
This registration doesn't enable the metrics or traces by default.
The API is in Infrastructure namespace, it's not expected to be called by external code.

Proposed API

namespace Microsoft.AspNetCore.Components.Infrastructure
{
+    public static class ComponentsMetricsServiceCollectionExtensions
+    {
+        public static IServiceCollection AddComponentsMetrics(IServiceCollection services)
+        public static IServiceCollection AddComponentsTracing(IServiceCollection services)
+    }
}

Alternative API

namespace Microsoft.AspNetCore.Components.Infrastructure
{
+    public static class ComponentsDiagnosticsServiceCollectionExtensions
+    {
+        public static IServiceCollection AddComponentsMetrics(IServiceCollection services)
+        public static IServiceCollection AddComponentsTracing(IServiceCollection services)
+    }
}

Usage Examples - in the internal DI code of Blazor

namespace Microsoft.Extensions.DependencyInjection;

public static class RazorComponentsServiceCollectionExtensions
{
    public static IRazorComponentsBuilder AddRazorComponents(this IServiceCollection services, Action<RazorComponentsServiceOptions>? configure = null)
    {
        ComponentsMetricsServiceCollectionExtensions.AddComponentsMetrics(services);
        ComponentsMetricsServiceCollectionExtensions.AddComponentsTracing(services);
    }

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-blazorIncludes: Blazor, Razor Components

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions