示例#1
0
        /// <summary>
        /// Enables the outgoing requests automatic data collection.
        /// </summary>
        /// <param name="builder">Trace builder to use.</param>
        /// <param name="configureHttpAdapterOptions">Http configuration options.</param>
        /// <param name="configureSqlAdapterOptions">Sql configuration options.</param>
        /// <returns>The instance of <see cref="TracerBuilder"/> to chain the calls.</returns>
        public static TracerBuilder AddDependencyAdapter(
            this TracerBuilder builder,
            Action <HttpClientAdapterOptions> configureHttpAdapterOptions = null,
            Action <SqlClientAdapterOptions> configureSqlAdapterOptions   = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var httpOptions = new HttpClientAdapterOptions();

            configureHttpAdapterOptions?.Invoke(httpOptions);

            var sqlOptions = new SqlClientAdapterOptions();

            configureSqlAdapterOptions?.Invoke(sqlOptions);

            return(builder
                   .AddAdapter((t) => new AzureClientsAdapter(t))
                   .AddAdapter((t) => new AzurePipelineAdapter(t))
                   .AddAdapter((t) => new HttpClientAdapter(t, httpOptions))
                   .AddAdapter((t) => new HttpWebRequestAdapter(t, httpOptions))
                   .AddAdapter((t) => new SqlClientAdapter(t, sqlOptions)));
        }
示例#2
0
 public SqlClientDiagnosticListener(string sourceName, Tracer tracer, SqlClientAdapterOptions options)
     : base(sourceName, tracer)
 {
     this.options = options ?? throw new ArgumentNullException(nameof(options));
 }