Exemplo n.º 1
0
        public async Task AddAndGetPeriodFeedback()
        {
            MetricsAdvisorClient client = GetMetricsAdvisorClient();

            var dimensionKey = new DimensionKey();

            dimensionKey.AddDimensionColumn("city", "Delhi");
            dimensionKey.AddDimensionColumn("category", "Handmade");

            var filter      = new FeedbackDimensionFilter(dimensionKey);
            var periodValue = 10;

            var feedbackToAdd = new MetricPeriodFeedback(MetricId, filter, PeriodType.AutoDetect, periodValue);

            string feedbackId = await client.AddFeedbackAsync(feedbackToAdd);

            Assert.That(feedbackId, Is.Not.Null);

            MetricFeedback addedFeedback = await client.GetFeedbackAsync(feedbackId);

            ValidateMetricFeedback(addedFeedback, feedbackId, dimensionKey);

            Assert.That(addedFeedback.Type, Is.EqualTo(FeedbackType.Period));

            var periodFeedback = addedFeedback as MetricPeriodFeedback;

            Assert.That(periodFeedback, Is.Not.Null);
            Assert.That(periodFeedback.PeriodType, Is.EqualTo(PeriodType.AutoDetect));
            Assert.That(periodFeedback.PeriodValue, Is.EqualTo(periodValue));
        }
        public async Task AddAndGetPeriodFeedback()
        {
            MetricsAdvisorClient client = GetMetricsAdvisorClient();

            var dimensions = new Dictionary <string, string>()
            {
                { "region", ExpectedRegion }, { "category", ExpectedCategory }
            };
            var dimensionKey = new DimensionKey(dimensions);

            var periodValue = 10;

            var feedbackToAdd = new MetricPeriodFeedback(MetricId, dimensionKey, MetricPeriodType.AutoDetect, periodValue);

            MetricFeedback addedFeedback = await client.AddFeedbackAsync(feedbackToAdd);

            ValidateMetricFeedback(addedFeedback);

            Assert.That(addedFeedback.FeedbackKind, Is.EqualTo(MetricFeedbackKind.Period));

            var periodFeedback = addedFeedback as MetricPeriodFeedback;

            Assert.That(periodFeedback, Is.Not.Null);
            Assert.That(periodFeedback.PeriodType, Is.EqualTo(MetricPeriodType.AutoDetect));
            Assert.That(periodFeedback.PeriodValue, Is.EqualTo(periodValue));
            Assert.That(periodFeedback.UserPrincipal, Is.Not.Null.And.Not.Empty);
        }
        public async Task AddAndGetPeriodFeedback()
        {
            MetricsAdvisorClient client = GetMetricsAdvisorClient();

            var filter = new FeedbackDimensionFilter();

            filter.DimensionFilter.AddDimensionColumn("city", ExpectedCity);
            filter.DimensionFilter.AddDimensionColumn("category", ExpectedCategory);

            var periodValue = 10;

            var feedbackToAdd = new MetricPeriodFeedback(MetricId, filter, PeriodType.AutoDetect, periodValue);

            MetricFeedback addedFeedback = await client.AddFeedbackAsync(feedbackToAdd);

            ValidateMetricFeedback(addedFeedback);

            Assert.That(addedFeedback.Type, Is.EqualTo(FeedbackType.Period));

            var periodFeedback = addedFeedback as MetricPeriodFeedback;

            Assert.That(periodFeedback, Is.Not.Null);
            Assert.That(periodFeedback.PeriodType, Is.EqualTo(PeriodType.AutoDetect));
            Assert.That(periodFeedback.PeriodValue, Is.EqualTo(periodValue));
        }
Exemplo n.º 4
0
        public async Task GetFeedbackAsync()
        {
            string endpoint        = MetricsAdvisorUri;
            string subscriptionKey = MetricsAdvisorSubscriptionKey;
            string apiKey          = MetricsAdvisorApiKey;
            var    credential      = new MetricsAdvisorKeyCredential(subscriptionKey, apiKey);

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

            string feedbackId = FeedbackId;

            Response <MetricFeedback> response = await client.GetFeedbackAsync(feedbackId);

            MetricFeedback feedback = response.Value;

            Console.WriteLine($"Feedback ID: {feedback.Id}");
            Console.WriteLine($"Metric ID: {feedback.MetricId}");
            Console.WriteLine($"Feedback type: {feedback.Type}");
            Console.WriteLine();

            if (feedback.Type == FeedbackType.Anomaly)
            {
                MetricAnomalyFeedback anomalyFeedback = feedback as MetricAnomalyFeedback;

                Console.WriteLine($"Detection configuration ID: {anomalyFeedback.AnomalyDetectionConfigurationId}");
                Console.WriteLine($"Anomaly value: {anomalyFeedback.AnomalyValue}");
            }
            else if (feedback.Type == FeedbackType.Comment)
            {
                MetricCommentFeedback commentFeedback = feedback as MetricCommentFeedback;

                Console.WriteLine($"Comment: {commentFeedback.Comment}");
            }
            else if (feedback.Type == FeedbackType.ChangePoint)
            {
                MetricChangePointFeedback changePointFeedback = feedback as MetricChangePointFeedback;

                Console.WriteLine($"Change point value: {changePointFeedback.ChangePointValue}");
            }
            else if (feedback.Type == FeedbackType.Period)
            {
                MetricPeriodFeedback periodFeedback = feedback as MetricPeriodFeedback;

                Console.WriteLine($"Period type: {periodFeedback.PeriodType}");
                Console.WriteLine($"Period value: {periodFeedback.PeriodValue}");
            }
        }
        public async Task CreateMetricFeedback()
        {
            var client = GetMetricsAdvisorClient();
            FeedbackDimensionFilter dimensionFilter = new FeedbackDimensionFilter(
                new DimensionKey(
                    new Dictionary <string, string>
            {
                { "Dim1", "Common Lime" },
                { "Dim2", "Ant" }
            }));
            DateTimeOffset start = Recording.UtcNow.AddMonths(-4);
            DateTimeOffset end   = Recording.UtcNow;

            MetricAnomalyFeedback     anomalyFeedback     = new MetricAnomalyFeedback(MetricId, dimensionFilter, start, end, AnomalyValue.NotAnomaly);
            MetricChangePointFeedback changePointFeedback = new MetricChangePointFeedback(MetricId, dimensionFilter, start, end, ChangePointValue.NotChangePoint);
            MetricPeriodFeedback      periodFeedback      = new MetricPeriodFeedback(MetricId, dimensionFilter, PeriodType.AssignValue, 5);
            MetricCommentFeedback     commentFeedback     = new MetricCommentFeedback(MetricId, dimensionFilter, "my comment");

            var feedbacks = new List <MetricFeedback>
            {
                anomalyFeedback,
                changePointFeedback,
                periodFeedback,
                commentFeedback
            };

            foreach (var feedback in feedbacks)
            {
                MetricFeedback createdFeedback = await client.CreateMetricFeedbackAsync(feedback).ConfigureAwait(false);

                Assert.That(createdFeedback.MetricId, Is.EqualTo(MetricId));
                Assert.That(createdFeedback.Id, Is.Not.Null);

                MetricFeedback getFeedback = await client.GetMetricFeedbackAsync(feedbackId : createdFeedback.Id).ConfigureAwait(false);

                Assert.That(getFeedback.Id, Is.EqualTo(createdFeedback.Id));
            }
        }