public bool Dispatch(SegmentContext segmentContext) { if (!_runtimeEnvironment.Initialized || segmentContext == null || !segmentContext.Sampled) { return(false); } // todo performance optimization for ConcurrentQueue if (_config.QueueSize < _offset || _cancellation.IsCancellationRequested) { return(false); } var segment = _segmentContextMapper.Map(segmentContext); if (segment == null) { return(false); } _segmentQueue.Enqueue(segment); Interlocked.Increment(ref _offset); _logger.LogDebug($"Dispatch trace segment. [SegmentId]={segmentContext.SegmentId}."); return(true); }
public LoggerRequest Map(LoggerContext loggerContext) { var segmentRequest = _segmentContextMapper.Map(loggerContext.SegmentContext); return(new LoggerRequest { Logs = loggerContext.Logs, SegmentRequest = segmentRequest, Date = loggerContext.Date, }); }