/// <summary> /// Enables the incoming requests automatic data collection for ASP.NET. /// </summary> /// <param name="builder"><see cref="MeterProviderBuilder"/> being configured.</param> /// <returns>The instance of <see cref="MeterProviderBuilder"/> to chain the calls.</returns> public static MeterProviderBuilder AddAspNetInstrumentation( this MeterProviderBuilder builder) { Guard.ThrowIfNull(builder); var instrumentation = new AspNetMetrics(); builder.AddMeter(AspNetMetrics.InstrumentationName); return(builder.AddInstrumentation(() => instrumentation)); }
/// <summary> /// Enables HttpClient instrumentation. /// </summary> /// <param name="builder"><see cref="MeterProviderBuilder"/> being configured.</param> /// <returns>The instance of <see cref="MeterProviderBuilder"/> to chain the calls.</returns> public static MeterProviderBuilder AddHttpClientInstrumentation( this MeterProviderBuilder builder) { Guard.Null(builder, nameof(builder)); // TODO: Implement an IDeferredMeterProviderBuilder // TODO: Handle HttpClientInstrumentationOptions // SetHttpFlavor - seems like this would be handled by views // Filter - makes sense for metric instrumentation // Enrich - do we want a similar kind of functionality for metrics? // RecordException - probably doesn't make sense for metric instrumentation var instrumentation = new HttpClientMetrics(); builder.AddMeter(HttpClientMetrics.InstrumentationName); return(builder.AddInstrumentation(() => instrumentation)); }
/// <summary> /// Enables the incoming requests automatic data collection for ASP.NET Core. /// </summary> /// <param name="builder"><see cref="MeterProviderBuilder"/> being configured.</param> /// <returns>The instance of <see cref="MeterProviderBuilder"/> to chain the calls.</returns> public static MeterProviderBuilder AddAspNetCoreInstrumentation( this MeterProviderBuilder builder) { Guard.ThrowIfNull(builder); // TODO: Implement an IDeferredMeterProviderBuilder // TODO: Handle AspNetCoreInstrumentationOptions // Filter - makes sense for metric instrumentation // Enrich - do we want a similar kind of functionality for metrics? // RecordException - probably doesn't make sense for metric instrumentation // EnableGrpcAspNetCoreSupport - this instrumentation will also need to also handle gRPC requests var instrumentation = new AspNetCoreMetrics(); builder.AddMeter(AspNetCoreMetrics.InstrumentationName); return(builder.AddInstrumentation(() => instrumentation)); }
/// <summary> /// Enables runtime instrumentation. /// </summary> /// <param name="builder"><see cref="MeterProviderBuilder"/> being configured.</param> /// <param name="configure">Runtime metrics options.</param> /// <returns>The instance of <see cref="MeterProviderBuilder"/> to chain the calls.</returns> public static MeterProviderBuilder AddRuntimeMetrics( this MeterProviderBuilder builder, Action <RuntimeMetricsOptions> configure = null) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } var options = new RuntimeMetricsOptions(); configure?.Invoke(options); var instrumentation = new RuntimeMetrics(options); builder.AddMeter(RuntimeMetrics.InstrumentationName); return(builder.AddInstrumentation(() => instrumentation)); }