コード例 #1
0
        /// <summary>
        /// Enables the outgoing requests automatic data collection.
        /// </summary>
        /// <param name="builder">Trace builder to use.</param>
        /// <param name="configureHttpInstrumentationOptions">Http configuration options.</param>
        /// <param name="configureSqlInstrumentationOptions">Sql configuration options.</param>
        /// <returns>The instance of <see cref="TracerBuilder"/> to chain the calls.</returns>
        public static TracerBuilder AddDependencyInstrumentation(
            this TracerBuilder builder,
            Action <HttpClientInstrumentationOptions> configureHttpInstrumentationOptions = null,
            Action <SqlClientInstrumentationOptions> configureSqlInstrumentationOptions   = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var httpOptions = new HttpClientInstrumentationOptions();

            configureHttpInstrumentationOptions?.Invoke(httpOptions);

            var sqlOptions = new SqlClientInstrumentationOptions();

            configureSqlInstrumentationOptions?.Invoke(sqlOptions);

            return(builder
                   .AddInstrumentation((t) => new AzureClientsInstrumentation(t))
                   .AddInstrumentation((t) => new AzurePipelineInstrumentation(t))
                   .AddInstrumentation((t) => new HttpClientInstrumentation(t, httpOptions))
                   .AddInstrumentation((t) => new HttpWebRequestInstrumentation(t, httpOptions))
                   .AddInstrumentation((t) => new SqlClientInstrumentation(t, sqlOptions)));
        }
コード例 #2
0
        /// <summary>
        /// Enables the incoming requests automatic data collection.
        /// </summary>
        /// <param name="builder">Trace builder to use.</param>
        /// <returns>The instance of <see cref="TracerBuilder"/> to chain the calls.</returns>
        public static TracerBuilder AddRequestInstrumentation(this TracerBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            return(builder.AddInstrumentation(t => new AspNetInstrumentation(t)));
        }
コード例 #3
0
        /// <summary>
        /// Enables the outgoing requests automatic data collection.
        /// </summary>
        /// <param name="builder">Trace builder to use.</param>
        /// <returns>The instance of <see cref="TracerBuilder"/> to chain the calls.</returns>
        public static TracerBuilder AddDependencyInstrumentation(this TracerBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            return(builder
                   .AddInstrumentation((t) => new AzureClientsInstrumentation(t))
                   .AddInstrumentation((t) => new AzurePipelineInstrumentation(t))
                   .AddInstrumentation((t) => new HttpClientInstrumentation(t))
                   .AddInstrumentation((t) => new HttpWebRequestInstrumentation(t))
                   .AddInstrumentation((t) => new SqlClientInstrumentation(t)));
        }
コード例 #4
0
        /// <summary>
        /// Enables the incoming requests automatic data collection.
        /// </summary>
        /// <param name="builder">Trace builder to use.</param>
        /// <param name="configure">Configuration options.</param>
        /// <returns>The instance of <see cref="TracerBuilder"/> to chain the calls.</returns>
        public static TracerBuilder AddRequestInstrumentation(this TracerBuilder builder, Action <AspNetInstrumentationOptions> configure)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            var options = new AspNetInstrumentationOptions();

            configure(options);

            return(builder.AddInstrumentation(t => new AspNetInstrumentation(t, options)));
        }