Esempio n. 1
0
 public static void NotifyFinish(ITraceSegment traceSegment)
 {
     foreach (var listener in _listeners)
     {
         listener.AfterFinished(traceSegment);
     }
 }
 public void AfterFinished(ITraceSegment traceSegment)
 {
     if (!traceSegment.IsIgnore)
     {
         _dispatcher.Dispatch(traceSegment.Transform());
     }
 }
Esempio n. 3
0
        public async void AfterFinished(ITraceSegment traceSegment)
        {
            var segment             = traceSegment.Transform();
            var traceSegmentService =
                new TraceSegmentService.TraceSegmentServiceClient(GrpcChannelManager.Instance.Channel);

            using (var asyncClientStreamingCall = traceSegmentService.collect())
            {
                await asyncClientStreamingCall.RequestStream.WriteAsync(segment);

                await asyncClientStreamingCall.RequestStream.CompleteAsync();
            }
        }
        public async void AfterFinished(ITraceSegment traceSegment)
        {
            if (traceSegment.IsIgnore)
            {
                return;
            }

            if (_traceSegments.Count >= AgentConfig.PendingSegmentsLimit && AgentConfig.PendingSegmentsLimit > 0)
            {
                _traceSegments.TryDequeue(out var v);
            }
            _traceSegments.Enqueue(traceSegment);
        }
        public async void AfterFinished(ITraceSegment traceSegment)
        {
            if (traceSegment.IsIgnore)
            {
                return;
            }

            var availableConnection = GrpcConnectionManager.Instance.GetAvailableConnection();

            if (availableConnection == null)
            {
                _logger.Warning(
                    $"Transform and send UpstreamSegment to collector fail. {GrpcConnectionManager.NotFoundErrorMessage}");
                return;
            }

            try
            {
                var segment             = traceSegment.Transform();
                var traceSegmentService =
                    new TraceSegmentService.TraceSegmentServiceClient(availableConnection.GrpcChannel);
                using (var asyncClientStreamingCall = traceSegmentService.collect())
                {
                    await asyncClientStreamingCall.RequestStream.WriteAsync(segment);

                    await asyncClientStreamingCall.RequestStream.CompleteAsync();

                    await asyncClientStreamingCall.ResponseAsync;
                }

                _logger.Debug(
                    $"Transform and send UpstreamSegment to collector. [TraceSegmentId] = {traceSegment.TraceSegmentId} [GlobalTraceId] = {traceSegment.RelatedGlobalTraces.FirstOrDefault()}");
            }
            catch (Exception e)
            {
                _logger.Warning($"Transform and send UpstreamSegment to collector fail. {e.Message}");
                availableConnection?.Failure();
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Finish the active Span. When it is finished, it will be archived by the given {@link TraceSegment}, which owners it
 /// </summary>
 /// <param name="owner"></param>
 /// <returns></returns>
 public virtual bool Finish(ITraceSegment owner)
 {
     _endTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
     owner.Archive(this);
     return(true);
 }
Esempio n. 7
0
 public TracingContext()
 {
     _sampler          = ServiceManager.Instance.GetService <SamplingService>();
     _segment          = new TraceSegment();
     _activeSpanStacks = new Stack <ISpan>();
 }
Esempio n. 8
0
 public void AfterFinished(ITraceSegment traceSegment)
 {
     _context.Value = null;
 }
Esempio n. 9
0
 public TracingContext()
 {
     _sampler          = DefaultSampler.Instance;
     _segment          = new TraceSegment();
     _activeSpanStacks = new Stack <ISpan>();
 }
 /// <summary>
 /// Finish the active Span. When it is finished, it will be archived by the given {@link TraceSegment}, which owners it
 /// </summary>
 /// <param name="owner"></param>
 /// <returns></returns>
 public virtual bool Finish(ITraceSegment owner)
 {
     _endTime = DateTime.UtcNow.GetTimeMillis();
     owner.Archive(this);
     return(true);
 }
Esempio n. 11
0
 public virtual bool Finish(ITraceSegment owner)
 {
     _endTime = DateTimeOffset.UtcNow;
     owner.Archive(this);
     return(true);
 }
Esempio n. 12
0
 public TracingContext()
 {
     _activeSpanStacks = new Stack <ISpan>();
     _segment          = new TraceSegment();
 }
 public ConcurrentTraceContext()
 {
     _sampler       = DefaultSampler.Instance;
     _segment       = new TraceSegment();
     _activeSpanDic = new ConcurrentDictionary <string, ISpan>();
 }