protected override async Task <ScrapeResult> ScrapeResourceAsync(string subscriptionId, string resourceGroupName, StorageQueueMetricDefinition metricDefinition, AggregationType aggregationType, TimeSpan aggregationInterval) { Guard.NotNull(metricDefinition, nameof(metricDefinition)); Guard.NotNull(metricDefinition.AzureMetricConfiguration, nameof(metricDefinition.AzureMetricConfiguration)); Guard.NotNull(metricDefinition.SasToken, nameof(metricDefinition.SasToken)); Guard.NotNullOrEmpty(metricDefinition.AzureMetricConfiguration.MetricName, nameof(metricDefinition.AzureMetricConfiguration.MetricName)); var resourceUri = string.Format(ResourceUriTemplate, subscriptionId, resourceGroupName, metricDefinition.AccountName); var sasToken = metricDefinition.SasToken.GetSecretValue(); double foundMetricValue; switch (metricDefinition.AzureMetricConfiguration.MetricName.ToLowerInvariant()) { case AzureStorageConstants.Queues.Metrics.TimeSpentInQueue: foundMetricValue = await _azureStorageQueueClient.GetQueueMessageTimeSpentInQueueAsync(metricDefinition.AccountName, metricDefinition.QueueName, sasToken); break; case AzureStorageConstants.Queues.Metrics.MessageCount: foundMetricValue = await _azureStorageQueueClient.GetQueueMessageCountAsync(metricDefinition.AccountName, metricDefinition.QueueName, sasToken); break; default: throw new InvalidMetricNameException(metricDefinition.AzureMetricConfiguration.MetricName, metricDefinition.ResourceType.ToString()); } return(new ScrapeResult(resourceUri, foundMetricValue)); }
protected override async Task <ScrapeResult> ScrapeResourceAsync(string subscriptionId, ScrapeDefinition <AzureResourceDefinition> scrapeDefinition, StorageQueueResourceDefinition resource, AggregationType aggregationType, TimeSpan aggregationInterval) { Guard.NotNull(scrapeDefinition, nameof(scrapeDefinition)); Guard.NotNull(scrapeDefinition.AzureMetricConfiguration, nameof(scrapeDefinition.AzureMetricConfiguration)); Guard.NotNull(resource.SasToken, nameof(resource.SasToken)); Guard.NotNullOrEmpty(scrapeDefinition.AzureMetricConfiguration.MetricName, nameof(scrapeDefinition.AzureMetricConfiguration.MetricName)); var resourceUri = string.Format(ResourceUriTemplate, subscriptionId, scrapeDefinition.ResourceGroupName, resource.AccountName); var sasToken = resource.SasToken.GetSecretValue(); double foundMetricValue; switch (scrapeDefinition.AzureMetricConfiguration.MetricName.ToLowerInvariant()) { case AzureStorageConstants.Queues.Metrics.TimeSpentInQueue: foundMetricValue = await _azureStorageQueueClient.GetQueueMessageTimeSpentInQueueAsync(resource.AccountName, resource.QueueName, sasToken); break; case AzureStorageConstants.Queues.Metrics.MessageCount: foundMetricValue = await _azureStorageQueueClient.GetQueueMessageCountAsync(resource.AccountName, resource.QueueName, sasToken); break; default: throw new InvalidMetricNameException(scrapeDefinition.AzureMetricConfiguration.MetricName, resource.ResourceType.ToString()); } var labels = new Dictionary <string, string> { { "queue_name", resource.QueueName } }; return(new ScrapeResult(subscriptionId, scrapeDefinition.ResourceGroupName, resource.AccountName, resourceUri, foundMetricValue, labels)); }
protected override async Task <double> ScrapeResourceAsync(StorageQueueMetricDefinition metricDefinition, AggregationType aggregationType, TimeSpan aggregationInterval) { Guard.NotNull(metricDefinition, nameof(metricDefinition)); Guard.NotNull(metricDefinition.AzureMetricConfiguration, nameof(metricDefinition.AzureMetricConfiguration)); Guard.NotNullOrEmpty(metricDefinition.AzureMetricConfiguration.MetricName, nameof(metricDefinition.AzureMetricConfiguration.MetricName)); switch (metricDefinition.AzureMetricConfiguration.MetricName.ToLowerInvariant()) { case AzureStorageConstants.Queues.Metrics.TimeSpentInQueue: return(await _azureStorageQueueClient.GetQueueMessageTimeSpentInQueueAsync(metricDefinition.AccountName, metricDefinition.QueueName, metricDefinition.SasToken)); case AzureStorageConstants.Queues.Metrics.MessageCount: return(await _azureStorageQueueClient.GetQueueMessageCountAsync(metricDefinition.AccountName, metricDefinition.QueueName, metricDefinition.SasToken)); default: throw new InvalidMetricNameException(metricDefinition.AzureMetricConfiguration.MetricName, metricDefinition.ResourceType.ToString()); } }