Пример #1
0
 private static void AssertServiceBusQueueMetricDefinition(ServiceBusQueueMetricDefinition deserializedServiceBusMetricDefinition, ServiceBusQueueMetricDefinition serviceBusMetricDefinition, MetricDefinition deserializedMetricDefinition)
 {
     Assert.NotNull(deserializedServiceBusMetricDefinition);
     Assert.Equal(serviceBusMetricDefinition.Namespace, deserializedServiceBusMetricDefinition.Namespace);
     Assert.Equal(serviceBusMetricDefinition.QueueName, deserializedServiceBusMetricDefinition.QueueName);
     Assert.NotNull(deserializedMetricDefinition.AzureMetricConfiguration);
     Assert.Equal(serviceBusMetricDefinition.AzureMetricConfiguration.MetricName, deserializedMetricDefinition.AzureMetricConfiguration.MetricName);
     Assert.NotNull(deserializedMetricDefinition.AzureMetricConfiguration.Aggregation);
     Assert.Equal(serviceBusMetricDefinition.AzureMetricConfiguration.Aggregation.Type, deserializedMetricDefinition.AzureMetricConfiguration.Aggregation.Type);
     Assert.Equal(serviceBusMetricDefinition.AzureMetricConfiguration.Aggregation.Interval, deserializedMetricDefinition.AzureMetricConfiguration.Aggregation.Interval);
 }
        public MetricsDeclarationBuilder WithServiceBusMetric(string metricName = "promitor-service-bus", string metricDescription = "Description for a metric", string queueName = "promitor-queue", string serviceBusNamespace = "promitor-namespace", string azureMetricName = "Total")
        {
            var azureMetricConfiguration = CreateAzureMetricConfiguration(azureMetricName);
            var metric = new ServiceBusQueueMetricDefinition
            {
                Name        = metricName,
                Description = metricDescription,
                QueueName   = queueName,
                Namespace   = serviceBusNamespace,
                AzureMetricConfiguration = azureMetricConfiguration
            };

            _metrics.Add(metric);

            return(this);
        }
Пример #3
0
        public MetricsDeclarationBuilder WithServiceBusMetric(string metricName = "foo", string metricDescription = "Description for a metric", string queueName = "foo-queue", string serviceBusNamespace = "foo-space", string azureMetricName = "Total")
        {
            var metric = new ServiceBusQueueMetricDefinition
            {
                ResourceType             = ResourceType.ServiceBusQueue,
                Name                     = metricName,
                Description              = metricDescription,
                QueueName                = queueName,
                Namespace                = serviceBusNamespace,
                AzureMetricConfiguration = new AzureMetricConfiguration
                {
                    MetricName  = azureMetricName,
                    Aggregation = AggregationType.Average
                }
            };

            metrics.Add(metric);

            return(this);
        }
Пример #4
0
        private List <string> ValidateMetric(ServiceBusQueueMetricDefinition metric)
        {
            var errorMessages = new List <string>();

            if (metric == null)
            {
                errorMessages.Add("Invalid metric is configured");
                return(errorMessages);
            }

            if (string.IsNullOrWhiteSpace(metric.Namespace))
            {
                errorMessages.Add($"{metric.Namespace} is not configured");
            }

            if (string.IsNullOrWhiteSpace(metric.QueueName))
            {
                errorMessages.Add($"{metric.QueueName} is not configured");
            }

            if (string.IsNullOrWhiteSpace(metric.Name))
            {
                errorMessages.Add($"{metric.QueueName} is not configured");
            }

            if (metric.ResourceType == ResourceType.NotSpecified)
            {
                errorMessages.Add($"{metric.ResourceType} '{nameof(ResourceType.NotSpecified)}' is not supported");
            }

            var metricsConfigurationErrorMessages = ValidateAzureMetricConfiguration(metric.AzureMetricConfiguration);

            errorMessages.AddRange(metricsConfigurationErrorMessages);

            return(errorMessages);
        }
 protected void AssertMetricDefinition(MetricDefinition deserializedMetricDefinition, ServiceBusQueueMetricDefinition serviceBusMetricDefinition)
 {
     Assert.NotNull(deserializedMetricDefinition);
     Assert.Equal(serviceBusMetricDefinition.Name, deserializedMetricDefinition.Name);
     Assert.Equal(serviceBusMetricDefinition.Description, deserializedMetricDefinition.Description);
     Assert.Equal(serviceBusMetricDefinition.ResourceType, deserializedMetricDefinition.ResourceType);
 }