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); } }
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)); } }
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); } }
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); } }