Exemplo n.º 1
0
        /// <summary>
        /// Enables the outgoing requests automatic data collection.
        /// </summary>
        /// <param name="builder">Trace builder to use.</param>
        /// <param name="configureHttpCollectorOptions">Http configuration options.</param>
        /// <param name="configureSqlCollectorOptions">Sql configuration options.</param>
        /// <returns>The instance of <see cref="TracerBuilder"/> to chain the calls.</returns>
        public static TracerBuilder AddDependencyCollector(
            this TracerBuilder builder,
            Action <HttpClientCollectorOptions> configureHttpCollectorOptions = null,
            Action <SqlClientCollectorOptions> configureSqlCollectorOptions   = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var httpOptions = new HttpClientCollectorOptions();

            configureHttpCollectorOptions?.Invoke(httpOptions);

            var sqlOptions = new SqlClientCollectorOptions();

            configureSqlCollectorOptions?.Invoke(sqlOptions);

            return(builder
                   .AddCollector((t) => new AzureClientsCollector(t))
                   .AddCollector((t) => new AzurePipelineCollector(t))
                   .AddCollector((t) => new HttpClientCollector(t, httpOptions))
                   .AddCollector((t) => new HttpWebRequestCollector(t, httpOptions))
                   .AddCollector((t) => new SqlClientCollector(t, sqlOptions)));
        }
Exemplo n.º 2
0
 public SqlClientDiagnosticListener(string sourceName, Tracer tracer, SqlClientCollectorOptions options)
     : base(sourceName, tracer)
 {
     this.options = options ?? throw new ArgumentNullException(nameof(options));
 }