Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BatchingSpanProcessor"/> class with custom settings.
        /// </summary>
        /// <param name="exporter">Exporter instance.</param>
        /// <param name="maxQueueSize">Maximum queue size. After the size is reached spans are dropped by processor.</param>
        /// <param name="scheduleDelay">The delay between two consecutive exports.</param>
        /// <param name="maxExportBatchSize">The maximum batch size of every export. It must be smaller or equal to maxQueueSize.</param>
        public BatchingSpanProcessor(SpanExporter exporter, int maxQueueSize, TimeSpan scheduleDelay, int maxExportBatchSize)
        {
            if (maxQueueSize <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maxQueueSize));
            }

            if (maxExportBatchSize <= 0 || maxExportBatchSize > maxQueueSize)
            {
                throw new ArgumentOutOfRangeException(nameof(maxExportBatchSize));
            }

            this.exporter           = exporter ?? throw new ArgumentNullException(nameof(exporter));
            this.maxQueueSize       = maxQueueSize;
            this.scheduleDelay      = scheduleDelay;
            this.maxExportBatchSize = maxExportBatchSize;

            this.cts         = new CancellationTokenSource();
            this.exportQueue = new ConcurrentQueue <SpanData>();

            // worker task that will last for lifetime of processor.
            // No need to specify long running - it is useless if any async calls are made internally.
            // Threads are also useless as exporter tasks run in thread pool threads.
            Task.Factory.StartNew(s => this.Worker((CancellationToken)s), this.cts.Token);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BatchingSpanProcessor"/> class with default parameters:
 /// <list type="bullet">
 /// <item>
 /// <description>maxQueueSize = 2048,</description>
 /// </item>
 /// <item>
 /// <description>scheduleDelay = 5 sec,</description>
 /// </item>
 /// <item>
 /// <description>maxExportBatchSize = 512</description>
 /// </item>
 /// </list>
 /// </summary>
 /// <param name="exporter">Exporter instance.</param>
 public BatchingSpanProcessor(SpanExporter exporter)
     : this(exporter, DefaultMaxQueueSize, DefaultScheduleDelay, DefaultMaxExportBatchSize)
 {
 }
 /// <summary>
 /// Constructs simple processor.
 /// </summary>
 /// <param name="exporter">Span processor instance.</param>
 public SimpleSpanProcessor(SpanExporter exporter)
 {
     this.exporter = exporter ?? throw new ArgumentNullException(nameof(exporter));
 }
Ejemplo n.º 4
0
 protected SpanProcessor(SpanExporter exporter)
 {
     this.Exporter = exporter ?? throw new ArgumentNullException(nameof(exporter));
 }
Ejemplo n.º 5
0
 public SimpleSpanProcessor(SpanExporter exporter) : base(exporter)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructs batching processor with default parameters:
 /// <list type="bullet">
 /// <item>
 /// <description>maxQueueSize = 2048,</description>
 /// </item>
 /// <item>
 /// <description>scheduleDelay = 5 sec,</description>
 /// </item>
 /// <item>
 /// <description>maxExportBatchSize = 512</description>
 /// </item>
 /// </list>
 /// </summary>
 /// <param name="exporter">Exporter instance.</param>
 public BatchingSpanProcessor(SpanExporter exporter) : this(exporter, DefaultMaxQueueSize, DefaultScheduleDelay, DefaultMaxExportBatchSize)
 {
     this.exporter = exporter ?? throw new ArgumentNullException(nameof(exporter));
 }