From 05a1262cf82ed2431ed0b27114aff6874b8dacee Mon Sep 17 00:00:00 2001 From: Tom Kerkhove Date: Thu, 2 Jul 2020 22:29:31 +0200 Subject: [PATCH 1/2] Rename all the things Signed-off-by: Tom Kerkhove --- .../resource-discovery-declaration.yaml | 2 +- config/promitor/scraper/metrics.yaml | 10 +- .../Configuration/ResourceDeclaration.cs | 2 +- ...ollection.cs => ResourceDiscoveryGroup.cs} | 2 +- .../Controllers/DiscoveryController.cs | 12 +- ...s => ResourceDiscoveryGroupsController.cs} | 18 +-- .../Docs/Open-Api.xml | 16 +-- .../Repositories/ResourceRepository.cs | 16 +-- .../Discovery/ResourceDiscoveryClient.cs | 4 +- .../Discovery/ResourceDiscoveryRepository.cs | 6 +- .../IServiceCollectionExtensions.cs | 2 +- ...s => ResourceDiscoveryGroupScrapingJob.cs} | 22 ++-- .../Scheduling/SchedulingExtensions.cs | 20 ++-- .../MetricDefinitions/MetricsValidator.cs | 2 +- ...tion.cs => AzureResourceDiscoveryGroup.cs} | 2 +- .../Model/Metrics/MetricDefinition.cs | 2 +- .../AzureResourceCollectionDeserializer.cs | 4 +- .../v1/Core/MetricDefinitionDeserializer.cs | 18 +-- .../v1/Mapping/V1MappingProfile.cs | 2 +- ...zureResourceDiscoveryGroupDefinitionV1.cs} | 2 +- .../v1/Model/MetricDefinitionV1.cs | 2 +- .../ResourceDiscoveryClient.cs | 8 +- .../Services/ResourceCollectionTests.cs | 14 +-- .../Services/ResourceDiscoveryTests.cs | 42 +++---- .../Metrics/v1/MetricsDeclarationBuilder.cs | 106 +++++++++--------- ...zureResourceCollectionDeserializerTests.cs | 8 +- .../Core/MetricDefinitionDeserializerTests.cs | 46 ++++---- .../Serialization/v1/V1DeserializerFactory.cs | 2 +- .../Serialization/v1/V1SerializationTests.cs | 20 ++-- ...tMetricsDeclarationValidationStepsTests.cs | 6 +- ...nMetricsDeclarationValidationStepsTests.cs | 6 +- ...geMetricsDeclarationValidationStepTests.cs | 6 +- ...ceMetricsDeclarationValidationStepTests.cs | 6 +- ...ryMetricsDeclarationValidationStepTests.cs | 6 +- ...DbMetricsDeclarationValidationStepTests.cs | 6 +- ...eMetricsDeclarationValidationStepsTests.cs | 6 +- ...geMetricsDeclarationValidationStepTests.cs | 6 +- ...pMetricsDeclarationValidationStepsTests.cs | 6 +- ...icMetricsDeclarationValidationStepTests.cs | 6 +- ...bMetricsDeclarationValidationStepsTests.cs | 6 +- ...tMetricsDeclarationValidationStepsTests.cs | 6 +- ...eMetricsDeclarationValidationStepsTests.cs | 6 +- ...qlMetricsDeclarationValidationStepTests.cs | 6 +- ...heMetricsDeclarationValidationStepTests.cs | 6 +- ...ueMetricsDeclarationValidationStepTests.cs | 6 +- ...seMetricsDeclarationValidationStepTests.cs | 6 +- ...ceMetricsDeclarationValidationStepTests.cs | 6 +- ...erMetricsDeclarationValidationStepTests.cs | 6 +- ...ntMetricsDeclarationValidationStepTests.cs | 6 +- ...ueMetricsDeclarationValidationStepTests.cs | 6 +- ...eMetricsDeclarationValidationStepsTests.cs | 6 +- ...tMetricsDeclarationValidationStepsTests.cs | 6 +- ...pMetricsDeclarationValidationStepsTests.cs | 6 +- 53 files changed, 278 insertions(+), 278 deletions(-) rename src/Promitor.Agents.ResourceDiscovery/Configuration/{ResourceCollection.cs => ResourceDiscoveryGroup.cs} (87%) rename src/Promitor.Agents.ResourceDiscovery/Controllers/{ResourceCollectionsController.cs => ResourceDiscoveryGroupsController.cs} (54%) rename src/Promitor.Agents.Scraper/Scheduling/{ResourceCollectionScrapingJob.cs => ResourceDiscoveryGroupScrapingJob.cs} (84%) rename src/Promitor.Core.Scraping/Configuration/Model/Metrics/{AzureResourceCollection.cs => AzureResourceDiscoveryGroup.cs} (72%) rename src/Promitor.Core.Scraping/Configuration/Serialization/v1/Model/{AzureResourceCollectionDefinitionV1.cs => AzureResourceDiscoveryGroupDefinitionV1.cs} (84%) diff --git a/config/promitor/resource-discovery/resource-discovery-declaration.yaml b/config/promitor/resource-discovery/resource-discovery-declaration.yaml index 9cfab8ec8..961b2e605 100644 --- a/config/promitor/resource-discovery/resource-discovery-declaration.yaml +++ b/config/promitor/resource-discovery/resource-discovery-declaration.yaml @@ -3,7 +3,7 @@ azureLandscape: subscriptions: - 0329dd2a-59dc-4493-aa54-cb01cb027dc2 - 0f9d7fea-99e8-4768-8672-06a28514f77e -resourceCollections: +resourceDiscoveryGroups: - name: service-bus-landscape type: ServiceBusQueue criteria: diff --git a/config/promitor/scraper/metrics.yaml b/config/promitor/scraper/metrics.yaml index 7b1f8843a..9e3d83f51 100644 --- a/config/promitor/scraper/metrics.yaml +++ b/config/promitor/scraper/metrics.yaml @@ -56,7 +56,7 @@ metrics: type: Average # Optionally override the default aggregation interval (metricDefaults.aggregation.interval) interval: 00:15:00 - resourceCollections: + resourceDiscoveryGroups: - name: service-bus-landscape - name: promitor_demo_servicebusqueue_queue_size description: "Amount of active messages of the 'orders' queue (determined with ServiceBusQueue provider)" @@ -153,7 +153,7 @@ metrics: metricName: TotalPullCount aggregation: type: Average - resourceCollections: + resourceDiscoveryGroups: - name: container-registry-landscape - name: promitor_demo_appplan_percentage_cpu_discovered description: "Average percentage of memory usage on an Azure App Plan" @@ -162,7 +162,7 @@ metrics: metricName: MemoryPercentage aggregation: type: Average - resourceCollections: + resourceDiscoveryGroups: - name: app-plan-landscape - name: promitor_demo_webapp_cpu_discovery description: "Amount of CPU time used for an Azure Web App" @@ -171,7 +171,7 @@ metrics: metricName: CpuTime aggregation: type: Total - resourceCollections: + resourceDiscoveryGroups: - name: web-app-landscape - name: promitor_demo_function_memory_discovery description: "Average memory for an Azure Function App" @@ -180,5 +180,5 @@ metrics: metricName: MemoryWorkingSet aggregation: type: Average - resourceCollections: + resourceDiscoveryGroups: - name: function-app-landscape \ No newline at end of file diff --git a/src/Promitor.Agents.ResourceDiscovery/Configuration/ResourceDeclaration.cs b/src/Promitor.Agents.ResourceDiscovery/Configuration/ResourceDeclaration.cs index 96431f309..974ca1399 100644 --- a/src/Promitor.Agents.ResourceDiscovery/Configuration/ResourceDeclaration.cs +++ b/src/Promitor.Agents.ResourceDiscovery/Configuration/ResourceDeclaration.cs @@ -5,6 +5,6 @@ namespace Promitor.Agents.ResourceDiscovery.Configuration public class ResourceDeclaration { public AzureLandscape AzureLandscape { get; set; } - public List ResourceCollections { get; set; } + public List ResourceDiscoveryGroups { get; set; } } } \ No newline at end of file diff --git a/src/Promitor.Agents.ResourceDiscovery/Configuration/ResourceCollection.cs b/src/Promitor.Agents.ResourceDiscovery/Configuration/ResourceDiscoveryGroup.cs similarity index 87% rename from src/Promitor.Agents.ResourceDiscovery/Configuration/ResourceCollection.cs rename to src/Promitor.Agents.ResourceDiscovery/Configuration/ResourceDiscoveryGroup.cs index df2a10300..cd2ddbe35 100644 --- a/src/Promitor.Agents.ResourceDiscovery/Configuration/ResourceCollection.cs +++ b/src/Promitor.Agents.ResourceDiscovery/Configuration/ResourceDiscoveryGroup.cs @@ -2,7 +2,7 @@ namespace Promitor.Agents.ResourceDiscovery.Configuration { - public class ResourceCollection + public class ResourceDiscoveryGroup { public string Name { get; set; } public ResourceType Type { get; set; } diff --git a/src/Promitor.Agents.ResourceDiscovery/Controllers/DiscoveryController.cs b/src/Promitor.Agents.ResourceDiscovery/Controllers/DiscoveryController.cs index 6b95a3f9b..0676e11e6 100644 --- a/src/Promitor.Agents.ResourceDiscovery/Controllers/DiscoveryController.cs +++ b/src/Promitor.Agents.ResourceDiscovery/Controllers/DiscoveryController.cs @@ -14,7 +14,7 @@ namespace Promitor.Agents.ResourceDiscovery.Controllers /// API endpoint to discover Azure resources /// [ApiController] - [Route("api/v1/resources/collections")] + [Route("api/v1/resources/groups")] public class DiscoveryController : ControllerBase { private readonly JsonSerializerSettings _serializerSettings; @@ -40,15 +40,15 @@ public DiscoveryController(ResourceRepository resourceRepository) /// Discover Resources /// /// Discovers Azure resources matching the criteria. - [HttpGet("{resourceCollectionName}/discovery", Name = "Discovery_Get")] - public async Task Get(string resourceCollectionName) + [HttpGet("{resourceDiscoveryGroup}/discovery", Name = "Discovery_Get")] + public async Task Get(string resourceDiscoveryGroup) { try { - var foundResources = await _resourceRepository.GetResourcesAsync(resourceCollectionName); + var foundResources = await _resourceRepository.GetResourcesAsync(resourceDiscoveryGroup); if (foundResources == null) { - return NotFound(new {Information = "No resource collection was found with specified name"}); + return NotFound(new {Information = "No resource discovery group was found with specified name"}); } var serializedResources = JsonConvert.SerializeObject(foundResources, _serializerSettings); @@ -59,7 +59,7 @@ public async Task Get(string resourceCollectionName) } catch (ResourceTypeNotSupportedException resourceTypeNotSupportedException) { - return StatusCode((int)HttpStatusCode.NotImplemented, new ResourceDiscoveryFailedDetails { Details=$"Resource type '{resourceTypeNotSupportedException.ResourceType}' for collection '{resourceCollectionName}' is not supported"}); + return StatusCode((int)HttpStatusCode.NotImplemented, new ResourceDiscoveryFailedDetails { Details=$"Resource type '{resourceTypeNotSupportedException.ResourceType}' for discovery group '{resourceDiscoveryGroup}' is not supported"}); } } } diff --git a/src/Promitor.Agents.ResourceDiscovery/Controllers/ResourceCollectionsController.cs b/src/Promitor.Agents.ResourceDiscovery/Controllers/ResourceDiscoveryGroupsController.cs similarity index 54% rename from src/Promitor.Agents.ResourceDiscovery/Controllers/ResourceCollectionsController.cs rename to src/Promitor.Agents.ResourceDiscovery/Controllers/ResourceDiscoveryGroupsController.cs index 5a9a975d7..b23759e52 100644 --- a/src/Promitor.Agents.ResourceDiscovery/Controllers/ResourceCollectionsController.cs +++ b/src/Promitor.Agents.ResourceDiscovery/Controllers/ResourceDiscoveryGroupsController.cs @@ -6,18 +6,18 @@ namespace Promitor.Agents.ResourceDiscovery.Controllers { /// - /// API endpoint to interact with resource collections + /// API endpoint to interact with resource discovery groups /// [ApiController] - [Route("api/v1/resources/collections")] - public class ResourceCollectionsController : ControllerBase + [Route("api/v1/resources/groups")] + public class ResourceDiscoveryGroupsController : ControllerBase { private readonly IOptionsMonitor _resourceDeclarationMonitor; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public ResourceCollectionsController(IOptionsMonitor resourceDeclarationMonitor) + public ResourceDiscoveryGroupsController(IOptionsMonitor resourceDeclarationMonitor) { Guard.NotNull(resourceDeclarationMonitor, nameof(resourceDeclarationMonitor)); @@ -25,14 +25,14 @@ public ResourceCollectionsController(IOptionsMonitor resour } /// - /// Get Resource Collections + /// Get Resource Discovery Groups /// - /// Lists all available resource collections. - [HttpGet(Name = "ResourceCollections_Get")] + /// Lists all available resource discovery groups. + [HttpGet(Name = "ResourceDiscoveryGroups_Get")] public IActionResult Get() { var resourceDeclaration = _resourceDeclarationMonitor.CurrentValue; - return Ok(resourceDeclaration.ResourceCollections); + return Ok(resourceDeclaration.ResourceDiscoveryGroups); } } } diff --git a/src/Promitor.Agents.ResourceDiscovery/Docs/Open-Api.xml b/src/Promitor.Agents.ResourceDiscovery/Docs/Open-Api.xml index 5428c4924..990d717fa 100644 --- a/src/Promitor.Agents.ResourceDiscovery/Docs/Open-Api.xml +++ b/src/Promitor.Agents.ResourceDiscovery/Docs/Open-Api.xml @@ -39,21 +39,21 @@ API is healthy API is unhealthy or in degraded state - + - API endpoint to interact with resource collections + API endpoint to interact with resource discovery groups - + - Initializes a new instance of the class. + Initializes a new instance of the class. - + - Get Resource Collections + Get Resource Discovery Groups - Lists all available resource collections. + Lists all available resource discovery groups. @@ -75,7 +75,7 @@ Get resources that are part of a given resource collection - Name of the resource collection + Name of the resource collection diff --git a/src/Promitor.Agents.ResourceDiscovery/Repositories/ResourceRepository.cs b/src/Promitor.Agents.ResourceDiscovery/Repositories/ResourceRepository.cs index 782e75e6e..d60fee5cf 100644 --- a/src/Promitor.Agents.ResourceDiscovery/Repositories/ResourceRepository.cs +++ b/src/Promitor.Agents.ResourceDiscovery/Repositories/ResourceRepository.cs @@ -35,21 +35,21 @@ public ResourceRepository(AzureResourceGraph azureResourceGraph, IOptionsMonitor /// /// Get resources that are part of a given resource collection /// - /// Name of the resource collection - public async Task> GetResourcesAsync(string resourceCollectionName) + /// Name of the resource collection + public async Task> GetResourcesAsync(string resourceDiscoveryGroupName) { var resourceDeclaration = _resourceDeclarationMonitor.CurrentValue; - var resourceCollectionDefinition = resourceDeclaration.ResourceCollections.SingleOrDefault(collection => collection.Name.Equals(resourceCollectionName, StringComparison.InvariantCultureIgnoreCase)); - if (resourceCollectionDefinition == null) + var resourceDiscoveryGroupDefinition = resourceDeclaration.ResourceDiscoveryGroups.SingleOrDefault(collection => collection.Name.Equals(resourceDiscoveryGroupName, StringComparison.InvariantCultureIgnoreCase)); + if (resourceDiscoveryGroupDefinition == null) { // No collection found so nothing to return return null; } - var resourceDiscovery = ResourceDiscoveryFactory.UseResourceDiscoveryFor(resourceCollectionDefinition.Type); + var resourceDiscovery = ResourceDiscoveryFactory.UseResourceDiscoveryFor(resourceDiscoveryGroupDefinition.Type); // 1. Create query per type - var query = resourceDiscovery.DefineQuery(resourceCollectionDefinition.Criteria); + var query = resourceDiscovery.DefineQuery(resourceDiscoveryGroupDefinition.Criteria); // 2. Run Query var unparsedResults = await _azureResourceGraph.QueryAsync(query); @@ -59,8 +59,8 @@ public async Task> GetResourcesAsync(string resour var contextualInformation = new Dictionary { - {"ResourceType",resourceCollectionDefinition.Type}, - {"CollectionName",resourceCollectionName} + {"ResourceType",resourceDiscoveryGroupDefinition.Type}, + {"CollectionName",resourceDiscoveryGroupName} }; _logger.LogMetric("Discovered Resources", foundResources.Count, contextualInformation); diff --git a/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryClient.cs b/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryClient.cs index 40a6a0bdc..77b28c59b 100644 --- a/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryClient.cs +++ b/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryClient.cs @@ -34,9 +34,9 @@ public ResourceDiscoveryClient(IHttpClientFactory httpClientFactory, IOptionsMon _httpClientFactory = httpClientFactory; } - public async Task> GetAsync(string resourceCollectionName) + public async Task> GetAsync(string resourceDiscoveryGroupName) { - var uri = $"/api/v1/resources/collections/{resourceCollectionName}/discovery"; + var uri = $"/api/v1/resources/collections/{resourceDiscoveryGroupName}/discovery"; var rawResponse = await SendGetRequestAsync(uri); var foundResources = JsonConvert.DeserializeObject>(rawResponse, _serializerSettings); diff --git a/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryRepository.cs b/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryRepository.cs index fadfcd371..6c648ecf8 100644 --- a/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryRepository.cs +++ b/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryRepository.cs @@ -16,11 +16,11 @@ public ResourceDiscoveryRepository(ResourceDiscoveryClient resourceDiscoveryClie _resourceDiscoveryClient = resourceDiscoveryClient; } - public async Task> GetResourceCollectionAsync(string resourceCollectionName) + public async Task> GetResourceDiscoveryGroupAsync(string resourceDiscoveryGroupName) { - Guard.NotNullOrWhitespace(resourceCollectionName,nameof(resourceCollectionName)); + Guard.NotNullOrWhitespace(resourceDiscoveryGroupName,nameof(resourceDiscoveryGroupName)); - var resources = await _resourceDiscoveryClient.GetAsync(resourceCollectionName); + var resources = await _resourceDiscoveryClient.GetAsync(resourceDiscoveryGroupName); return resources; } } diff --git a/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs b/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs index ce518415d..5a4d30739 100644 --- a/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs +++ b/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs @@ -56,7 +56,7 @@ public static IServiceCollection DefineDependencies(this IServiceCollection serv services.AddSingleton, MetricDimensionDeserializer>(); services.AddSingleton, ScrapingDeserializer>(); services.AddSingleton, AzureMetricConfigurationDeserializer>(); - services.AddSingleton, AzureResourceCollectionDeserializer>(); + services.AddSingleton, AzureResourceDiscoveryGroupDeserializer>(); services.AddSingleton(); services.AddSingleton, MetricAggregationDeserializer>(); services.AddSingleton, SecretDeserializer>(); diff --git a/src/Promitor.Agents.Scraper/Scheduling/ResourceCollectionScrapingJob.cs b/src/Promitor.Agents.Scraper/Scheduling/ResourceDiscoveryGroupScrapingJob.cs similarity index 84% rename from src/Promitor.Agents.Scraper/Scheduling/ResourceCollectionScrapingJob.cs rename to src/Promitor.Agents.Scraper/Scheduling/ResourceDiscoveryGroupScrapingJob.cs index d96810f87..411535a26 100644 --- a/src/Promitor.Agents.Scraper/Scheduling/ResourceCollectionScrapingJob.cs +++ b/src/Promitor.Agents.Scraper/Scheduling/ResourceDiscoveryGroupScrapingJob.cs @@ -20,7 +20,7 @@ namespace Promitor.Agents.Scraper.Scheduling { - public class ResourceCollectionScrapingJob : MetricScrapingJob, IScheduledJob + public class ResourceDiscoveryGroupScrapingJob : MetricScrapingJob, IScheduledJob { private readonly ResourceDiscoveryRepository _resourceDiscoveryRepository; private readonly MetricDefinition _metricDefinition; @@ -35,15 +35,15 @@ public class ResourceCollectionScrapingJob : MetricScrapingJob, IScheduledJob private readonly MetricScraperFactory _metricScraperFactory; - public ResourceCollectionScrapingJob(string jobName, string resourceCollectionName, AzureMetadata azureMetadata, MetricDefinition metricDefinition, ResourceDiscoveryRepository resourceDiscoveryRepository, + public ResourceDiscoveryGroupScrapingJob(string jobName, string resourceDiscoveryGroupName, AzureMetadata azureMetadata, MetricDefinition metricDefinition, ResourceDiscoveryRepository resourceDiscoveryRepository, MetricSinkWriter metricSinkWriter, IPrometheusMetricWriter prometheusMetricWriter, MetricScraperFactory metricScraperFactory, AzureMonitorClientFactory azureMonitorClientFactory, IRuntimeMetricsCollector runtimeMetricCollector, IConfiguration configuration, IOptions azureMonitorLoggingConfiguration, ILoggerFactory loggerFactory, - ILogger logger) + ILogger logger) : base(jobName, logger) { - Guard.NotNullOrWhitespace(resourceCollectionName, nameof(resourceCollectionName)); + Guard.NotNullOrWhitespace(resourceDiscoveryGroupName, nameof(resourceDiscoveryGroupName)); Guard.NotNull(resourceDiscoveryRepository, nameof(resourceDiscoveryRepository)); Guard.NotNull(metricDefinition, nameof(metricDefinition)); Guard.NotNull(azureMetadata, nameof(azureMetadata)); @@ -57,7 +57,7 @@ public ResourceCollectionScrapingJob(string jobName, string resourceCollectionNa Guard.NotNull(loggerFactory, nameof(loggerFactory)); Guard.NotNull(metricSinkWriter, nameof(metricSinkWriter)); - ResourceCollectionName = resourceCollectionName; + resourceDiscoveryGroupName = resourceDiscoveryGroupName; _azureMetadata = azureMetadata; _metricDefinition = metricDefinition; @@ -74,20 +74,20 @@ public ResourceCollectionScrapingJob(string jobName, string resourceCollectionNa _metricScraperFactory = metricScraperFactory; } - public string ResourceCollectionName { get; } + public string ResourceDiscoveryGroupName { get; } public async Task ExecuteAsync(CancellationToken cancellationToken) { - Logger.LogInformation("Scraping resource collection {ResourceCollection} - {Timestamp}", ResourceCollectionName, DateTimeOffset.UtcNow); + Logger.LogInformation("Scraping resource collection {ResourceDiscoveryGroup} - {Timestamp}", ResourceDiscoveryGroupName, DateTimeOffset.UtcNow); try { - var discoveredResources = await _resourceDiscoveryRepository.GetResourceCollectionAsync(ResourceCollectionName); - Logger.LogInformation("Discovered {ResourceCount} resources for resource collection {ResourceCollection}.", discoveredResources?.Count ?? 0, ResourceCollectionName); + var discoveredResources = await _resourceDiscoveryRepository.GetResourceDiscoveryGroupAsync(ResourceDiscoveryGroupName); + Logger.LogInformation("Discovered {ResourceCount} resources for resource collection {ResourceDiscoveryGroup}.", discoveredResources?.Count ?? 0, ResourceDiscoveryGroupName); if (discoveredResources == null) { - Logger.LogWarning("Discovered no resources for resource collection {ResourceCollection}.", ResourceCollectionName); + Logger.LogWarning("Discovered no resources for resource collection {ResourceDiscoveryGroup}.", ResourceDiscoveryGroupName); return; } @@ -107,7 +107,7 @@ public async Task ExecuteAsync(CancellationToken cancellationToken) } catch (Exception exception) { - Logger.LogCritical(exception, "Failed to scrape resource collection {ResourceCollection}: {Exception}", ResourceCollectionName, exception.Message); + Logger.LogCritical(exception, "Failed to scrape resource collection {ResourceDiscoveryGroup}: {Exception}", ResourceDiscoveryGroupName, exception.Message); } } diff --git a/src/Promitor.Agents.Scraper/Scheduling/SchedulingExtensions.cs b/src/Promitor.Agents.Scraper/Scheduling/SchedulingExtensions.cs index 09a7d5986..c8e6ef776 100644 --- a/src/Promitor.Agents.Scraper/Scheduling/SchedulingExtensions.cs +++ b/src/Promitor.Agents.Scraper/Scheduling/SchedulingExtensions.cs @@ -43,11 +43,11 @@ public static IServiceCollection ScheduleMetricScraping(this IServiceCollection var startupLogger = loggerFactory.CreateLogger(); foreach (var metric in metrics.Metrics) { - if (metric.ResourceCollections?.Any() == true) + if (metric.ResourceDiscoveryGroups?.Any() == true) { - foreach (var resourceCollection in metric.ResourceCollections) + foreach (var resourceDiscoveryGroup in metric.ResourceDiscoveryGroups) { - ScheduleResourceCollectionScraping(resourceCollection, metrics.AzureMetadata, metric, azureMonitorClientFactory, metricSinkWriter, runtimeMetricCollector, configuration, azureMonitorLoggingConfiguration, loggerFactory, startupLogger, services); + ScheduleResourceDiscoveryGroupScraping(resourceDiscoveryGroup, metrics.AzureMetadata, metric, azureMonitorClientFactory, metricSinkWriter, runtimeMetricCollector, configuration, azureMonitorLoggingConfiguration, loggerFactory, startupLogger, services); } } @@ -92,14 +92,14 @@ private static void ScheduleResourceScraping(IAzureResourceDefinition resource, logger.LogInformation("Scheduled scraping job {JobName} for resource {Resource} which will be reported as metric {MetricName}", jobName, scrapeDefinition.Resource.UniqueName, scrapeDefinition.PrometheusMetricDefinition?.Name); } - private static void ScheduleResourceCollectionScraping(AzureResourceCollection resourceCollection, AzureMetadata azureMetadata, MetricDefinition metricDefinition, AzureMonitorClientFactory azureMonitorClientFactory, MetricSinkWriter metricSinkWriter, IRuntimeMetricsCollector runtimeMetricCollector, IConfiguration configuration, IOptions azureMonitorLoggingConfiguration, ILoggerFactory loggerFactory, ILogger logger, IServiceCollection services) + private static void ScheduleResourceDiscoveryGroupScraping(AzureResourceDiscoveryGroup resourceDiscoveryGroup, AzureMetadata azureMetadata, MetricDefinition metricDefinition, AzureMonitorClientFactory azureMonitorClientFactory, MetricSinkWriter metricSinkWriter, IRuntimeMetricsCollector runtimeMetricCollector, IConfiguration configuration, IOptions azureMonitorLoggingConfiguration, ILoggerFactory loggerFactory, ILogger logger, IServiceCollection services) { - var jobName = GenerateResourceCollectionScrapingJobName(metricDefinition.PrometheusMetricDefinition?.Name, resourceCollection.Name); + var jobName = GenerateResourceDiscoveryGroupScrapingJobName(metricDefinition.PrometheusMetricDefinition?.Name, resourceDiscoveryGroup.Name); services.AddScheduler(builder => { builder.AddJob(jobServices => { - return new ResourceCollectionScrapingJob(jobName, resourceCollection.Name, azureMetadata, metricDefinition, + return new ResourceDiscoveryGroupScrapingJob(jobName, resourceDiscoveryGroup.Name, azureMetadata, metricDefinition, jobServices.GetService(), metricSinkWriter, jobServices.GetService(), @@ -109,7 +109,7 @@ private static void ScheduleResourceCollectionScraping(AzureResourceCollection r configuration, azureMonitorLoggingConfiguration, loggerFactory, - jobServices.GetService>()); + jobServices.GetService>()); }, schedulerOptions => { schedulerOptions.CronSchedule = metricDefinition.Scraping.Schedule; @@ -119,7 +119,7 @@ private static void ScheduleResourceCollectionScraping(AzureResourceCollection r builder.UnobservedTaskExceptionHandler = (sender, exceptionEventArgs) => UnobservedJobHandlerHandler(jobName, exceptionEventArgs, services); }); - logger.LogInformation("Scheduled scraping job {JobName} for resource collection {ResourceCollection} which will be reported as metric {MetricName}", jobName, resourceCollection.Name, metricDefinition.PrometheusMetricDefinition?.Name); + logger.LogInformation("Scheduled scraping job {JobName} for resource collection {ResourceDiscoveryGroup} which will be reported as metric {MetricName}", jobName, resourceDiscoveryGroup.Name, metricDefinition.PrometheusMetricDefinition?.Name); } private static string GenerateResourceScrapingJobName(ScrapeDefinition scrapeDefinition, IAzureResourceDefinition resource) @@ -138,12 +138,12 @@ private static string GenerateResourceScrapingJobName(ScrapeDefinition Validate(MetricDefinition metric) errorMessages.Add("No metric name is configured"); } - if (metric.Resources?.Any() == false && metric.ResourceCollections?.Any() == false) + if (metric.Resources?.Any() == false && metric.ResourceDiscoveryGroups?.Any() == false) { errorMessages.Add("No resource or resource collection is configured to be scraped"); } diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/AzureResourceCollection.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/AzureResourceDiscoveryGroup.cs similarity index 72% rename from src/Promitor.Core.Scraping/Configuration/Model/Metrics/AzureResourceCollection.cs rename to src/Promitor.Core.Scraping/Configuration/Model/Metrics/AzureResourceDiscoveryGroup.cs index cb7aa8fda..b344938e6 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/AzureResourceCollection.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/AzureResourceDiscoveryGroup.cs @@ -1,6 +1,6 @@ namespace Promitor.Core.Scraping.Configuration.Model.Metrics { - public class AzureResourceCollection + public class AzureResourceDiscoveryGroup { public string Name { get; set; } } diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/MetricDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/MetricDefinition.cs index 4f24cb7a6..3e9f6de8c 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/MetricDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/MetricDefinition.cs @@ -45,7 +45,7 @@ public MetricDefinition(PrometheusMetricDefinition prometheusMetricDefinition, /// /// Gets or sets the list of resource collections to discover resources with. /// - public List ResourceCollections { get; set; } + public List ResourceDiscoveryGroups { get; set; } /// /// Gets or sets the list of resources to scrape. diff --git a/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Core/AzureResourceCollectionDeserializer.cs b/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Core/AzureResourceCollectionDeserializer.cs index e0d57244b..fb1f74632 100644 --- a/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Core/AzureResourceCollectionDeserializer.cs +++ b/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Core/AzureResourceCollectionDeserializer.cs @@ -3,9 +3,9 @@ namespace Promitor.Core.Scraping.Configuration.Serialization.v1.Core { - public class AzureResourceCollectionDeserializer : Deserializer + public class AzureResourceDiscoveryGroupDeserializer : Deserializer { - public AzureResourceCollectionDeserializer(ILogger logger) : base(logger) + public AzureResourceDiscoveryGroupDeserializer(ILogger logger) : base(logger) { Map(metadata => metadata.Name) .IsRequired(); diff --git a/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Core/MetricDefinitionDeserializer.cs b/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Core/MetricDefinitionDeserializer.cs index 295b63e96..deabde6d5 100644 --- a/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Core/MetricDefinitionDeserializer.cs +++ b/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Core/MetricDefinitionDeserializer.cs @@ -9,17 +9,17 @@ namespace Promitor.Core.Scraping.Configuration.Serialization.v1.Core public class MetricDefinitionDeserializer : Deserializer { private const string ResourcesTag = "resources"; - private const string ResourceCollectionsTag = "resourceCollections"; - private readonly IDeserializer _azureResourceCollectionDeserializer; + private const string ResourceDiscoveryGroupsTag = "resourceDiscoveryGroups"; + private readonly IDeserializer _azureResourceDiscoveryGroupDeserializer; private readonly IAzureResourceDeserializerFactory _azureResourceDeserializerFactory; public MetricDefinitionDeserializer(IDeserializer azureMetricConfigurationDeserializer, IDeserializer scrapingDeserializer, - IDeserializer azureResourceCollectionDeserializer, + IDeserializer azureResourceDiscoveryGroupDeserializer, IAzureResourceDeserializerFactory azureResourceDeserializerFactory, ILogger logger) : base(logger) { - _azureResourceCollectionDeserializer = azureResourceCollectionDeserializer; + _azureResourceDiscoveryGroupDeserializer = azureResourceDiscoveryGroupDeserializer; _azureResourceDeserializerFactory = azureResourceDeserializerFactory; Map(definition => definition.Name) @@ -34,7 +34,7 @@ public MetricDefinitionDeserializer(IDeserializer az Map(definition => definition.Labels); Map(definition => definition.Scraping) .MapUsingDeserializer(scrapingDeserializer); - IgnoreField(ResourceCollectionsTag); + IgnoreField(ResourceDiscoveryGroupsTag); IgnoreField(ResourcesTag); } @@ -61,9 +61,9 @@ private void DeserializeMetrics(YamlMappingNode node, MetricDefinitionV1 metricD return; } - if (node.Children.TryGetValue(ResourceCollectionsTag, out var resourceCollectionNode)) + if (node.Children.TryGetValue(ResourceDiscoveryGroupsTag, out var resourceDiscoveryGroupNode)) { - metricDefinition.ResourceCollections = _azureResourceCollectionDeserializer.Deserialize((YamlSequenceNode)resourceCollectionNode, errorReporter); + metricDefinition.ResourceDiscoveryGroups = _azureResourceDiscoveryGroupDeserializer.Deserialize((YamlSequenceNode)resourceDiscoveryGroupNode, errorReporter); } if (node.Children.TryGetValue(ResourcesTag, out var metricsNode)) @@ -80,9 +80,9 @@ private void DeserializeMetrics(YamlMappingNode node, MetricDefinitionV1 metricD } if ((metricDefinition.Resources == null || !metricDefinition.Resources.Any()) && - (metricDefinition.ResourceCollections == null || !metricDefinition.ResourceCollections.Any())) + (metricDefinition.ResourceDiscoveryGroups == null || !metricDefinition.ResourceDiscoveryGroups.Any())) { - errorReporter.ReportError(node, "Either 'resources' or 'resourceCollections' must be specified."); + errorReporter.ReportError(node, "Either 'resources' or 'resourceDiscoveryGroups' must be specified."); } } } diff --git a/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Mapping/V1MappingProfile.cs b/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Mapping/V1MappingProfile.cs index 75883ecff..ff254ae56 100644 --- a/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Mapping/V1MappingProfile.cs +++ b/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Mapping/V1MappingProfile.cs @@ -20,7 +20,7 @@ public V1MappingProfile() CreateMap(); CreateMap(); CreateMap(); - CreateMap(); + CreateMap(); CreateMap(); CreateMap(); diff --git a/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Model/AzureResourceCollectionDefinitionV1.cs b/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Model/AzureResourceDiscoveryGroupDefinitionV1.cs similarity index 84% rename from src/Promitor.Core.Scraping/Configuration/Serialization/v1/Model/AzureResourceCollectionDefinitionV1.cs rename to src/Promitor.Core.Scraping/Configuration/Serialization/v1/Model/AzureResourceDiscoveryGroupDefinitionV1.cs index 0c12c05b7..d059468d6 100644 --- a/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Model/AzureResourceCollectionDefinitionV1.cs +++ b/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Model/AzureResourceDiscoveryGroupDefinitionV1.cs @@ -3,7 +3,7 @@ /// /// Represents a resource collection that represent a collection of Azure resource that are automatically discovered and will be scraped. /// - public class AzureResourceCollectionDefinitionV1 + public class AzureResourceDiscoveryGroupDefinitionV1 { public string Name { get; set; } } diff --git a/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Model/MetricDefinitionV1.cs b/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Model/MetricDefinitionV1.cs index af85b6cb3..2d84c0c96 100644 --- a/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Model/MetricDefinitionV1.cs +++ b/src/Promitor.Core.Scraping/Configuration/Serialization/v1/Model/MetricDefinitionV1.cs @@ -42,7 +42,7 @@ public class MetricDefinitionV1 /// /// The resource collections to be scraped. /// - public IReadOnlyCollection ResourceCollections { get; set; } + public IReadOnlyCollection ResourceDiscoveryGroups { get; set; } /// /// The resources to be scraped. diff --git a/src/Promitor.Tests.Integration/ResourceDiscoveryClient.cs b/src/Promitor.Tests.Integration/ResourceDiscoveryClient.cs index 746f315eb..1a22cfc25 100644 --- a/src/Promitor.Tests.Integration/ResourceDiscoveryClient.cs +++ b/src/Promitor.Tests.Integration/ResourceDiscoveryClient.cs @@ -28,9 +28,9 @@ public ResourceDiscoveryClient(IConfiguration configuration, ILogger logger) _logger = logger; } - public async Task GetResourceCollectionsAsync() + public async Task GetResourceDiscoveryGroupsAsync() { - return await GetAsync("/api/v1/resources/collections"); + return await GetAsync("/api/v1/resources/groups"); } public async Task GetHealthAsync() @@ -38,9 +38,9 @@ public async Task GetHealthAsync() return await GetAsync("/api/v1/health"); } - public async Task GetDiscoveredResourcesAsync(string resourceCollectionName) + public async Task GetDiscoveredResourcesAsync(string resourceDiscoveryGroupName) { - return await GetAsync($"/api/v1/resources/collections/{resourceCollectionName}/discovery"); + return await GetAsync($"/api/v1/resources/groups/{resourceDiscoveryGroupName}/discovery"); } private async Task GetAsync(string uri) diff --git a/src/Promitor.Tests.Integration/Services/ResourceCollectionTests.cs b/src/Promitor.Tests.Integration/Services/ResourceCollectionTests.cs index 8e175bb13..ca139bfb9 100644 --- a/src/Promitor.Tests.Integration/Services/ResourceCollectionTests.cs +++ b/src/Promitor.Tests.Integration/Services/ResourceCollectionTests.cs @@ -10,29 +10,29 @@ namespace Promitor.Tests.Integration.Services { [Category("Integration")] - public class ResourceCollectionTests : IntegrationTest + public class ResourceDiscoveryGroupTests : IntegrationTest { - public ResourceCollectionTests(ITestOutputHelper testOutput) + public ResourceDiscoveryGroupTests(ITestOutputHelper testOutput) : base(testOutput) { } [Fact] - public async Task ResourceCollection_GetAll_ReturnsValidList() + public async Task ResourceDiscoveryGroup_GetAll_ReturnsValidList() { // Arrange var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger); // Act - var response = await resourceDiscoveryClient.GetResourceCollectionsAsync(); + var response = await resourceDiscoveryClient.GetResourceDiscoveryGroupsAsync(); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); var rawResponseBody = await response.Content.ReadAsStringAsync(); Assert.NotEmpty(rawResponseBody); - var resourceCollections = JsonConvert.DeserializeObject>(rawResponseBody); - Assert.NotNull(resourceCollections); - Assert.NotEmpty(resourceCollections); + var resourceDiscoveryGroups = JsonConvert.DeserializeObject>(rawResponseBody); + Assert.NotNull(resourceDiscoveryGroups); + Assert.NotEmpty(resourceDiscoveryGroups); } } } diff --git a/src/Promitor.Tests.Integration/Services/ResourceDiscoveryTests.cs b/src/Promitor.Tests.Integration/Services/ResourceDiscoveryTests.cs index f4a1a47d2..7a597d77e 100644 --- a/src/Promitor.Tests.Integration/Services/ResourceDiscoveryTests.cs +++ b/src/Promitor.Tests.Integration/Services/ResourceDiscoveryTests.cs @@ -21,14 +21,14 @@ public ResourceDiscoveryTests(ITestOutputHelper testOutput) } [Fact] - public async Task ResourceDiscovery_GetForUnexistingResourceCollection_ReturnsNotFound() + public async Task ResourceDiscovery_GetForUnexistingResourceDiscoveryGroup_ReturnsNotFound() { // Arrange - string resourceCollectionName = _bogusGenerator.Lorem.Word(); + string resourceDiscoveryGroupName = _bogusGenerator.Lorem.Word(); var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger); // Act - var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceCollectionName); + var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceDiscoveryGroupName); // Assert Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); @@ -38,12 +38,12 @@ public async Task ResourceDiscovery_GetForUnexistingResourceCollection_ReturnsNo public async Task ResourceDiscovery_GetAllPerResourceTypeWithoutFilters_ReturnsExpectedAmount() { // Arrange - const string resourceCollectionName = "no-filter"; + const string resourceDiscoveryGroupName = "no-filter"; const int expectedResourceCount = 10; var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger); // Act - var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceCollectionName); + var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceDiscoveryGroupName); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -58,12 +58,12 @@ public async Task ResourceDiscovery_GetAllPerResourceTypeWithoutFilters_ReturnsE public async Task ResourceDiscovery_GetWithFilterOnOneResourceGroup_ReturnsExpectedAmount() { // Arrange - const string resourceCollectionName = "one-resource-group-scenario"; + const string resourceDiscoveryGroupName = "one-resource-group-scenario"; const int expectedResourceCount = 3; var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger); // Act - var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceCollectionName); + var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceDiscoveryGroupName); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -78,12 +78,12 @@ public async Task ResourceDiscovery_GetWithFilterOnOneResourceGroup_ReturnsExpec public async Task ResourceDiscovery_GetWithFilterOnTwoResourceGroups_ReturnsExpectedAmount() { // Arrange - const string resourceCollectionName = "two-resource-group-scenario"; + const string resourceDiscoveryGroupName = "two-resource-group-scenario"; const int expectedResourceCount = 4; var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger); // Act - var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceCollectionName); + var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceDiscoveryGroupName); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -98,12 +98,12 @@ public async Task ResourceDiscovery_GetWithFilterOnTwoResourceGroups_ReturnsExpe public async Task ResourceDiscovery_GetWithFilterOnOneSubscription_ReturnsExpectedAmount() { // Arrange - const string resourceCollectionName = "one-subscriptions-scenario"; + const string resourceDiscoveryGroupName = "one-subscriptions-scenario"; const int expectedResourceCount = 2; var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger); // Act - var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceCollectionName); + var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceDiscoveryGroupName); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -118,12 +118,12 @@ public async Task ResourceDiscovery_GetWithFilterOnOneSubscription_ReturnsExpect public async Task ResourceDiscovery_GetWithFilterOnTwoSubscriptions_ReturnsExpectedAmount() { // Arrange - const string resourceCollectionName = "two-subscriptions-scenario"; + const string resourceDiscoveryGroupName = "two-subscriptions-scenario"; const int expectedResourceCount = 10; var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger); // Act - var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceCollectionName); + var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceDiscoveryGroupName); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -138,12 +138,12 @@ public async Task ResourceDiscovery_GetWithFilterOnTwoSubscriptions_ReturnsExpec public async Task ResourceDiscovery_GetWithFilterOnAppTag_ReturnsExpectedAmount() { // Arrange - const string resourceCollectionName = "one-tag-scenario"; + const string resourceDiscoveryGroupName = "one-tag-scenario"; const int expectedResourceCount = 3; var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger); // Act - var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceCollectionName); + var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceDiscoveryGroupName); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -158,12 +158,12 @@ public async Task ResourceDiscovery_GetWithFilterOnAppTag_ReturnsExpectedAmount( public async Task ResourceDiscovery_GetWithFilterOnAppAndRegionTag_ReturnsExpectedAmount() { // Arrange - const string resourceCollectionName = "two-tag-scenario"; + const string resourceDiscoveryGroupName = "two-tag-scenario"; const int expectedResourceCount = 3; var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger); // Act - var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceCollectionName); + var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceDiscoveryGroupName); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -178,12 +178,12 @@ public async Task ResourceDiscovery_GetWithFilterOnAppAndRegionTag_ReturnsExpect public async Task ResourceDiscovery_GetWithFilterOnOneRegion_ReturnsExpectedAmount() { // Arrange - const string resourceCollectionName = "one-region-scenario"; + const string resourceDiscoveryGroupName = "one-region-scenario"; const int expectedResourceCount = 1; var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger); // Act - var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceCollectionName); + var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceDiscoveryGroupName); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -198,12 +198,12 @@ public async Task ResourceDiscovery_GetWithFilterOnOneRegion_ReturnsExpectedAmou public async Task ResourceDiscovery_GetWithFilterOnTwoRegions_ReturnsExpectedAmount() { // Arrange - const string resourceCollectionName = "two-region-scenario"; + const string resourceDiscoveryGroupName = "two-region-scenario"; const int expectedResourceCount = 9; var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger); // Act - var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceCollectionName); + var response = await resourceDiscoveryClient.GetDiscoveredResourcesAsync(resourceDiscoveryGroupName); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); diff --git a/src/Promitor.Tests.Unit/Builders/Metrics/v1/MetricsDeclarationBuilder.cs b/src/Promitor.Tests.Unit/Builders/Metrics/v1/MetricsDeclarationBuilder.cs index 5d4651a9a..652ee47f0 100644 --- a/src/Promitor.Tests.Unit/Builders/Metrics/v1/MetricsDeclarationBuilder.cs +++ b/src/Promitor.Tests.Unit/Builders/Metrics/v1/MetricsDeclarationBuilder.cs @@ -75,7 +75,7 @@ public MetricsDeclarationBuilder WithServiceBusMetric(string metricName = "promi string queueName = "promitor-queue", string serviceBusNamespace = "promitor-namespace", string azureMetricName = "Total", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new ServiceBusQueueResourceV1 @@ -84,7 +84,7 @@ public MetricsDeclarationBuilder WithServiceBusMetric(string metricName = "promi Namespace = serviceBusNamespace }; - CreateAndAddMetricDefinition(ResourceType.ServiceBusQueue, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource, metricDimension); + CreateAndAddMetricDefinition(ResourceType.ServiceBusQueue, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource, metricDimension); return this; } @@ -93,7 +93,7 @@ public MetricsDeclarationBuilder WithContainerInstanceMetric(string metricName = string metricDescription = "Description for a metric", string containerGroup = "promitor-group", string azureMetricName = "Total", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new ContainerInstanceResourceV1 @@ -101,7 +101,7 @@ public MetricsDeclarationBuilder WithContainerInstanceMetric(string metricName = ContainerGroup = containerGroup }; - CreateAndAddMetricDefinition(ResourceType.ContainerInstance, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.ContainerInstance, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -110,7 +110,7 @@ public MetricsDeclarationBuilder WithContainerRegistryMetric(string metricName = string metricDescription = "Description for a metric", string registryName = "promitor-container-registry", string azureMetricName = "Total", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new ContainerRegistryResourceV1 @@ -118,7 +118,7 @@ public MetricsDeclarationBuilder WithContainerRegistryMetric(string metricName = RegistryName = registryName }; - CreateAndAddMetricDefinition(ResourceType.ContainerRegistry, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.ContainerRegistry, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -127,7 +127,7 @@ public MetricsDeclarationBuilder WithCosmosDbMetric(string metricName = "promito string metricDescription = "Description for a metric", string dbName = "promitor-cosmosdb", string azureMetricName = "TotalRequests", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new CosmosDbResourceV1 @@ -135,7 +135,7 @@ public MetricsDeclarationBuilder WithCosmosDbMetric(string metricName = "promito DbName = dbName }; - CreateAndAddMetricDefinition(ResourceType.CosmosDb, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.CosmosDb, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -144,7 +144,7 @@ public MetricsDeclarationBuilder WithAppPlanMetric(string metricName = "promitor string metricDescription = "Description for a metric", string appPlanName = "promitor-app-plan", string azureMetricName = "TotalRequests", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new AppPlanResourceV1 @@ -152,7 +152,7 @@ public MetricsDeclarationBuilder WithAppPlanMetric(string metricName = "promitor AppPlanName = appPlanName }; - CreateAndAddMetricDefinition(ResourceType.AppPlan, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.AppPlan, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -162,7 +162,7 @@ public MetricsDeclarationBuilder WithApiManagementMetric(string metricName = "pr string instanceName = "promitor-app-plan", string locationName = "West Europe", string azureMetricName = "TotalRequests", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new ApiManagementResourceV1 @@ -171,7 +171,7 @@ public MetricsDeclarationBuilder WithApiManagementMetric(string metricName = "pr LocationName = locationName }; - CreateAndAddMetricDefinition(ResourceType.ApiManagement, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.ApiManagement, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -180,7 +180,7 @@ public MetricsDeclarationBuilder WithFunctionAppMetric(string metricName = "prom string metricDescription = "Description for a metric", string functionAppName = "promitor-fuction-app", string azureMetricName = "TotalRequests", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new FunctionAppResourceV1 @@ -188,7 +188,7 @@ public MetricsDeclarationBuilder WithFunctionAppMetric(string metricName = "prom FunctionAppName = functionAppName }; - CreateAndAddMetricDefinition(ResourceType.FunctionApp, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.FunctionApp, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -199,7 +199,7 @@ public MetricsDeclarationBuilder WithStorageQueueMetric(string metricName = "pro string accountName = "promitor-account", string sasToken = "?sig=promitor", string azureMetricName = AzureStorageConstants.Queues.Metrics.MessageCount, - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var secret = new SecretV1 @@ -214,7 +214,7 @@ public MetricsDeclarationBuilder WithStorageQueueMetric(string metricName = "pro SasToken = secret }; - CreateAndAddMetricDefinition(ResourceType.StorageQueue, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.StorageQueue, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -223,7 +223,7 @@ public MetricsDeclarationBuilder WithStorageAccountMetric(string metricName = "p string metricDescription = "Description for a metric", string accountName = "promitor-account", string azureMetricName = "Total", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new StorageAccountResourceV1 @@ -231,7 +231,7 @@ public MetricsDeclarationBuilder WithStorageAccountMetric(string metricName = "p AccountName = accountName }; - CreateAndAddMetricDefinition(ResourceType.StorageAccount, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.StorageAccount, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -240,7 +240,7 @@ public MetricsDeclarationBuilder WithFileStorageMetric(string metricName = "prom string metricDescription = "Description for a metric", string accountName = "promitor-account", string azureMetricName = "Total", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new FileStorageResourceV1 @@ -248,7 +248,7 @@ public MetricsDeclarationBuilder WithFileStorageMetric(string metricName = "prom AccountName = accountName }; - CreateAndAddMetricDefinition(ResourceType.FileStorage, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.FileStorage, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -257,7 +257,7 @@ public MetricsDeclarationBuilder WithBlobStorageMetric(string metricName = "prom string metricDescription = "Description for a metric", string accountName = "promitor-account", string azureMetricName = "Total", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new BlobStorageResourceV1 @@ -265,7 +265,7 @@ public MetricsDeclarationBuilder WithBlobStorageMetric(string metricName = "prom AccountName = accountName }; - CreateAndAddMetricDefinition(ResourceType.BlobStorage, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.BlobStorage, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -274,7 +274,7 @@ public MetricsDeclarationBuilder WithVirtualMachineMetric(string metricName = "p string metricDescription = "Description for a metric", string virtualMachineName = "promitor-virtual-machine-name", string azureMetricName = "Total", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new VirtualMachineResourceV1 @@ -282,7 +282,7 @@ public MetricsDeclarationBuilder WithVirtualMachineMetric(string metricName = "p VirtualMachineName = virtualMachineName }; - CreateAndAddMetricDefinition(ResourceType.VirtualMachine, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.VirtualMachine, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -292,7 +292,7 @@ public MetricsDeclarationBuilder WithWebAppMetric(string metricName = "promitor- string webAppName = "promitor-web-app-name", string slotName = "production", string azureMetricName = "Total", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new WebAppResourceV1 @@ -301,7 +301,7 @@ public MetricsDeclarationBuilder WithWebAppMetric(string metricName = "promitor- SlotName = slotName }; - CreateAndAddMetricDefinition(ResourceType.WebApp, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.WebApp, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -310,7 +310,7 @@ public MetricsDeclarationBuilder WithVirtualMachineScaleSetMetric(string metricN string metricDescription = "Description for a metric", string scaleSetName = "promitor-scale-set-name", string azureMetricName = "Total", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new VirtualMachineScaleSetResourceV1() @@ -318,7 +318,7 @@ public MetricsDeclarationBuilder WithVirtualMachineScaleSetMetric(string metricN ScaleSetName = scaleSetName }; - CreateAndAddMetricDefinition(ResourceType.VirtualMachineScaleSet, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.VirtualMachineScaleSet, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -327,7 +327,7 @@ public MetricsDeclarationBuilder WithNetworkInterfaceMetric(string metricName = string metricDescription = "Description for a metric", string networkInterfaceName = "promitor-network-interface-name", string azureMetricName = "Total", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new NetworkInterfaceResourceV1 @@ -335,7 +335,7 @@ public MetricsDeclarationBuilder WithNetworkInterfaceMetric(string metricName = NetworkInterfaceName = networkInterfaceName }; - CreateAndAddMetricDefinition(ResourceType.NetworkInterface, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.NetworkInterface, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -345,7 +345,7 @@ public MetricsDeclarationBuilder WithGenericMetric(string metricName = "foo", string resourceUri = "Microsoft.ServiceBus/namespaces/promitor-messaging", string filter = "EntityName eq \'orders\'", string azureMetricName = "Total", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new GenericResourceV1 @@ -354,7 +354,7 @@ public MetricsDeclarationBuilder WithGenericMetric(string metricName = "foo", Filter = filter }; - CreateAndAddMetricDefinition(ResourceType.Generic, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.Generic, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -363,7 +363,7 @@ public MetricsDeclarationBuilder WithRedisCacheMetric(string metricName = "promi string metricDescription = "Description for a metric", string cacheName = "promitor-redis", string azureMetricName = "CacheHits", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new RedisCacheResourceV1 @@ -371,7 +371,7 @@ public MetricsDeclarationBuilder WithRedisCacheMetric(string metricName = "promi CacheName = cacheName }; - CreateAndAddMetricDefinition(ResourceType.RedisCache, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.RedisCache, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -380,7 +380,7 @@ public MetricsDeclarationBuilder WithPostgreSqlMetric(string metricName = "promi string metricDescription = "Description for a metric", string serverName = "promitor-postgresql", string azureMetricName = "cpu_percent", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new PostgreSqlResourceV1 @@ -388,7 +388,7 @@ public MetricsDeclarationBuilder WithPostgreSqlMetric(string metricName = "promi ServerName = serverName }; - CreateAndAddMetricDefinition(ResourceType.PostgreSql, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.PostgreSql, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -399,7 +399,7 @@ public MetricsDeclarationBuilder WithSqlDatabaseMetric( string serverName = "promitor-sql-server", string databaseName = "promitor-db", string metricDescription = "Metric description", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new SqlDatabaseResourceV1 @@ -408,7 +408,7 @@ public MetricsDeclarationBuilder WithSqlDatabaseMetric( DatabaseName = databaseName }; - CreateAndAddMetricDefinition(ResourceType.SqlDatabase, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.SqlDatabase, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -418,7 +418,7 @@ public MetricsDeclarationBuilder WithSqlServerMetric( string azureMetricName = "cpu_percent", string serverName = "promitor-sql-server", string metricDescription = "Metric description", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new SqlServerResourceV1 @@ -426,7 +426,7 @@ public MetricsDeclarationBuilder WithSqlServerMetric( ServerName = serverName }; - CreateAndAddMetricDefinition(ResourceType.SqlServer, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.SqlServer, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -436,7 +436,7 @@ public MetricsDeclarationBuilder WithSqlManagedInstanceMetric( string azureMetricName = "cpu_percent", string instanceName = "promitor-sql-instance", string metricDescription = "Metric description", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new SqlManagedInstanceResourceV1 @@ -444,7 +444,7 @@ public MetricsDeclarationBuilder WithSqlManagedInstanceMetric( InstanceName = instanceName }; - CreateAndAddMetricDefinition(ResourceType.SqlManagedInstance, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.SqlManagedInstance, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -453,7 +453,7 @@ public MetricsDeclarationBuilder WithIoTHubMetric(string metricName = "promitor- string metricDescription = "Description for a metric", string iotHubName = "promitor-iot-hub", string azureMetricName = "devices.totalDevices", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new IoTHubResourceV1 @@ -461,7 +461,7 @@ public MetricsDeclarationBuilder WithIoTHubMetric(string metricName = "promitor- IoTHubName = iotHubName }; - CreateAndAddMetricDefinition(ResourceType.IoTHub, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.IoTHub, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -470,7 +470,7 @@ public MetricsDeclarationBuilder WithDeviceProvisioningServiceMetric(string metr string metricDescription = "Description for a metric", string deviceProvisioningServiceName = "promitor-dps", string azureMetricName = "AttestationAttempts", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new DeviceProvisioningServiceResourceV1 @@ -478,7 +478,7 @@ public MetricsDeclarationBuilder WithDeviceProvisioningServiceMetric(string metr DeviceProvisioningServiceName = deviceProvisioningServiceName }; - CreateAndAddMetricDefinition(ResourceType.DeviceProvisioningService, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.DeviceProvisioningService, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } @@ -487,7 +487,7 @@ public MetricsDeclarationBuilder WithKeyVaultMetric(string metricName = "promito string metricDescription = "Description for a metric", string vaultName = "promitor-kv", string azureMetricName = "ServiceApiLatency", - string resourceCollectionName = "", + string resourceDiscoveryGroupName = "", bool omitResource = false) { var resource = new KeyVaultResourceV1 @@ -495,12 +495,12 @@ public MetricsDeclarationBuilder WithKeyVaultMetric(string metricName = "promito VaultName = vaultName }; - CreateAndAddMetricDefinition(ResourceType.KeyVault, metricName, metricDescription, resourceCollectionName, omitResource, azureMetricName, resource); + CreateAndAddMetricDefinition(ResourceType.KeyVault, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource); return this; } - private void CreateAndAddMetricDefinition(ResourceType resourceType, string metricName, string metricDescription, string resourceCollectionName, bool omitResource, string azureMetricName, AzureResourceDefinitionV1 resource, string metricDimension = null) + private void CreateAndAddMetricDefinition(ResourceType resourceType, string metricName, string metricDescription, string resourceDiscoveryGroupName, bool omitResource, string azureMetricName, AzureResourceDefinitionV1 resource, string metricDimension = null) { var azureMetricConfiguration = CreateAzureMetricConfiguration(azureMetricName, metricDimension); var metric = new MetricDefinitionV1 @@ -516,12 +516,12 @@ private void CreateAndAddMetricDefinition(ResourceType resourceType, string metr metric.Resources = new List { resource }; } - if (string.IsNullOrWhiteSpace(resourceCollectionName) == false) + if (string.IsNullOrWhiteSpace(resourceDiscoveryGroupName) == false) { - var resourceCollection = new AzureResourceCollectionDefinitionV1 { Name = resourceCollectionName }; - metric.ResourceCollections = new List + var resourceDiscoveryGroup = new AzureResourceDiscoveryGroupDefinitionV1 { Name = resourceDiscoveryGroupName }; + metric.ResourceDiscoveryGroups = new List { - resourceCollection + resourceDiscoveryGroup }; } diff --git a/src/Promitor.Tests.Unit/Serialization/v1/Core/AzureResourceCollectionDeserializerTests.cs b/src/Promitor.Tests.Unit/Serialization/v1/Core/AzureResourceCollectionDeserializerTests.cs index 69f892e62..f08ad76cf 100644 --- a/src/Promitor.Tests.Unit/Serialization/v1/Core/AzureResourceCollectionDeserializerTests.cs +++ b/src/Promitor.Tests.Unit/Serialization/v1/Core/AzureResourceCollectionDeserializerTests.cs @@ -6,13 +6,13 @@ namespace Promitor.Tests.Unit.Serialization.v1.Core { [Category("Unit")] - public class AzureResourceCollectionDeserializerTests + public class AzureResourceDiscoveryGroupDeserializerTests { - private readonly AzureResourceCollectionDeserializer _deserializer; + private readonly AzureResourceDiscoveryGroupDeserializer _deserializer; - public AzureResourceCollectionDeserializerTests() + public AzureResourceDiscoveryGroupDeserializerTests() { - _deserializer = new AzureResourceCollectionDeserializer(NullLogger.Instance); + _deserializer = new AzureResourceDiscoveryGroupDeserializer(NullLogger.Instance); } [Fact] diff --git a/src/Promitor.Tests.Unit/Serialization/v1/Core/MetricDefinitionDeserializerTests.cs b/src/Promitor.Tests.Unit/Serialization/v1/Core/MetricDefinitionDeserializerTests.cs index 37132fbba..d9f1b82c1 100644 --- a/src/Promitor.Tests.Unit/Serialization/v1/Core/MetricDefinitionDeserializerTests.cs +++ b/src/Promitor.Tests.Unit/Serialization/v1/Core/MetricDefinitionDeserializerTests.cs @@ -18,8 +18,8 @@ public class MetricDefinitionDeserializerTests private readonly Mock> _scrapingDeserializer; private readonly Mock _resourceDeserializerFactory; private readonly Mock _errorReporter = new Mock(); - private readonly Mock> _resourceCollectionsDeserializer = - new Mock>(); + private readonly Mock> _resourceDiscoveryGroupDeserializer = + new Mock>(); private readonly MetricDefinitionDeserializer _deserializer; @@ -32,7 +32,7 @@ public MetricDefinitionDeserializerTests() _deserializer = new MetricDefinitionDeserializer( _azureMetricConfigurationDeserializer.Object, _scrapingDeserializer.Object, - _resourceCollectionsDeserializer.Object, + _resourceDiscoveryGroupDeserializer.Object, _resourceDeserializerFactory.Object, NullLogger.Instance); } @@ -342,7 +342,7 @@ public void Deserialize_ResourcesNotSupplied_Null() } [Fact] - public void Deserialize_ResourceCollectionsSupplied_DoesNotReportWarning() + public void Deserialize_ResourceDiscoveryGroupsSupplied_DoesNotReportWarning() { // Because we're handling deserializing the resources manually, we // need to explicitly ignore the field to stop a warning being reported @@ -351,7 +351,7 @@ public void Deserialize_ResourceCollectionsSupplied_DoesNotReportWarning() // Arrange const string yamlText = @"resourceType: Generic -resourceCollections: +resourceDiscoveryGroups: - name: sample-1 - name: sample-2"; var node = YamlUtils.CreateYamlNode(yamlText); @@ -361,11 +361,11 @@ public void Deserialize_ResourceCollectionsSupplied_DoesNotReportWarning() // Assert _errorReporter.Verify( - r => r.ReportWarning(It.IsAny(), It.Is(s => s.Contains("resourceCollections"))), Times.Never); + r => r.ReportWarning(It.IsAny(), It.Is(s => s.Contains("resourceDiscoveryGroups"))), Times.Never); } [Fact] - public void Deserialize_ResourceCollectionsNotSupplied_Null() + public void Deserialize_ResourceDiscoveryGroupsNotSupplied_Null() { // Arrange var node = YamlUtils.CreateYamlNode("resourceType: Generic"); @@ -374,7 +374,7 @@ public void Deserialize_ResourceCollectionsNotSupplied_Null() var definition = _deserializer.Deserialize(node, _errorReporter.Object); // Assert - Assert.Null(definition.ResourceCollections); + Assert.Null(definition.ResourceDiscoveryGroups); } [Fact] @@ -413,7 +413,7 @@ public void Deserialize_ResourcesAndCollectionNotSupplied_ReportsError() // Assert _errorReporter.Verify( - reporter => reporter.ReportError(node, "Either 'resources' or 'resourceCollections' must be specified.")); + reporter => reporter.ReportError(node, "Either 'resources' or 'resourceDiscoveryGroups' must be specified.")); } [Fact] @@ -434,7 +434,7 @@ public void Deserialize_ResourcesSupplied_DoesNotReportError() // Assert _errorReporter.Verify( - reporter => reporter.ReportError(node, "Either 'resources' or 'resourceCollections' must be specified."), Times.Never); + reporter => reporter.ReportError(node, "Either 'resources' or 'resourceDiscoveryGroups' must be specified."), Times.Never); } [Fact] @@ -453,50 +453,50 @@ public void Deserialize_ResourcesEmpty_ReportsError() // Assert _errorReporter.Verify( - reporter => reporter.ReportError(node, "Either 'resources' or 'resourceCollections' must be specified.")); + reporter => reporter.ReportError(node, "Either 'resources' or 'resourceDiscoveryGroups' must be specified.")); } [Fact] - public void Deserialize_ResourceCollectionsSupplied_DoesNotReportError() + public void Deserialize_ResourceDiscoveryGroupsSupplied_DoesNotReportError() { // Arrange const string yamlText = @"resourceType: Generic -resourceCollections: +resourceDiscoveryGroups: - name: orders"; var node = YamlUtils.CreateYamlNode(yamlText); - var resourceCollections = new List + var resourceDiscoveryGroups = new List { - new AzureResourceCollectionDefinitionV1() + new AzureResourceDiscoveryGroupDefinitionV1() }; - _resourceCollectionsDeserializer.Setup( - d => d.Deserialize(It.IsAny(), It.IsAny())).Returns(resourceCollections); + _resourceDiscoveryGroupDeserializer.Setup( + d => d.Deserialize(It.IsAny(), It.IsAny())).Returns(resourceDiscoveryGroups); // Act _deserializer.Deserialize(node, _errorReporter.Object); // Assert _errorReporter.Verify( - reporter => reporter.ReportError(node, "Either 'resources' or 'resourceCollections' must be specified."), Times.Never); + reporter => reporter.ReportError(node, "Either 'resources' or 'resourceDiscoveryGroups' must be specified."), Times.Never); } [Fact] - public void Deserialize_ResourceCollectionsEmpty_ReportsError() + public void Deserialize_ResourceDiscoveryGroupsEmpty_ReportsError() { // Arrange const string yamlText = @"resourceType: Generic -resourceCollections: []"; +resourceDiscoveryGroups: []"; var node = YamlUtils.CreateYamlNode(yamlText); - _resourceCollectionsDeserializer.Setup( - d => d.Deserialize(It.IsAny(), It.IsAny())).Returns(new List()); + _resourceDiscoveryGroupDeserializer.Setup( + d => d.Deserialize(It.IsAny(), It.IsAny())).Returns(new List()); // Act _deserializer.Deserialize(node, _errorReporter.Object); // Assert _errorReporter.Verify( - reporter => reporter.ReportError(node, "Either 'resources' or 'resourceCollections' must be specified.")); + reporter => reporter.ReportError(node, "Either 'resources' or 'resourceDiscoveryGroups' must be specified.")); } private void SetupResourceDeserializer(YamlMappingNode node, IReadOnlyCollection resources) diff --git a/src/Promitor.Tests.Unit/Serialization/v1/V1DeserializerFactory.cs b/src/Promitor.Tests.Unit/Serialization/v1/V1DeserializerFactory.cs index 4e064d4bf..375f3d19c 100644 --- a/src/Promitor.Tests.Unit/Serialization/v1/V1DeserializerFactory.cs +++ b/src/Promitor.Tests.Unit/Serialization/v1/V1DeserializerFactory.cs @@ -23,7 +23,7 @@ public static V1Deserializer CreateDeserializer() new MetricAggregationDeserializer(NullLogger.Instance), NullLogger.Instance), new ScrapingDeserializer(NullLogger.Instance), - new AzureResourceCollectionDeserializer(NullLogger.Instance), + new AzureResourceDiscoveryGroupDeserializer(NullLogger.Instance), new AzureResourceDeserializerFactory(new SecretDeserializer(NullLogger.Instance), new LoggerFactory()), NullLogger.Instance), NullLogger.Instance); diff --git a/src/Promitor.Tests.Unit/Serialization/v1/V1SerializationTests.cs b/src/Promitor.Tests.Unit/Serialization/v1/V1SerializationTests.cs index 636bb45af..c11b46919 100644 --- a/src/Promitor.Tests.Unit/Serialization/v1/V1SerializationTests.cs +++ b/src/Promitor.Tests.Unit/Serialization/v1/V1SerializationTests.cs @@ -116,9 +116,9 @@ public V1SerializationTests() ResourceGroupName = "promitor-demo-group" } }, - ResourceCollections = new List + ResourceDiscoveryGroups = new List { - new AzureResourceCollectionDefinitionV1 + new AzureResourceDiscoveryGroupDefinitionV1 { Name="example-resource-collection" } @@ -178,10 +178,10 @@ public void Deserialize_SerializedModel_CanDeserialize() Assert.Equal("promitor-messaging", serviceBusQueueResource.Namespace); Assert.Equal("orders", serviceBusQueueResource.QueueName); Assert.Equal("promitor-demo-group", serviceBusQueueResource.ResourceGroupName); - Assert.NotNull(deserializedModel.Metrics.ElementAt(1).ResourceCollections); - Assert.Single(deserializedModel.Metrics.ElementAt(1).ResourceCollections); - var resourceCollection =deserializedModel.Metrics.ElementAt(1).ResourceCollections.ElementAt(0); - Assert.Equal("example-resource-collection", resourceCollection.Name); + Assert.NotNull(deserializedModel.Metrics.ElementAt(1).ResourceDiscoveryGroups); + Assert.Single(deserializedModel.Metrics.ElementAt(1).ResourceDiscoveryGroups); + var resourceDiscoveryGroup =deserializedModel.Metrics.ElementAt(1).ResourceDiscoveryGroups.ElementAt(0); + Assert.Equal("example-resource-collection", resourceDiscoveryGroup.Name); } [Fact] @@ -226,10 +226,10 @@ public void Deserialize_SerializedYaml_CanDeserializeToRuntimeModel() Assert.Equal("orders", definition.QueueName); Assert.Equal("promitor-demo-group", definition.ResourceGroupName); }); - Assert.NotNull(secondMetric.ResourceCollections); - Assert.Single(secondMetric.ResourceCollections); - var resourceCollection = secondMetric.ResourceCollections.First(); - Assert.Equal("example-resource-collection", resourceCollection.Name); + Assert.NotNull(secondMetric.ResourceDiscoveryGroups); + Assert.Single(secondMetric.ResourceDiscoveryGroups); + var resourceDiscoveryGroup = secondMetric.ResourceDiscoveryGroups.First(); + Assert.Equal("example-resource-collection", resourceDiscoveryGroup.Name); } } } diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ApiManagementMetricsDeclarationValidationStepsTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ApiManagementMetricsDeclarationValidationStepsTests.cs index 1508abbce..e8a37587d 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ApiManagementMetricsDeclarationValidationStepsTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ApiManagementMetricsDeclarationValidationStepsTests.cs @@ -94,7 +94,7 @@ public void ApiManagementMetricsDeclaration_DeclarationWithoutInstanceName_Fails } [Fact] - public void ApiManagementMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void ApiManagementMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -111,11 +111,11 @@ public void ApiManagementMetricsDeclaration_DeclarationWithoutResourceAndResourc } [Fact] - public void ApiManagementMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void ApiManagementMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithApiManagementMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithApiManagementMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/AppPlanMetricsDeclarationValidationStepsTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/AppPlanMetricsDeclarationValidationStepsTests.cs index 7ac02ce3d..0a370b001 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/AppPlanMetricsDeclarationValidationStepsTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/AppPlanMetricsDeclarationValidationStepsTests.cs @@ -78,7 +78,7 @@ public void AppPlanMetricsDeclaration_DeclarationWithoutAppPlanName_Fails() } [Fact] - public void AppPlanMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void AppPlanMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -95,11 +95,11 @@ public void AppPlanMetricsDeclaration_DeclarationWithoutResourceAndResourceColle } [Fact] - public void AppPlanMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void AppPlanMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithAppPlanMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithAppPlanMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/BlobStorageMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/BlobStorageMetricsDeclarationValidationStepTests.cs index 6837773cb..ef6f16f05 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/BlobStorageMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/BlobStorageMetricsDeclarationValidationStepTests.cs @@ -131,7 +131,7 @@ public void BlobStorageMetricsDeclaration_ValidDeclarationWithTimeSpentInQueue_S } [Fact] - public void BlobStorageMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void BlobStorageMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -148,11 +148,11 @@ public void BlobStorageMetricsDeclaration_DeclarationWithoutResourceAndResourceC } [Fact] - public void BlobStorageMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void BlobStorageMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithBlobStorageMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithBlobStorageMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ContainerInstanceMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ContainerInstanceMetricsDeclarationValidationStepTests.cs index 328dd67a3..9624f5881 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ContainerInstanceMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ContainerInstanceMetricsDeclarationValidationStepTests.cs @@ -78,7 +78,7 @@ public void ContainerInstanceMetricsDeclaration_DeclarationWithoutContainerGroup } [Fact] - public void ContainerInstanceMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void ContainerInstanceMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -95,11 +95,11 @@ public void ContainerInstanceMetricsDeclaration_DeclarationWithoutResourceAndRes } [Fact] - public void ContainerInstanceMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void ContainerInstanceMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithContainerInstanceMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithContainerInstanceMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ContainerRegistryMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ContainerRegistryMetricsDeclarationValidationStepTests.cs index 99e00a70f..5258cc83f 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ContainerRegistryMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ContainerRegistryMetricsDeclarationValidationStepTests.cs @@ -80,7 +80,7 @@ public void ContainerRegistryMetricsDeclaration_DeclarationWithoutRegistryName_F } [Fact] - public void ContainerRegistryMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void ContainerRegistryMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -97,11 +97,11 @@ public void ContainerRegistryMetricsDeclaration_DeclarationWithoutResourceAndRes } [Fact] - public void ContainerRegistryMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void ContainerRegistryMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithContainerRegistryMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithContainerRegistryMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/CosmosDbMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/CosmosDbMetricsDeclarationValidationStepTests.cs index 034489308..80ea23643 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/CosmosDbMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/CosmosDbMetricsDeclarationValidationStepTests.cs @@ -78,7 +78,7 @@ public void CosmosDbMetricsDeclaration_DeclarationWithoutDbName_Fails() } [Fact] - public void CosmosDbMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void CosmosDbMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -95,11 +95,11 @@ public void CosmosDbMetricsDeclaration_DeclarationWithoutResourceAndResourceColl } [Fact] - public void CosmosDbMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void CosmosDbMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithCosmosDbMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithCosmosDbMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/DeviceProvisioningServiceMetricsDeclarationValidationStepsTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/DeviceProvisioningServiceMetricsDeclarationValidationStepsTests.cs index b1ed8f1ee..8b1b55e2d 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/DeviceProvisioningServiceMetricsDeclarationValidationStepsTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/DeviceProvisioningServiceMetricsDeclarationValidationStepsTests.cs @@ -78,7 +78,7 @@ public void DeviceProvisioningServiceMetricsDeclaration_DeclarationWithoutDevice } [Fact] - public void DeviceProvisioningServiceMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void DeviceProvisioningServiceMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -95,11 +95,11 @@ public void DeviceProvisioningServiceMetricsDeclaration_DeclarationWithoutResour } [Fact] - public void DeviceProvisioningServiceMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void DeviceProvisioningServiceMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithDeviceProvisioningServiceMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithDeviceProvisioningServiceMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/FileStorageMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/FileStorageMetricsDeclarationValidationStepTests.cs index 8e702e9af..2125d1cee 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/FileStorageMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/FileStorageMetricsDeclarationValidationStepTests.cs @@ -114,7 +114,7 @@ public void FileStorageMetricsDeclaration_ValidDeclarationWithMessageCount_Succe } [Fact] - public void FileStorageMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void FileStorageMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -131,11 +131,11 @@ public void FileStorageMetricsDeclaration_DeclarationWithoutResourceAndResourceC } [Fact] - public void FileStorageMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void FileStorageMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithFileStorageMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithFileStorageMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/FunctionAppMetricsDeclarationValidationStepsTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/FunctionAppMetricsDeclarationValidationStepsTests.cs index d258f5c73..fe1812662 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/FunctionAppMetricsDeclarationValidationStepsTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/FunctionAppMetricsDeclarationValidationStepsTests.cs @@ -78,7 +78,7 @@ public void FunctionAppMetricsDeclaration_DeclarationWithoutFunctionAppName_Fail } [Fact] - public void FunctionAppMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void FunctionAppMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -95,11 +95,11 @@ public void FunctionAppMetricsDeclaration_DeclarationWithoutResourceAndResourceC } [Fact] - public void FunctionAppMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void FunctionAppMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithFunctionAppMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithFunctionAppMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/GenericMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/GenericMetricsDeclarationValidationStepTests.cs index d86ad87a4..101518082 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/GenericMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/GenericMetricsDeclarationValidationStepTests.cs @@ -112,7 +112,7 @@ public void GenericMetricsDeclaration_DeclarationWithoutResourceUri_Fails() } [Fact] - public void GenericMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void GenericMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -129,11 +129,11 @@ public void GenericMetricsDeclaration_DeclarationWithoutResourceAndResourceColle } [Fact] - public void GenericMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void GenericMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithGenericMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithGenericMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/IoTHubMetricsDeclarationValidationStepsTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/IoTHubMetricsDeclarationValidationStepsTests.cs index 32495fb39..49f9efd20 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/IoTHubMetricsDeclarationValidationStepsTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/IoTHubMetricsDeclarationValidationStepsTests.cs @@ -78,7 +78,7 @@ public void IoTHubMetricsDeclaration_DeclarationWithoutIoTHubName_Fails() } [Fact] - public void IoTHubMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void IoTHubMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -95,11 +95,11 @@ public void IoTHubMetricsDeclaration_DeclarationWithoutResourceAndResourceCollec } [Fact] - public void IoTHubMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void IoTHubMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithIoTHubMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithIoTHubMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/KeyVaultMetricsDeclarationValidationStepsTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/KeyVaultMetricsDeclarationValidationStepsTests.cs index a06fc17dd..420108490 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/KeyVaultMetricsDeclarationValidationStepsTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/KeyVaultMetricsDeclarationValidationStepsTests.cs @@ -78,7 +78,7 @@ public void KeyVaultMetricsDeclaration_DeclarationWithoutVaultName_Fails() } [Fact] - public void KeyVaultMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void KeyVaultMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -95,11 +95,11 @@ public void KeyVaultMetricsDeclaration_DeclarationWithoutResourceAndResourceColl } [Fact] - public void KeyVaultMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void KeyVaultMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithKeyVaultMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithKeyVaultMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/NetworkInterfaceMetricsDeclarationValidationStepsTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/NetworkInterfaceMetricsDeclarationValidationStepsTests.cs index fdb2ffb6c..2336a3665 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/NetworkInterfaceMetricsDeclarationValidationStepsTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/NetworkInterfaceMetricsDeclarationValidationStepsTests.cs @@ -78,7 +78,7 @@ public void NetworkInterfaceMetricsDeclaration_DeclarationWithoutNetworkInterfac } [Fact] - public void NetworkInterfaceMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void NetworkInterfaceMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -95,11 +95,11 @@ public void NetworkInterfaceMetricsDeclaration_DeclarationWithoutResourceAndReso } [Fact] - public void NetworkInterfaceMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void NetworkInterfaceMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithNetworkInterfaceMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithNetworkInterfaceMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/PostgreSqlMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/PostgreSqlMetricsDeclarationValidationStepTests.cs index 2196c10be..06facf553 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/PostgreSqlMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/PostgreSqlMetricsDeclarationValidationStepTests.cs @@ -61,7 +61,7 @@ public void PostgreSqlMetricsDeclaration_DeclarationWithoutServerName_Fails() } [Fact] - public void PostgreSqlMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void PostgreSqlMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -78,11 +78,11 @@ public void PostgreSqlMetricsDeclaration_DeclarationWithoutResourceAndResourceCo } [Fact] - public void PostgreSqlMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void PostgreSqlMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithPostgreSqlMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithPostgreSqlMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/RedisCacheMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/RedisCacheMetricsDeclarationValidationStepTests.cs index 3e6893438..18bfbb1c2 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/RedisCacheMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/RedisCacheMetricsDeclarationValidationStepTests.cs @@ -61,7 +61,7 @@ public void RedisCacheMetricsDeclaration_DeclarationWithoutCacheName_Fails() } [Fact] - public void RedisCacheMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void RedisCacheMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -78,11 +78,11 @@ public void RedisCacheMetricsDeclaration_DeclarationWithoutResourceAndResourceCo } [Fact] - public void RedisCacheMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void RedisCacheMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithRedisCacheMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithRedisCacheMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ServiceBusQueueMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ServiceBusQueueMetricsDeclarationValidationStepTests.cs index 99d075541..3b88bdbea 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ServiceBusQueueMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/ServiceBusQueueMetricsDeclarationValidationStepTests.cs @@ -61,7 +61,7 @@ public void ServiceBusQueuesMetricsDeclaration_UseAllowedDimension_Succeeded() } [Fact] - public void ServiceBusQueuesMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void ServiceBusQueuesMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -78,11 +78,11 @@ public void ServiceBusQueuesMetricsDeclaration_DeclarationWithoutResourceAndReso } [Fact] - public void ServiceBusQueuesMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void ServiceBusQueuesMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithServiceBusMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithServiceBusMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/SqlDatabaseMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/SqlDatabaseMetricsDeclarationValidationStepTests.cs index 4df565322..a34b0a681 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/SqlDatabaseMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/SqlDatabaseMetricsDeclarationValidationStepTests.cs @@ -78,7 +78,7 @@ public void SqlDatabaseMetricsDeclaration_DeclarationWithoutDatabaseName_Fails() } [Fact] - public void SqlDatabaseMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void SqlDatabaseMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -95,11 +95,11 @@ public void SqlDatabaseMetricsDeclaration_DeclarationWithoutResourceAndResourceC } [Fact] - public void SqlDatabaseMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void SqlDatabaseMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithSqlDatabaseMetric(omitResource:true, resourceCollectionName: "sample-collection") + .WithSqlDatabaseMetric(omitResource:true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/SqlManagedInstanceMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/SqlManagedInstanceMetricsDeclarationValidationStepTests.cs index e6197a4d6..34a02e336 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/SqlManagedInstanceMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/SqlManagedInstanceMetricsDeclarationValidationStepTests.cs @@ -61,7 +61,7 @@ public void SqlManagedInstanceMetricsDeclaration_DeclarationWithoutInstanceName_ } [Fact] - public void SqlManagedInstanceMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void SqlManagedInstanceMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -78,11 +78,11 @@ public void SqlManagedInstanceMetricsDeclaration_DeclarationWithoutResourceAndRe } [Fact] - public void SqlManagedInstanceMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void SqlManagedInstanceMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithSqlManagedInstanceMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithSqlManagedInstanceMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/SqlServerMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/SqlServerMetricsDeclarationValidationStepTests.cs index 8e169b180..283c147bb 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/SqlServerMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/SqlServerMetricsDeclarationValidationStepTests.cs @@ -61,7 +61,7 @@ public void SqlServerMetricsDeclaration_DeclarationWithoutServerName_Fails() } [Fact] - public void SqlServerMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void SqlServerMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -78,11 +78,11 @@ public void SqlServerMetricsDeclaration_DeclarationWithoutResourceAndResourceCol } [Fact] - public void SqlServerMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void SqlServerMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithSqlServerMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithSqlServerMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/StorageAccountMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/StorageAccountMetricsDeclarationValidationStepTests.cs index 81783cc40..58b7f413b 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/StorageAccountMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/StorageAccountMetricsDeclarationValidationStepTests.cs @@ -131,7 +131,7 @@ public void StorageAccountMetricsDeclaration_ValidDeclarationWithTimeSpentInQueu } [Fact] - public void StorageAccountMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void StorageAccountMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -148,11 +148,11 @@ public void StorageAccountMetricsDeclaration_DeclarationWithoutResourceAndResour } [Fact] - public void StorageAccountMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void StorageAccountMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithStorageAccountMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithStorageAccountMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/StorageQueueMetricsDeclarationValidationStepTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/StorageQueueMetricsDeclarationValidationStepTests.cs index 37ae5493a..0ddc362e0 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/StorageQueueMetricsDeclarationValidationStepTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/StorageQueueMetricsDeclarationValidationStepTests.cs @@ -184,7 +184,7 @@ public void StorageQueuesMetricsDeclaration_ValidDeclarationWithTimeSpentInQueue } [Fact] - public void StorageQueuesMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void StorageQueuesMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -201,11 +201,11 @@ public void StorageQueuesMetricsDeclaration_DeclarationWithoutResourceAndResourc } [Fact] - public void StorageQueuesMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void StorageQueuesMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithStorageQueueMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithStorageQueueMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/VirtualMachineMetricsDeclarationValidationStepsTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/VirtualMachineMetricsDeclarationValidationStepsTests.cs index b4aa84a00..0b05643e1 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/VirtualMachineMetricsDeclarationValidationStepsTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/VirtualMachineMetricsDeclarationValidationStepsTests.cs @@ -78,7 +78,7 @@ public void VirtualMachineMetricsDeclaration_DeclarationWithoutVirtualMachineNam } [Fact] - public void VirtualMachineMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void VirtualMachineMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -95,11 +95,11 @@ public void VirtualMachineMetricsDeclaration_DeclarationWithoutResourceAndResour } [Fact] - public void VirtualMachineMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void VirtualMachineMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithVirtualMachineMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithVirtualMachineMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/VirtualMachineScaleSetMetricsDeclarationValidationStepsTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/VirtualMachineScaleSetMetricsDeclarationValidationStepsTests.cs index 0d2bcd6c4..d754b631c 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/VirtualMachineScaleSetMetricsDeclarationValidationStepsTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/VirtualMachineScaleSetMetricsDeclarationValidationStepsTests.cs @@ -78,7 +78,7 @@ public void VirtualMachineScaleSetMetricsDeclaration_DeclarationWithoutVirtualMa } [Fact] - public void VirtualMachineScaleSetMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void VirtualMachineScaleSetMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -95,11 +95,11 @@ public void VirtualMachineScaleSetMetricsDeclaration_DeclarationWithoutResourceA } [Fact] - public void VirtualMachineScaleSetMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void VirtualMachineScaleSetMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithVirtualMachineScaleSetMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithVirtualMachineScaleSetMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); diff --git a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/WebAppMetricsDeclarationValidationStepsTests.cs b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/WebAppMetricsDeclarationValidationStepsTests.cs index b43838e76..2f76a63a3 100644 --- a/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/WebAppMetricsDeclarationValidationStepsTests.cs +++ b/src/Promitor.Tests.Unit/Validation/Metrics/ResourceTypes/WebAppMetricsDeclarationValidationStepsTests.cs @@ -95,7 +95,7 @@ public void WebAppMetricsDeclaration_DeclarationWithoutSlotName_Succeeds() } [Fact] - public void WebAppMetricsDeclaration_DeclarationWithoutResourceAndResourceCollectionInfo_Fails() + public void WebAppMetricsDeclaration_DeclarationWithoutResourceAndResourceDiscoveryGroupInfo_Fails() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() @@ -112,11 +112,11 @@ public void WebAppMetricsDeclaration_DeclarationWithoutResourceAndResourceCollec } [Fact] - public void WebAppMetricsDeclaration_DeclarationWithoutResourceButWithResourceCollectionInfo_Succeeds() + public void WebAppMetricsDeclaration_DeclarationWithoutResourceButWithResourceDiscoveryGroupInfo_Succeeds() { // Arrange var rawMetricsDeclaration = MetricsDeclarationBuilder.WithMetadata() - .WithWebAppMetric(omitResource: true, resourceCollectionName: "sample-collection") + .WithWebAppMetric(omitResource: true, resourceDiscoveryGroupName:"sample-collection") .Build(Mapper); var metricsDeclarationProvider = new MetricsDeclarationProviderStub(rawMetricsDeclaration, Mapper); From 5123c26bf15cc1272b50c94ef8b18251ec53bbdb Mon Sep 17 00:00:00 2001 From: Tom Kerkhove Date: Thu, 2 Jul 2020 22:43:25 +0200 Subject: [PATCH 2/2] Working refactoring Signed-off-by: Tom Kerkhove --- .../Controllers/DiscoveryController.cs | 2 +- .../Discovery/ResourceDiscoveryClient.cs | 2 +- .../Scheduling/ResourceDiscoveryGroupScrapingJob.cs | 2 +- src/Promitor.Tests.Integration/ResourceDiscoveryClient.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Promitor.Agents.ResourceDiscovery/Controllers/DiscoveryController.cs b/src/Promitor.Agents.ResourceDiscovery/Controllers/DiscoveryController.cs index 0676e11e6..7767d18ce 100644 --- a/src/Promitor.Agents.ResourceDiscovery/Controllers/DiscoveryController.cs +++ b/src/Promitor.Agents.ResourceDiscovery/Controllers/DiscoveryController.cs @@ -40,7 +40,7 @@ public DiscoveryController(ResourceRepository resourceRepository) /// Discover Resources /// /// Discovers Azure resources matching the criteria. - [HttpGet("{resourceDiscoveryGroup}/discovery", Name = "Discovery_Get")] + [HttpGet("{resourceDiscoveryGroup}/discover", Name = "Discovery_Get")] public async Task Get(string resourceDiscoveryGroup) { try diff --git a/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryClient.cs b/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryClient.cs index 77b28c59b..c6aeb8c9a 100644 --- a/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryClient.cs +++ b/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryClient.cs @@ -36,7 +36,7 @@ public ResourceDiscoveryClient(IHttpClientFactory httpClientFactory, IOptionsMon public async Task> GetAsync(string resourceDiscoveryGroupName) { - var uri = $"/api/v1/resources/collections/{resourceDiscoveryGroupName}/discovery"; + var uri = $"/api/v1/resources/groups/{resourceDiscoveryGroupName}/discover"; var rawResponse = await SendGetRequestAsync(uri); var foundResources = JsonConvert.DeserializeObject>(rawResponse, _serializerSettings); diff --git a/src/Promitor.Agents.Scraper/Scheduling/ResourceDiscoveryGroupScrapingJob.cs b/src/Promitor.Agents.Scraper/Scheduling/ResourceDiscoveryGroupScrapingJob.cs index 411535a26..29bd0aae5 100644 --- a/src/Promitor.Agents.Scraper/Scheduling/ResourceDiscoveryGroupScrapingJob.cs +++ b/src/Promitor.Agents.Scraper/Scheduling/ResourceDiscoveryGroupScrapingJob.cs @@ -57,7 +57,7 @@ public ResourceDiscoveryGroupScrapingJob(string jobName, string resourceDiscover Guard.NotNull(loggerFactory, nameof(loggerFactory)); Guard.NotNull(metricSinkWriter, nameof(metricSinkWriter)); - resourceDiscoveryGroupName = resourceDiscoveryGroupName; + ResourceDiscoveryGroupName = resourceDiscoveryGroupName; _azureMetadata = azureMetadata; _metricDefinition = metricDefinition; diff --git a/src/Promitor.Tests.Integration/ResourceDiscoveryClient.cs b/src/Promitor.Tests.Integration/ResourceDiscoveryClient.cs index 1a22cfc25..4a09566c6 100644 --- a/src/Promitor.Tests.Integration/ResourceDiscoveryClient.cs +++ b/src/Promitor.Tests.Integration/ResourceDiscoveryClient.cs @@ -40,7 +40,7 @@ public async Task GetHealthAsync() public async Task GetDiscoveredResourcesAsync(string resourceDiscoveryGroupName) { - return await GetAsync($"/api/v1/resources/groups/{resourceDiscoveryGroupName}/discovery"); + return await GetAsync($"/api/v1/resources/groups/{resourceDiscoveryGroupName}/discover"); } private async Task GetAsync(string uri)