示例#1
0
        public async Task <IncidentEntity> CreateAsync(ParsedIncident input)
        {
            var groupEntity = await _aggregationProvider.GetAsync(input);

            var affectedPath = _pathProvider.Get(input);

            using (_logger.Scope("Creating incident for parsed incident with path {AffectedComponentPath}.", affectedPath))
            {
                var incidentEntity = new IncidentEntity(
                    input.Id,
                    groupEntity,
                    affectedPath,
                    input.AffectedComponentStatus,
                    input.StartTime,
                    input.EndTime);

                await _table.InsertOrReplaceAsync(incidentEntity);

                if (incidentEntity.AffectedComponentStatus > groupEntity.AffectedComponentStatus)
                {
                    _logger.LogInformation("Incident {IncidentRowKey} has a greater severity than incident group {GroupRowKey} it was just linked to ({NewSeverity} > {OldSeverity}), updating group's severity.",
                                           incidentEntity.RowKey, groupEntity.RowKey, (ComponentStatus)incidentEntity.AffectedComponentStatus, (ComponentStatus)groupEntity.AffectedComponentStatus);
                    groupEntity.AffectedComponentStatus = incidentEntity.AffectedComponentStatus;
                    await _table.ReplaceAsync(groupEntity);
                }

                return(incidentEntity);
            }
        }
示例#2
0
        public Task Set(string name, DateTime value)
        {
            name = name ?? throw new ArgumentNullException(nameof(name));

            using (_logger.Scope("Updating cursor with name {CursorName} to {CursorValue}.", name, value))
            {
                var cursorEntity = new CursorEntity(name, value);
                return(_table.InsertOrReplaceAsync(cursorEntity));
            }
        }
示例#3
0
        public async Task <EventEntity> CreateAsync(ParsedIncident input)
        {
            var affectedPath = _pathProvider.Get(input);

            using (_logger.Scope("Creating event for parsed incident with path {AffectedComponentPath}.", affectedPath))
            {
                var entity = new EventEntity(affectedPath, input.StartTime);
                await _table.InsertOrReplaceAsync(entity);

                return(entity);
            }
        }
示例#4
0
        public async Task <IncidentGroupEntity> CreateAsync(ParsedIncident input)
        {
            var eventEntity = await _aggregationProvider.GetAsync(input);

            var affectedPath = _pathProvider.Get(input);

            using (_logger.Scope("Creating incident for parsed incident with path {AffectedComponentPath}.", affectedPath))
            {
                var incidentGroupEntity = new IncidentGroupEntity(
                    eventEntity,
                    affectedPath,
                    (ComponentStatus)input.AffectedComponentStatus,
                    input.StartTime);

                await _table.InsertOrReplaceAsync(incidentGroupEntity);

                return(incidentGroupEntity);
            }
        }