/// <summary> /// Initializes a new instance of the <see cref="SqlClientInstrumentation"/> class. /// </summary> /// <param name="options">Configuration options for sql instrumentation.</param> public SqlClientInstrumentation(SqlClientInstrumentationOptions options) { this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber( name => new SqlClientDiagnosticListener(name, options), listener => listener.Name == SqlClientDiagnosticListenerName, null); this.diagnosticSourceSubscriber.Subscribe(); }
/// <summary> /// Initializes a new instance of the <see cref="SqlClientInstrumentation"/> class. /// </summary> /// <param name="options">Configuration options for sql instrumentation.</param> public SqlClientInstrumentation(SqlClientInstrumentationOptions options = null) { this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber( name => new SqlClientDiagnosticListener(name, options), listener => listener.Name == SqlClientDiagnosticListenerName, null); this.diagnosticSourceSubscriber.Subscribe(); #if NETFRAMEWORK this.sqlEventSourceListener = new SqlEventSourceListener(options); #endif }
/// <summary> /// Initializes a new instance of the <see cref="DependenciesInstrumentation"/> 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 DependenciesInstrumentation(TracerFactoryBase tracerFactory, HttpClientInstrumentationOptions httpOptions = null, SqlClientInstrumentationOptions sqlOptions = null) { if (tracerFactory == null) { throw new ArgumentNullException(nameof(tracerFactory)); } var assemblyVersion = typeof(DependenciesInstrumentation).Assembly.GetName().Version; var httpClientListener = new HttpClientInstrumentation(tracerFactory.GetTracer(nameof(HttpClientInstrumentation), "semver:" + assemblyVersion), httpOptions ?? new HttpClientInstrumentationOptions()); var httpWebRequestInstrumentation = new HttpWebRequestInstrumentation(tracerFactory.GetTracer(nameof(HttpWebRequestInstrumentation), "semver:" + assemblyVersion), httpOptions ?? new HttpClientInstrumentationOptions()); var azureClientsListener = new AzureClientsInstrumentation(tracerFactory.GetTracer(nameof(AzureClientsInstrumentation), "semver:" + assemblyVersion)); var azurePipelineListener = new AzurePipelineInstrumentation(tracerFactory.GetTracer(nameof(AzurePipelineInstrumentation), "semver:" + assemblyVersion)); var sqlClientListener = new SqlClientInstrumentation(tracerFactory.GetTracer(nameof(AzurePipelineInstrumentation), "semver:" + assemblyVersion), sqlOptions ?? new SqlClientInstrumentationOptions()); this.instrumentations.Add(httpClientListener); this.instrumentations.Add(httpWebRequestInstrumentation); this.instrumentations.Add(azureClientsListener); this.instrumentations.Add(azurePipelineListener); this.instrumentations.Add(sqlClientListener); }