Beispiel #1
0
        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)));
            }
        }
        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)));
            }
        }
Beispiel #3
0
        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)));
        }
Beispiel #4
0
        /// <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);
            }));
        }
        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)));
            }
        }