Exemplo n.º 1
0
        /// <inheritdoc/>
        public OpsGenieAlertRequest Convert(INimatorResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            var message = string.IsNullOrEmpty(result.Message) ?
                          "Unknown message" :
                          result.Message.Truncate(MaxOpsgenieMessageLength);

            var failingLayerName = result.GetFirstFailedLayerName() ?? "UnknownLayer";

            return(new OpsGenieAlertRequest(message)
            {
                Alias = "nimator-failure",
                Description = result.RenderPlainText(settings.Threshold).Truncate(MaxOpsgenieDescriptionLength),
                Responders = new[]
                {
                    new OpsGenieResponder
                    {
                        Type = OpsGenieResponderType.Team,
                        Name = settings.TeamName
                    }
                },
                Tags = new[] { "Nimator", failingLayerName.Truncate(MaxOpsgenieTagLength) }
            });
        }
Exemplo n.º 2
0
        public IEnumerable<DataDogEvent> Convert(INimatorResult result)
        {
            if (!result.LayerResults.Any())
            {
                yield return ConvertToDataDogEvent(result.Level, 
                    result.GetFirstFailedLayerName(), 
                    result.GetFirstFailedCheckName(), 
                    result.Message, result.RenderPlainText(settings.Threshold));
                yield break;
            }

            var layerResults = result.LayerResults.Where(l => l?.Level >= settings.Threshold);

            foreach (var layerResult in layerResults)
            {
                var layerName = layerResult.LayerName;
                var checkResults = layerResult.CheckResults.Where(c => c?.Level >= settings.Threshold);

                foreach (var checkResult in checkResults)
                {
                    yield return ConvertToDataDogEvent(checkResult.Level, 
                        layerName, 
                        checkResult.CheckName, 
                        checkResult.RenderPlainText());
                }
            }
        }
Exemplo n.º 3
0
        private void NotifyFailureResult(INimatorResult result)
        {
            var failingLayerName = (result.GetFirstFailedLayerName() ?? "UnknownLayer").Truncate(MaxOpsgenieTagLength);
            var message          = result.Message.Truncate(MaxOpsgenieMessageLength);

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

            SimpleRestUtils.PostToRestApi(AlertUrl, request);
        }