public void PushLog(LogCollectorRequest logCollectorRequest) { logCollectorRequest.ServiceId = serviceId; logCollectorRequest.ServiceName = _selfOptions.ServerName; var logTask = _logEventProvider.AddLogEvent(logCollectorRequest); logTask.Wait(); }
public async Task PushLog(LogCollectorRequest logCollectorRequest) { if (_loggerOptions.CurrentValue.NotifyOptions.Enable) { logCollectorRequest.ServiceId = serviceId; logCollectorRequest.ServiceName = _serviceOptions.CurrentValue.Name; try { while (await _logCollectorChannel.GetChannel().Writer .WaitToWriteAsync() .ConfigureAwait(false)) { _logCollectorChannel.GetChannel().Writer.TryWrite(logCollectorRequest); } } catch (Exception ex) { throw new Exception("There are some erros when trying to notify log behavior in Service Management, please check stack trace.", ex); } } }
public async Task AddLogEvent(LogCollectorRequest logCollectorRequest) { var logEvent = new LogEvent { Id = DataUtil.GenerateUniqueId(), BeginRequest = logCollectorRequest.BeginRequest.ToDateTime(), EndRequest = logCollectorRequest.EndRequest.ToDateTime(), CpuUsage = logCollectorRequest.CpuUsage, ElapsedTime = logCollectorRequest.ElapsedTime, HttpRequestUrl = logCollectorRequest.HttpRequestUrl, HttpRequestHeaders = logCollectorRequest.HttpHeaders, HttRequestBody = logCollectorRequest.HttpRequestBody, HttpResponseStatusCode = logCollectorRequest.ResponseStatusCode, HttpResponseBody = logCollectorRequest.HttpRequestBody, MemoryUsed = logCollectorRequest.MemoryUsed, TraceId = logCollectorRequest.TraceId, Source = logCollectorRequest.ServiceName, SourceId = logCollectorRequest.ServiceId, StackTrace = logCollectorRequest.StackTraces }; await _logEventRepository.AddAsync(logEvent); }