Esempio n. 1
0
        public void Send([NotNull] HealthCheckResult result)
        {
            Guard.AgainstNull(nameof(result), result);

            result.Finalize(result.CheckId, r => r.Level >= _settings.Threshold);
            if (result.Level >= _settings.Threshold)
            {
                _writeLine(_formatter.Format(result));
            }
        }
Esempio n. 2
0
        private void NotifyFailureResult(HealthCheckResult result)
        {
            var failingLayerName = (result.AllResults.FirstOrDefault(r => r.Level >= LogLevel.Error)?.CheckId?.Name ?? "UnknownLayer").Truncate(MaxOpsgenieTagLength);
            var message          = result.Reason.Truncate(MaxOpsgenieMessageLength);

            var request = new OpsGenieCreateAlertRequest(this._settings.ApiKey, message)
            {
                Alias       = "nimator-failure",
                Description = _formatter.Format(result),
                Teams       = new[] { this._settings.TeamName },
                Tags        = new[] { "Nimator", failingLayerName }
            };

            SimpleRestUtils.PostToRestApi(AlertUrl, request);
        }
Esempio n. 3
0
        public SlackMessage(
            [NotNull] HealthCheckResult result,
            [NotNull] IHealthCheckResultFormatter formatter)
        {
            // Because "text" will be shown (a) full-width and (b) full height without
            // a 'Show More...' link, we prefer that to use for the full description.
            // The "attachments" will then be a simpler things, drawing attention with
            // specific coloring and icons.

            Text = result.Reason
                   + ":\n```"
                   + formatter.Format(result)
                   + "```";

            SlackMessageAttachments = new[]
            {
                new SlackMessageAttachment
                {
                    Text  = CallToActionForLevel(result.Level),
                    Color = GetHexForLevel(result.Level)
                }
            };
        }