public static TracerProviderBuilder AddZipkinExporter(this TracerProviderBuilder builder, Action <ZipkinExporterOptions> configure = null) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } var exporterOptions = new ZipkinExporterOptions(); configure?.Invoke(exporterOptions); var zipkinExporter = new ZipkinExporter(exporterOptions); if (exporterOptions.ExportProcessorType == ExportProcessorType.Simple) { return(builder.AddProcessor(new SimpleActivityExportProcessor(zipkinExporter))); } else { return(builder.AddProcessor(new BatchActivityExportProcessor( zipkinExporter, exporterOptions.BatchExportProcessorOptions.MaxQueueSize, exporterOptions.BatchExportProcessorOptions.ScheduledDelayMilliseconds, exporterOptions.BatchExportProcessorOptions.ExporterTimeoutMilliseconds, exporterOptions.BatchExportProcessorOptions.MaxExportBatchSize))); } }
public SendTracesToZipkinCollector() { int collectorPort = 9411; var agentUri = new Uri($"http://localhost:{collectorPort}/api/v2/spans"); var exporter = new ZipkinExporter(agentUri); var exporterWriter = new ExporterWriter(exporter, new NullMetrics()); _tracer = new Tracer(new TracerSettings(), plugins: null, exporterWriter, sampler: null, scopeManager: null, statsd: null); _zipkinCollector = new MockZipkinCollector(collectorPort); }
private static TracerProviderBuilder AddZipkinExporter( TracerProviderBuilder builder, ZipkinExporterOptions options, Action <ZipkinExporterOptions> configure, IServiceProvider serviceProvider) { configure?.Invoke(options); if (serviceProvider != null && options.HttpClientFactory == ZipkinExporterOptions.DefaultHttpClientFactory) { options.HttpClientFactory = () => { Type httpClientFactoryType = Type.GetType("System.Net.Http.IHttpClientFactory, Microsoft.Extensions.Http", throwOnError: false); if (httpClientFactoryType != null) { object httpClientFactory = serviceProvider.GetService(httpClientFactoryType); if (httpClientFactory != null) { MethodInfo createClientMethod = httpClientFactoryType.GetMethod( "CreateClient", BindingFlags.Public | BindingFlags.Instance, binder: null, new Type[] { typeof(string) }, modifiers: null); if (createClientMethod != null) { return((HttpClient)createClientMethod.Invoke(httpClientFactory, new object[] { "ZipkinExporter" })); } } } return(new HttpClient()); }; } var zipkinExporter = new ZipkinExporter(options); if (options.ExportProcessorType == ExportProcessorType.Simple) { return(builder.AddProcessor(new SimpleActivityExportProcessor(zipkinExporter))); } else { return(builder.AddProcessor(new BatchActivityExportProcessor( zipkinExporter, options.BatchExportProcessorOptions.MaxQueueSize, options.BatchExportProcessorOptions.ScheduledDelayMilliseconds, options.BatchExportProcessorOptions.ExporterTimeoutMilliseconds, options.BatchExportProcessorOptions.MaxExportBatchSize))); } }
public void ZipkinExporter_Export() { var zipkinExporter = new ZipkinExporter( new ZipkinExporterOptions { Endpoint = new Uri($"http://{this.serverHost}:{this.serverPort}"), }); var processor = new SimpleExportActivityProcessor(zipkinExporter); for (int i = 0; i < this.NumberOfActivities; i++) { processor.OnEnd(this.testActivity); } }
public static TracerProviderBuilder AddZipkinExporter(this TracerProviderBuilder builder, Action <ZipkinExporterOptions> configure = null) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } var exporterOptions = new ZipkinExporterOptions(); configure?.Invoke(exporterOptions); var zipkinExporter = new ZipkinExporter(exporterOptions); // TODO: Pick Simple vs Batching based on ZipkinExporterOptions return(builder.AddProcessor(new BatchExportActivityProcessor(zipkinExporter))); }
/// <summary> /// Registers a Zipkin exporter that will receive <see cref="System.Diagnostics.Activity"/> instances. /// </summary> /// <param name="builder"><see cref="TracerProviderBuilder"/> builder to use.</param> /// <param name="configure">Exporter configuration options.</param> /// <param name="processorConfigure">Activity processor configuration.</param> /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns> public static TracerProviderBuilder UseZipkinExporter(this TracerProviderBuilder builder, Action <ZipkinExporterOptions> configure = null, Action <ActivityProcessorPipelineBuilder> processorConfigure = null) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.AddProcessorPipeline(pipeline => { var options = new ZipkinExporterOptions(); configure?.Invoke(options); var exporter = new ZipkinExporter(options); processorConfigure?.Invoke(pipeline); pipeline.SetExporter(exporter); })); }
public async Task ZipkinExporter_ExportAsync() { var zipkinExporter = new ZipkinExporter( new ZipkinExporterOptions { Endpoint = new Uri($"http://{this.serverHost}:{this.serverPort}"), }); var activities = new List <Activity>(this.NumberOfActivities); for (int i = 0; i < this.NumberOfActivities; i++) { activities.Add(this.testActivity); } await zipkinExporter.ExportAsync(activities, CancellationToken.None).ConfigureAwait(false); }
public void ZipkinExporter_Batching() { var exporter = new ZipkinExporter( new ZipkinExporterOptions { Endpoint = new Uri($"http://{this.serverHost}:{this.serverPort}"), }); for (int i = 0; i < this.NumberOfBatches; i++) { for (int c = 0; c < this.NumberOfSpans; c++) { this.activityBatch.Add(this.activity); } exporter.Export(new Batch <Activity>(this.activityBatch, this.NumberOfSpans)); } exporter.Shutdown(); }
private static TracerProviderBuilder AddZipkinExporter(TracerProviderBuilder builder, ZipkinExporterOptions options, Action <ZipkinExporterOptions> configure = null) { configure?.Invoke(options); var zipkinExporter = new ZipkinExporter(options); if (options.ExportProcessorType == ExportProcessorType.Simple) { return(builder.AddProcessor(new SimpleActivityExportProcessor(zipkinExporter))); } else { return(builder.AddProcessor(new BatchActivityExportProcessor( zipkinExporter, options.BatchExportProcessorOptions.MaxQueueSize, options.BatchExportProcessorOptions.ScheduledDelayMilliseconds, options.BatchExportProcessorOptions.ExporterTimeoutMilliseconds, options.BatchExportProcessorOptions.MaxExportBatchSize))); } }
public JsonContent(ZipkinExporter exporter, in Batch <Activity> batch)