Пример #1
0
        /// <summary>
        /// Adds OpenTelemetry MeterProvider to the specified <see cref="IServiceCollection" />.
        /// </summary>
        /// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param>
        /// <param name="configure">Callback action to configure the <see cref="MeterProviderBuilder"/>.</param>
        /// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
        public static IServiceCollection AddOpenTelemetryMetrics(this IServiceCollection services, Action <MeterProviderBuilder> configure)
        {
            Guard.Null(configure, nameof(configure));

            var builder = new MeterProviderBuilderHosting(services);

            configure(builder);
            return(services.AddOpenTelemetryMetrics(sp => builder.Build(sp)));
        }
Пример #2
0
        /// <summary>
        /// Adds OpenTelemetry MeterProvider to the specified <see cref="IServiceCollection" />.
        /// </summary>
        /// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param>
        /// <param name="configure">Callback action to configure the <see cref="MeterProviderBuilder"/>.</param>
        /// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
        public static IServiceCollection AddOpenTelemetryMetrics(this IServiceCollection services, Action <MeterProviderBuilder> configure)
        {
            if (configure is null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            var builder = new MeterProviderBuilderHosting(services);

            configure(builder);
            return(services.AddOpenTelemetryMetrics(sp => builder.Build(sp)));
        }