/// <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))); }
public HttpHandlerDiagnosticListener(Tracer tracer, HttpClientAdapterOptions options) : base("HttpHandlerDiagnosticListener", tracer) { var framework = Assembly .GetEntryAssembly()? .GetCustomAttribute <TargetFrameworkAttribute>()? .FrameworkName; // Depending on the .NET version/flavor this will look like // '.NETCoreApp,Version=v3.0', '.NETCoreApp,Version = v2.2' or '.NETFramework,Version = v4.7.1' if (framework != null) { var match = CoreAppMajorVersionCheckRegex.Match(framework); this.httpClientSupportsW3C = match.Success && int.Parse(match.Groups[1].Value) >= 3; } this.options = options; }
public HttpWebRequestDiagnosticListener(Tracer tracer, HttpClientAdapterOptions options) : base(HttpWebRequestDiagnosticSource.DiagnosticListenerName, tracer) { this.options = options; }