コード例 #1
0
        public async Task CollectAsync(QuickFactContext context)
        {
            var versions = await _repository.FindForIncidentAsync(context.IncidentId);

            if (!versions.Any())
            {
                return;
            }

            context.CollectedFacts.Add(new QuickFact
            {
                Title       = "Versions",
                Description = "Application versions that this incident have been detected in.",
                Value       = string.Join(", ", versions.Select(x => "v" + x.Version))
            });
        }
コード例 #2
0
        public async Task <GetIncidentResult> HandleAsync(IMessageContext context, GetIncident query)
        {
            _logger.Info("GetIncident step 1");
            var sql =
                "SELECT Incidents.*, Users.Username as AssignedTo " +
                " FROM Incidents WITH(READUNCOMMITTED)" +
                " LEFT JOIN Users WITH(READUNCOMMITTED) ON (AssignedToId = Users.AccountId) " +
                " WHERE Incidents.Id = @id";

            var result = await _unitOfWork.FirstAsync <GetIncidentResult>(sql, new { Id = query.IncidentId });

            _logger.Info("GetIncident step 2");

            result.Tags = GetTags(query.IncidentId);
            _logger.Info("GetIncident step 3");

            var facts = new List <QuickFact>
            {
                new QuickFact
                {
                    Title       = "Created",
                    Description = "When we received the first error report",
                    Value       = result.CreatedAtUtc.ToShortDateString()
                },
                new QuickFact
                {
                    Title       = "Last report",
                    Description = "When we received the most recent error report",
                    Value       = result.LastReportReceivedAtUtc.ToShortDateString()
                },
                new QuickFact
                {
                    Title       = "Report Count",
                    Description = "Number of reports since this incident was discovered",
                    Value       = result.ReportCount.ToString()
                }
            };

            var environments = GetEnvironments(query.IncidentId);

            if (environments.Any())
            {
                facts.Add(new QuickFact
                {
                    Title = "Environments",
                    Value = string.Join(", ", environments)
                });
            }

            _logger.Info("GetIncident step 4");
            await GetContextCollectionNames(result);

            _logger.Info("GetIncident step 5");
            await GetReportStatistics(result);

            _logger.Info("GetIncident step 6");
            await GetStatSummary(query, facts);

            _logger.Info("GetIncident step 7");

            var solutions = new List <SuggestedIncidentSolution>();
            var suggestedSolutionContext = new SolutionProviderContext(solutions)
            {
                ApplicationId = result.ApplicationId,
                Description   = result.Description,
                FullName      = result.FullName,
                IncidentId    = result.Id,
                StackTrace    = result.StackTrace,
                Tags          = result.Tags
            };

            var contextData        = new List <HighlightedContextData>();
            var highlightedContext = new HighlightedContextDataProviderContext(contextData)
            {
                ApplicationId = result.ApplicationId,
                Description   = result.Description,
                FullName      = result.FullName,
                IncidentId    = result.Id,
                StackTrace    = result.StackTrace,
                Tags          = result.Tags
            };
            var quickFactContext = new QuickFactContext(result.ApplicationId, query.IncidentId, facts);

            foreach (var provider in _quickfactProviders)
            {
                await provider.CollectAsync(quickFactContext);
            }
            foreach (var provider in _highlightedContextDataProviders)
            {
                await provider.CollectAsync(highlightedContext);
            }
            foreach (var provider in _solutionProviders)
            {
                await provider.SuggestSolutionAsync(suggestedSolutionContext);
            }
            _logger.Info("GetIncident step 8");

            result.Facts = facts.ToArray();
            result.SuggestedSolutions     = solutions.ToArray();
            result.HighlightedContextData = contextData.ToArray();
            return(result);
        }
コード例 #3
0
        public async Task <GetIncidentResult> HandleAsync(IMessageContext context, GetIncident query)
        {
            _logger.Info("GetIncident step 1");
            var sql =
                "SELECT Incidents.*, Users.Username as AssignedTo " +
                " FROM Incidents WITH (ReadPast)" +
                " LEFT JOIN Users WITH (ReadPast) ON (AssignedToId = Users.AccountId) " +
                " WHERE Incidents.Id = @id";

            var result = await _unitOfWork.FirstAsync <GetIncidentResult>(sql, new { Id = query.IncidentId });

            _logger.Info("GetIncident step 2");

            var tags = GetTags(query.IncidentId);

            result.Tags = tags.ToArray();
            _logger.Info("GetIncident step 3");

            var facts = new List <QuickFact>
            {
                new QuickFact
                {
                    Title       = "Report Count",
                    Description = "Number of reports since this incident was discovered",
                    Value       = result.ReportCount.ToString()
                }
            };


            _logger.Info("GetIncident step 4");
            await GetContextCollectionNames(result);

            _logger.Info("GetIncident step 5");
            await GetReportStatistics(result);

            _logger.Info("GetIncident step 6");
            await GetStatSummary(query, facts);

            _logger.Info("GetIncident step 7");

            var contextData      = new List <HighlightedContextData>();
            var solutions        = new List <SuggestedIncidentSolution>();
            var quickFactContext = new QuickFactContext(result.ApplicationId, query.IncidentId, facts);

            foreach (var provider in _quickfactProviders)
            {
                await provider.CollectAsync(quickFactContext);
            }
            foreach (var provider in _highlightedContextDataProviders)
            {
                await provider.CollectAsync(query.IncidentId, contextData);
            }
            foreach (var provider in _solutionProviders)
            {
                await provider.SuggestSolutionAsync(query.IncidentId, solutions);
            }
            _logger.Info("GetIncident step 8");

            result.Facts = facts.ToArray();
            result.SuggestedSolutions     = solutions.ToArray();
            result.HighlightedContextData = contextData.ToArray();
            return(result);
        }