public void PushLog(PushLogModel pushLogModel)
        {
            pushLogModel.RegisteredServiceId = serviceId;
            pushLogModel.ServiceName         = _serviceOptions.CurrentValue.Name;
            var logTask = _logEventProvider.AddLogEvent(pushLogModel);

            logTask.Wait();
        }
Ejemplo n.º 2
0
 public void PushLog(PushLogModel pushLogModel)
 {
     if (_loggerOptions.CurrentValue.NotifyOptions.Enable)
     {
         pushLogModel.RegisteredServiceId = serviceId;
         pushLogModel.ServiceName         = _serviceOptions.CurrentValue.Name;
         try
         {
             var task = _httpClient.PostAsJsonAsync(_serviceOptions.CurrentValue.ServiceManagementEndpoint + "/api/logs", pushLogModel);
             var httpResponseMessage = task.Result;
             httpResponseMessage.EnsureSuccessStatusCode();
         }
         catch (Exception ex)
         {
             throw new Exception("There are some erros when trying to notify log behavior in Service Management, please check stack trace.", ex);
         }
     }
 }
Ejemplo n.º 3
0
        public async Task AddLogEvent(PushLogModel pushLogModel)
        {
            var logEvent = new LogEvent
            {
                Id                     = DataUtil.GenerateUniqueId(),
                BeginRequest           = pushLogModel.BeginRequest,
                EndRequest             = pushLogModel.EndRequest,
                CpuUsage               = pushLogModel.CpuUsage,
                ElapsedTime            = pushLogModel.ElapsedTime,
                HttpRequestUrl         = pushLogModel.HttpRequestUrl,
                HttpRequestHeaders     = pushLogModel.HttpHeaders,
                HttRequestBody         = pushLogModel.HttpRequestBody,
                HttpResponseStatusCode = pushLogModel.ResponseStatusCode,
                HttpResponseBody       = pushLogModel.ResponseBody,
                MemoryUsed             = pushLogModel.MemoryUsed,
                TraceId                = pushLogModel.TraceId,
                Source                 = pushLogModel.ServiceName,
                SourceId               = pushLogModel.RegisteredServiceId,
                StackTrace             = pushLogModel.StackTraces
            };

            await _logEventRepository.AddAsync(logEvent);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> ConsumeLog([FromBody] PushLogModel pushLogModel)
        {
            await _logEventProvider.AddLogEvent(pushLogModel);

            return(Ok());
        }