/// <summary> /// Initializes a new instance of the <see cref="DependenciesCollector"/> class. /// </summary> /// <param name="options">Configuraiton options.</param> /// <param name="tracerFactory">Tracer factory to get a tracer from.</param> public DependenciesCollector(HttpClientCollectorOptions options, TracerFactoryBase tracerFactory) { var assemblyVersion = typeof(DependenciesCollector).Assembly.GetName().Version; var httpClientListener = new HttpClientCollector(tracerFactory.GetTracer(nameof(HttpClientCollector), "semver:" + assemblyVersion), options); var azureClientsListener = new AzureClientsCollector(tracerFactory.GetTracer(nameof(AzureClientsCollector), "semver:" + assemblyVersion)); var azurePipelineListener = new AzurePipelineCollector(tracerFactory.GetTracer(nameof(AzurePipelineCollector), "semver:" + assemblyVersion)); this.collectors.Add(httpClientListener); this.collectors.Add(azureClientsListener); this.collectors.Add(azurePipelineListener); }
/// <summary> /// Initializes a new instance of the <see cref="DependenciesCollector"/> 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 DependenciesCollector(TracerFactoryBase tracerFactory, HttpClientCollectorOptions httpOptions = null, SqlClientCollectorOptions sqlOptions = null) { if (tracerFactory == null) { throw new ArgumentNullException(nameof(tracerFactory)); } var assemblyVersion = typeof(DependenciesCollector).Assembly.GetName().Version; var httpClientListener = new HttpClientCollector(tracerFactory.GetTracer(nameof(HttpClientCollector), "semver:" + assemblyVersion), httpOptions ?? new HttpClientCollectorOptions()); var azureClientsListener = new AzureClientsCollector(tracerFactory.GetTracer(nameof(AzureClientsCollector), "semver:" + assemblyVersion)); var azurePipelineListener = new AzurePipelineCollector(tracerFactory.GetTracer(nameof(AzurePipelineCollector), "semver:" + assemblyVersion)); var sqlClientListener = new SqlClientCollector(tracerFactory.GetTracer(nameof(AzurePipelineCollector), "semver:" + assemblyVersion), sqlOptions ?? new SqlClientCollectorOptions()); this.collectors.Add(httpClientListener); this.collectors.Add(azureClientsListener); this.collectors.Add(azurePipelineListener); this.collectors.Add(sqlClientListener); }
/// <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(SqlClientInstrumentation), "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); }
private static async Task Foo(TracerFactoryBase tracerFactory) { var tracer = tracerFactory.GetTracer("ConsoleApp", "semver:1.0.0"); using (tracer.WithSpan(tracer.StartSpan("Main"))) { using (tracer.WithSpan(tracer.StartSpan("Main (span1)"))) { await Task.Delay(100); using (tracer.WithSpan(tracer.StartSpan("Foo (span2)"))) { tracer.CurrentSpan.SetAttribute("myattribute", "mvalue"); await Task.Delay(100); } } } }
public WeatherForecastController(ILogger <WeatherForecastController> logger, TracerFactoryBase tracerFactory) { _logger = logger; _tracer = tracerFactory.GetTracer("custom"); }
public static Tracer GetApplicationTracer(this TracerFactoryBase tracerFactory) { return(tracerFactory.GetTracer(TracerServiceName, appTracerVersion)); }
public OpenTelemetryCollectingDeviceRepository(TDeviceRepository repository, TracerFactoryBase tracerFactory) { this.tracer = tracerFactory.GetTracer("sql"); this.repository = repository; }
public Program(TracerFactoryBase tracerFactory) { _tracer = tracerFactory.GetTracer("mytracername", "semver:1.0.0"); }