Ejemplo n.º 1
0
      private static string ToJson(IEnumerable<LogEvent> events)
      {
         var data = new RawEvents
         {
            Events = events.Select(e => RawEvent.FromLogEvent(e)).ToArray()
         };

         string json = data.ToJsonString();
         return json;
      }
Ejemplo n.º 2
0
        private static string ToJson(IEnumerable <LogEvent> events)
        {
            var data = new RawEvents
            {
                Events = events.Select(e => RawEvent.FromLogEvent(e)).ToArray()
            };

            throw new NotImplementedException();
            //string json = data.ToJsonString();
            //return json;
        }
Ejemplo n.º 3
0
        private static string ToJson(IEnumerable <LogEvent> events)
        {
            var data = new RawEvents
            {
                Events = events.Select(e => RawEvent.FromLogEvent(e)).ToArray()
            };

            string json = data.ToJsonString();

            return(json);
        }
Ejemplo n.º 4
0
 private void AddEvent(IRecorderEvent e)
 {
     if (_windowTracker.HasActiveWindowChanged())
     {
         LogWindowInfo();
         OnLogAction(string.Format("Active Window Changed to: {0} id: {0}", _windowTracker.GetActiveWindowTitle(), _windowTracker.GetActiveWindowId().ToInt64()));
         RawEvents.Add(new TransitionEvent()
         {
             TransitionType = TransitionType.ActiveWindowChanged
         });
     }
     RawEvents.Add(e);
 }
        public async Task PublishAsync(HealthReport report, CancellationToken cancellationToken)
        {
            var level = _options.DefaultInputLevel;

            switch (report.Status)
            {
            case HealthStatus.Degraded:
                level = SeqInputLevel.Warning;
                break;

            case HealthStatus.Unhealthy:
                level = SeqInputLevel.Error;
                break;
            }

            var events = new RawEvents
            {
                Events = new[]
                {
                    new RawEvent
                    {
                        Timestamp       = DateTimeOffset.UtcNow,
                        MessageTemplate = $"[{Assembly.GetEntryAssembly()?.GetName().Name} - HealthCheck Result]",
                        Level           = level.ToString(),
                        Properties      = new Dictionary <string, object>
                        {
                            { nameof(Environment.MachineName), Environment.MachineName },
                            { nameof(Assembly), Assembly.GetEntryAssembly()?.GetName().Name },
                            { "Status", report.Status.ToString() },
                            { "TimeElapsed", report.TotalDuration.TotalMilliseconds },
                            { "RawReport", JsonConvert.SerializeObject(report) }
                        }
                    }
                }
            };

            await PushMetrics(JsonConvert.SerializeObject(events));
        }
Ejemplo n.º 6
0
        public async Task PublishAsync(HealthReport report, CancellationToken cancellationToken)
        {
            var level = "Information";

            switch (report.Status)
            {
            case HealthStatus.Degraded:
                level = "Warning";
                break;

            case HealthStatus.Unhealthy:
                level = "Error";
                break;
            }

            var events = new RawEvents
            {
                Events = new RawEvent[]
                {
                    new RawEvent
                    {
                        Timestamp       = DateTimeOffset.UtcNow,
                        MessageTemplate = EVENT_NAME,
                        Level           = level,
                        Properties      = new Dictionary <string, object>
                        {
                            { nameof(Environment.MachineName), Environment.MachineName },
                            { nameof(Assembly), Assembly.GetEntryAssembly().GetName().Name },
                            { METRIC_STATUS_NAME, (int)report.Status },
                            { METRIC_DURATION_NAME, report.TotalDuration.TotalMilliseconds }
                        }
                    }
                }
            };

            await PushMetrics(JsonConvert.SerializeObject(events));
        }