Example #1
0
        public async Task GetDimensionValuesWithOptionalDimensionFilter()
        {
            const string dimensionName = "city";
            const string filter        = "ba";

            MetricsAdvisorClient client = GetMetricsAdvisorClient();

            var options = new GetDimensionValuesOptions()
            {
                DimensionValueToFilter = filter
            };

            var valueCount = 0;

            await foreach (string value in client.GetDimensionValuesAsync(MetricId, dimensionName, options))
            {
                Assert.That(value, Is.Not.Null.And.Not.Empty);
                Assert.That(value.ToLowerInvariant().Contains(filter));

                if (++valueCount >= MaximumSamplesCount)
                {
                    break;
                }
            }

            Assert.That(valueCount, Is.GreaterThan(0));
        }
        public async Task GetDimensionValuesAsync()
        {
            string endpoint        = MetricsAdvisorUri;
            string subscriptionKey = MetricsAdvisorSubscriptionKey;
            string apiKey          = MetricsAdvisorApiKey;
            var    credential      = new MetricsAdvisorKeyCredential(subscriptionKey, apiKey);

            var client = new MetricsAdvisorClient(new Uri(endpoint), credential);

            string metricId = MetricId;

            string dimensionName = "city";
            var    options       = new GetDimensionValuesOptions()
            {
                TopCount = 10
            };

            Console.WriteLine($"The dimension '{dimensionName}' can assume the following values (limited to 10):");

            int dimensionValueCount = 0;

            await foreach (string dimensionValue in client.GetDimensionValuesAsync(metricId, dimensionName, options))
            {
                Console.WriteLine($"  {dimensionValue}");

                // Print at most 10 values.
                if (++dimensionValueCount >= 10)
                {
                    break;
                }
            }
        }