コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlClientAdapter"/> class.
 /// </summary>
 /// <param name="tracer">Tracer to record traced with.</param>
 /// <param name="options">Configuration options for sql adapter.</param>
 public SqlClientAdapter(Tracer tracer, SqlClientAdapterOptions options)
 {
     this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(
         name => new SqlClientDiagnosticListener(name, tracer, options),
         listener => listener.Name == SqlClientDiagnosticListenerName,
         null);
     this.diagnosticSourceSubscriber.Subscribe();
 }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DependenciesAdapter"/> class.
        /// </summary>
        /// <param name="tracerFactory">Tracer factory to get a tracer from.</param>
        /// <param name="httpOptions">Http configuration options.</param>
        /// <param name="sqlOptions">Sql configuration options.</param>
        public DependenciesAdapter(TracerFactoryBase tracerFactory, HttpClientAdapterOptions httpOptions = null, SqlClientAdapterOptions sqlOptions = null)
        {
            if (tracerFactory == null)
            {
                throw new ArgumentNullException(nameof(tracerFactory));
            }

            var assemblyVersion = typeof(DependenciesAdapter).Assembly.GetName().Version;

            var httpClientListener    = new HttpClientAdapter(tracerFactory.GetTracer(nameof(HttpClientAdapter), "semver:" + assemblyVersion), httpOptions ?? new HttpClientAdapterOptions());
            var httpWebRequestAdapter = new HttpWebRequestAdapter(tracerFactory.GetTracer(nameof(HttpWebRequestAdapter), "semver:" + assemblyVersion), httpOptions ?? new HttpClientAdapterOptions());
            var azureClientsListener  = new AzureClientsAdapter(tracerFactory.GetTracer(nameof(AzureClientsAdapter), "semver:" + assemblyVersion));
            var azurePipelineListener = new AzurePipelineAdapter(tracerFactory.GetTracer(nameof(AzurePipelineAdapter), "semver:" + assemblyVersion));
            var sqlClientListener     = new SqlClientAdapter(tracerFactory.GetTracer(nameof(AzurePipelineAdapter), "semver:" + assemblyVersion), sqlOptions ?? new SqlClientAdapterOptions());

            this.adapters.Add(httpClientListener);
            this.adapters.Add(httpWebRequestAdapter);
            this.adapters.Add(azureClientsListener);
            this.adapters.Add(azurePipelineListener);
            this.adapters.Add(sqlClientListener);
        }