예제 #1
0
        // [Fact]
        // public void SettingStateToDisabledWillClearStats_Interval()
        // {
        //    View intervalView =
        //        View.Create(
        //            VIEW_NAME_2,
        //            VIEW_DESCRIPTION,
        //            MeasureDouble,
        //            Mean,
        //            Arrays.asList(Key),
        //            Interval.Create(Duration.Create(60, 0)));
        //    settingStateToDisabledWillClearStats(intervalView);
        // }

        private void SettingStateToDisabledWillClearStats(IView view)
        {
            // TODO: deal with timestamp validation
            var timestamp1 = PreciseTimestamp.GetUtcNow().AddSeconds(-10);

            //clock.Time = timestamp1;
            viewManager.RegisterView(view);
            statsRecorder
            .NewMeasureMap()
            .Put(MeasureDouble, 1.1)
            .Record(tagger.EmptyBuilder.Put(Key, Value).Build());
            TagValues tv = TagValues.Create(new List <string>()
            {
                Value
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewManager.GetView(view.Name).AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(view.Aggregation, view.Measure, 1.1) },
            },
                Epsilon);

            var timestamp2 = timestamp1.AddSeconds(2);

            //clock.Time = timestamp2;
            Stats.State = StatsCollectionState.DISABLED; // This will clear stats.
            Assert.Equal(StatsTestUtil.CreateEmptyViewData(view), viewManager.GetView(view.Name));

            var timestamp3 = timestamp1.AddSeconds(3);

            //clock.Time = timestamp3;
            Stats.State = StatsCollectionState.ENABLED;

            var timestamp4 = timestamp1.AddSeconds(4);
            //clock.Time = timestamp4;
            // This ViewData does not have any stats, but it should not be an empty ViewData, since it has
            // non-zero TimeStamps.
            IViewData viewData = viewManager.GetView(view.Name);

            Assert.Empty(viewData.AggregationMap);
            //Assert.Equal(timestamp3, viewData.Start);
            //Assert.Equal(timestamp4, viewData.End);
            // if (windowData instanceof CumulativeData) {
            //    Assert.Equal(windowData).isEqualTo(CumulativeData.Create(timestamp3, timestamp4));
            // } else {
            //    Assert.Equal(windowData).isEqualTo(IntervalData.Create(timestamp4));
            // }
        }
예제 #2
0
        // [Fact]
        // public void SettingStateToDisabledWillClearStats_Interval()
        // {
        //    View intervalView =
        //        View.Create(
        //            VIEW_NAME_2,
        //            VIEW_DESCRIPTION,
        //            MEASURE_DOUBLE,
        //            MEAN,
        //            Arrays.asList(KEY),
        //            Interval.Create(Duration.Create(60, 0)));
        //    settingStateToDisabledWillClearStats(intervalView);
        // }

        private void SettingStateToDisabledWillClearStats(IView view)
        {
            // TODO: deal with timestamp validation
            Timestamp timestamp1 = Timestamp.Create(1, 0);

            //clock.Time = timestamp1;
            viewManager.RegisterView(view);
            statsRecorder
            .NewMeasureMap()
            .Put(MEASURE_DOUBLE, 1.1)
            .Record(tagger.EmptyBuilder.Put(KEY, VALUE).Build());
            TagValues tv = TagValues.Create(new List <TagValue>()
            {
                VALUE
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewManager.GetView(view.Name).AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(view.Aggregation, view.Measure, 1.1) },
            },
                EPSILON);

            Timestamp timestamp2 = Timestamp.Create(2, 0);

            //clock.Time = timestamp2;
            statsComponent.State = StatsCollectionState.DISABLED; // This will clear stats.
            Assert.Equal(StatsTestUtil.CreateEmptyViewData(view), viewManager.GetView(view.Name));

            Timestamp timestamp3 = Timestamp.Create(3, 0);

            //clock.Time = timestamp3;
            statsComponent.State = StatsCollectionState.ENABLED;

            Timestamp timestamp4 = Timestamp.Create(4, 0);
            //clock.Time = timestamp4;
            // This ViewData does not have any stats, but it should not be an empty ViewData, since it has
            // non-zero TimeStamps.
            IViewData viewData = viewManager.GetView(view.Name);

            Assert.Empty(viewData.AggregationMap);
            //Assert.Equal(timestamp3, viewData.Start);
            //Assert.Equal(timestamp4, viewData.End);
            // if (windowData instanceof CumulativeData) {
            //    Assert.Equal(windowData).isEqualTo(CumulativeData.Create(timestamp3, timestamp4));
            // } else {
            //    Assert.Equal(windowData).isEqualTo(IntervalData.Create(timestamp4));
            // }
        }
예제 #3
0
        public void RegisterRecordAndGetView_StatsDisabled()
        {
            Stats.State = StatsCollectionState.DISABLED;
            IView view = CreateCumulativeView(CreateRandomViewName(), MeasureDouble, Mean, new List <string>()
            {
                Key
            });

            viewManager.RegisterView(view);
            statsRecorder
            .NewMeasureMap()
            .Put(MeasureDouble, 1.1)
            .Record(tagger.EmptyBuilder.Put(Key, Value).Build());
            Assert.Equal(StatsTestUtil.CreateEmptyViewData(view), viewManager.GetView(view.Name));
        }
예제 #4
0
        public void RegisterRecordAndGetView_StatsDisabled()
        {
            statsComponent.State = StatsCollectionState.DISABLED;
            IView view = CreateCumulativeView(VIEW_NAME, MEASURE_DOUBLE, MEAN, new List <TagKey>()
            {
                KEY
            });

            viewManager.RegisterView(view);
            statsRecorder
            .NewMeasureMap()
            .Put(MEASURE_DOUBLE, 1.1)
            .Record(tagger.EmptyBuilder.Put(KEY, VALUE).Build());
            Assert.Equal(StatsTestUtil.CreateEmptyViewData(view), viewManager.GetView(VIEW_NAME));
        }
        public void Record_StatsReenabled()
        {
            IView view =
                View.Create(
                    VIEW_NAME,
                    "description",
                    MEASURE_DOUBLE,
                    Sum.Create(),
                    new List <string>()
            {
                KEY
            });

            viewManager.RegisterView(view);

            Stats.State = StatsCollectionState.DISABLED;
            statsRecorder
            .NewMeasureMap()
            .Put(MEASURE_DOUBLE, 1.0)
            .Record(new SimpleTagContext(new DistributedContextEntry(KEY, VALUE)));
            Assert.Equal(CreateEmptyViewData(view), viewManager.GetView(VIEW_NAME));

            Stats.State = StatsCollectionState.ENABLED;
            Assert.Empty(viewManager.GetView(VIEW_NAME).AggregationMap);
            // assertThat(viewManager.getView(VIEW_NAME).getWindowData())
            //    .isNotEqualTo(CumulativeData.Create(ZERO_TIMESTAMP, ZERO_TIMESTAMP));
            statsRecorder
            .NewMeasureMap()
            .Put(MEASURE_DOUBLE, 4.0)
            .Record(new SimpleTagContext(new DistributedContextEntry(KEY, VALUE)));
            TagValues tv = TagValues.Create(new List <string>()
            {
                VALUE
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewManager.GetView(VIEW_NAME).AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(Sum.Create(), MEASURE_DOUBLE, 4.0) },
            },
                1e-6);
        }
예제 #6
0
        private void TestMultipleViews_DifferentMeasures(IMeasure measure1, IMeasure measure2, double value1, double value2)
        {
            IView view1 = CreateCumulativeView(VIEW_NAME, measure1, DISTRIBUTION, new List <TagKey>()
            {
                KEY
            });
            IView view2 =
                CreateCumulativeView(VIEW_NAME_2, measure2, DISTRIBUTION, new List <TagKey>()
            {
                KEY
            });

            viewManager.RegisterView(view1);
            viewManager.RegisterView(view2);
            ITagContext tags       = tagger.EmptyBuilder.Put(KEY, VALUE).Build();
            IMeasureMap measureMap = statsRecorder.NewMeasureMap();

            PutToMeasureMap(measureMap, measure1, value1);
            PutToMeasureMap(measureMap, measure2, value2);
            measureMap.Record(tags);
            IViewData viewData1 = viewManager.GetView(VIEW_NAME);
            IViewData viewData2 = viewManager.GetView(VIEW_NAME_2);
            var       tv        = TagValues.Create(new List <TagValue>()
            {
                VALUE
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData1.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(DISTRIBUTION, measure1, value1) },
            },
                EPSILON);

            StatsTestUtil.AssertAggregationMapEquals(
                viewData2.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(DISTRIBUTION, measure2, value2) },
            },
                EPSILON);
        }
        public void RecordTwice()
        {
            Stats.State = StatsCollectionState.ENABLED;

            IViewName viewName = CreateRandomViewName();

            IView view =
                View.Create(
                    viewName,
                    "description",
                    MEASURE_DOUBLE,
                    Sum.Create(),
                    new List <string>()
            {
                KEY
            });

            viewManager.RegisterView(view);
            IMeasureMap statsRecord = statsRecorder.NewMeasureMap().Put(MEASURE_DOUBLE, 1.0);

            statsRecord.Record(new SimpleTagContext(new DistributedContextEntry(KEY, VALUE)));
            statsRecord.Record(new SimpleTagContext(new DistributedContextEntry(KEY, VALUE_2)));
            IViewData viewData = viewManager.GetView(viewName);

            // There should be two entries.
            var tv = TagValues.Create(new List <string>()
            {
                VALUE
            });
            var tv2 = TagValues.Create(new List <string>()
            {
                VALUE_2
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(Sum.Create(), MEASURE_DOUBLE, 1.0) },
                { tv2, StatsTestUtil.CreateAggregationData(Sum.Create(), MEASURE_DOUBLE, 1.0) },
            },
                1e-6);
        }
예제 #8
0
        private void TestMultipleViews_DifferentMeasures(IMeasure measure1, IMeasure measure2, double value1, double value2)
        {
            IView view1 = CreateCumulativeView(CreateRandomViewName(), measure1, Distribution, new List <string>()
            {
                Key
            });
            IView view2 = CreateCumulativeView(CreateRandomViewName(), measure2, Distribution, new List <string>()
            {
                Key
            });

            viewManager.RegisterView(view1);
            viewManager.RegisterView(view2);
            ITagContext tags       = tagger.EmptyBuilder.Put(Key, Value).Build();
            IMeasureMap measureMap = statsRecorder.NewMeasureMap();

            PutToMeasureMap(measureMap, measure1, value1);
            PutToMeasureMap(measureMap, measure2, value2);
            measureMap.Record(tags);
            IViewData viewData1 = viewManager.GetView(view1.Name);
            IViewData viewData2 = viewManager.GetView(view2.Name);
            var       tv        = TagValues.Create(new List <string>()
            {
                Value
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData1.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(Distribution, measure1, value1) },
            },
                Epsilon);

            StatsTestUtil.AssertAggregationMapEquals(
                viewData2.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(Distribution, measure2, value2) },
            },
                Epsilon);
        }
예제 #9
0
        public void TestMultipleViewSameMeasure()
        {
            IView view1 =
                CreateCumulativeView(CreateRandomViewName(), MeasureDouble, Distribution, new List <string>()
            {
                Key
            });
            IView view2 =
                CreateCumulativeView(CreateRandomViewName(), MeasureDouble, Distribution, new List <string>()
            {
                Key
            });

            viewManager.RegisterView(view1);
            viewManager.RegisterView(view2);
            statsRecorder
            .NewMeasureMap()
            .Put(MeasureDouble, 5.0)
            .Record(tagger.EmptyBuilder.Put(Key, Value).Build());
            IViewData viewData1 = viewManager.GetView(view1.Name);
            IViewData viewData2 = viewManager.GetView(view2.Name);
            var       tv        = TagValues.Create(new List <string>()
            {
                Value
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData1.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(Distribution, MeasureDouble, 5.0) },
            },
                Epsilon);

            StatsTestUtil.AssertAggregationMapEquals(
                viewData2.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(Distribution, MeasureDouble, 5.0) },
            },
                Epsilon);
        }
예제 #10
0
        public void TestMultipleViewSameMeasure()
        {
            IView view1 =
                CreateCumulativeView(VIEW_NAME, MEASURE_DOUBLE, DISTRIBUTION, new List <TagKey>()
            {
                KEY
            });
            IView view2 =
                CreateCumulativeView(VIEW_NAME_2, MEASURE_DOUBLE, DISTRIBUTION, new List <TagKey>()
            {
                KEY
            });

            viewManager.RegisterView(view1);
            viewManager.RegisterView(view2);
            statsRecorder
            .NewMeasureMap()
            .Put(MEASURE_DOUBLE, 5.0)
            .Record(tagger.EmptyBuilder.Put(KEY, VALUE).Build());
            IViewData viewData1 = viewManager.GetView(VIEW_NAME);
            IViewData viewData2 = viewManager.GetView(VIEW_NAME_2);
            var       tv        = TagValues.Create(new List <TagValue>()
            {
                VALUE
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData1.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(DISTRIBUTION, MEASURE_DOUBLE, 5.0) },
            },
                EPSILON);

            StatsTestUtil.AssertAggregationMapEquals(
                viewData2.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(DISTRIBUTION, MEASURE_DOUBLE, 5.0) },
            },
                EPSILON);
        }
예제 #11
0
        public void Record_UnregisteredMeasure()
        {
            Stats.State = StatsCollectionState.ENABLED;

            IViewName viewName = CreateRandomViewName();

            IView view =
                View.Create(
                    viewName,
                    "description",
                    MEASURE_DOUBLE,
                    Sum.Create(),
                    new List <TagKey>()
            {
                KEY
            });

            viewManager.RegisterView(view);
            statsRecorder
            .NewMeasureMap()
            .Put(MEASURE_DOUBLE_NO_VIEW_1, 1.0)
            .Put(MEASURE_DOUBLE, 2.0)
            .Put(MEASURE_DOUBLE_NO_VIEW_2, 3.0)
            .Record(new SimpleTagContext(Tag.Create(KEY, VALUE)));

            IViewData viewData = viewManager.GetView(viewName);

            // There should be one entry.
            var tv = TagValues.Create(new List <TagValue>()
            {
                VALUE
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(Sum.Create(), MEASURE_DOUBLE, 2.0) }
            },
                1e-6);
        }
예제 #12
0
        public void TestRecordCumulativeMultipleTagValues()
        {
            IView view = CreateCumulativeView(CreateRandomViewName(), MeasureDouble, Distribution, new List <TagKey>()
            {
                Key
            });

            viewManager.RegisterView(view);
            statsRecorder
            .NewMeasureMap()
            .Put(MeasureDouble, 10.0)
            .Record(tagger.EmptyBuilder.Put(Key, Value).Build());
            statsRecorder
            .NewMeasureMap()
            .Put(MeasureDouble, 30.0)
            .Record(tagger.EmptyBuilder.Put(Key, Value2).Build());
            statsRecorder
            .NewMeasureMap()
            .Put(MeasureDouble, 50.0)
            .Record(tagger.EmptyBuilder.Put(Key, Value2).Build());
            IViewData viewData = viewManager.GetView(view.Name);
            var       tv       = TagValues.Create(new List <TagValue>()
            {
                Value
            });
            var tv2 = TagValues.Create(new List <TagValue>()
            {
                Value2
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(Distribution, MeasureDouble, 10.0) },
                { tv2, StatsTestUtil.CreateAggregationData(Distribution, MeasureDouble, 30.0, 50.0) },
            },
                Epsilon);
        }
예제 #13
0
        public void GetViewDoesNotClearStats()
        {
            IView view = CreateCumulativeView(CreateRandomViewName(), MeasureDouble, Distribution, new List <string>()
            {
                Key
            });

            viewManager.RegisterView(view);
            ITagContext tags = tagger.EmptyBuilder.Put(Key, Value).Build();

            statsRecorder.NewMeasureMap().Put(MeasureDouble, 0.1).Record(tags);
            IViewData viewData1 = viewManager.GetView(view.Name);
            var       tv        = TagValues.Create(new List <string>()
            {
                Value
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData1.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(Distribution, MeasureDouble, 0.1) },
            },
                Epsilon);

            statsRecorder.NewMeasureMap().Put(MeasureDouble, 0.2).Record(tags);
            IViewData viewData2 = viewManager.GetView(view.Name);

            // The second view should have the same start time as the first view, and it should include both
            // Recorded values:

            StatsTestUtil.AssertAggregationMapEquals(
                viewData2.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(Distribution, MeasureDouble, 0.1, 0.2) },
            },
                Epsilon);
        }
예제 #14
0
        public void RecordTwice()
        {
            var view =
                View.Create(
                    VIEW_NAME,
                    "description",
                    MEASURE_DOUBLE,
                    Sum.Create(),
                    new List <TagKey>()
            {
                KEY
            });

            viewManager.RegisterView(view);
            var statsRecord = statsRecorder.NewMeasureMap().Put(MEASURE_DOUBLE, 1.0);

            statsRecord.Record(new SimpleTagContext(Tag.Create(KEY, VALUE)));
            statsRecord.Record(new SimpleTagContext(Tag.Create(KEY, VALUE_2)));
            var viewData = viewManager.GetView(VIEW_NAME);

            // There should be two entries.
            var tv = TagValues.Create(new List <TagValue>()
            {
                VALUE
            });
            var tv2 = TagValues.Create(new List <TagValue>()
            {
                VALUE_2
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(Sum.Create(), MEASURE_DOUBLE, 1.0) },
                { tv2, StatsTestUtil.CreateAggregationData(Sum.Create(), MEASURE_DOUBLE, 1.0) },
            },
                1e-6);
        }
예제 #15
0
        public void GetViewDoesNotClearStats()
        {
            IView view = CreateCumulativeView(VIEW_NAME, MEASURE_DOUBLE, DISTRIBUTION, new List <TagKey>()
            {
                KEY
            });

            viewManager.RegisterView(view);
            ITagContext tags = tagger.EmptyBuilder.Put(KEY, VALUE).Build();

            statsRecorder.NewMeasureMap().Put(MEASURE_DOUBLE, 0.1).Record(tags);
            IViewData viewData1 = viewManager.GetView(VIEW_NAME);
            var       tv        = TagValues.Create(new List <TagValue>()
            {
                VALUE
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData1.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(DISTRIBUTION, MEASURE_DOUBLE, 0.1) },
            },
                EPSILON);

            statsRecorder.NewMeasureMap().Put(MEASURE_DOUBLE, 0.2).Record(tags);
            IViewData viewData2 = viewManager.GetView(VIEW_NAME);

            // The second view should have the same start time as the first view, and it should include both
            // Recorded values:

            StatsTestUtil.AssertAggregationMapEquals(
                viewData2.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(DISTRIBUTION, MEASURE_DOUBLE, 0.1, 0.2) },
            },
                EPSILON);
        }
예제 #16
0
        public void TestRecordCumulativeMultipleTagValues()
        {
            viewManager.RegisterView(
                CreateCumulativeView(VIEW_NAME, MEASURE_DOUBLE, DISTRIBUTION, new List <TagKey>()
            {
                KEY
            }));
            statsRecorder
            .NewMeasureMap()
            .Put(MEASURE_DOUBLE, 10.0)
            .Record(tagger.EmptyBuilder.Put(KEY, VALUE).Build());
            statsRecorder
            .NewMeasureMap()
            .Put(MEASURE_DOUBLE, 30.0)
            .Record(tagger.EmptyBuilder.Put(KEY, VALUE_2).Build());
            statsRecorder
            .NewMeasureMap()
            .Put(MEASURE_DOUBLE, 50.0)
            .Record(tagger.EmptyBuilder.Put(KEY, VALUE_2).Build());
            IViewData viewData = viewManager.GetView(VIEW_NAME);
            var       tv       = TagValues.Create(new List <TagValue>()
            {
                VALUE
            });
            var tv2 = TagValues.Create(new List <TagValue>()
            {
                VALUE_2
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv, StatsTestUtil.CreateAggregationData(DISTRIBUTION, MEASURE_DOUBLE, 10.0) },
                { tv2, StatsTestUtil.CreateAggregationData(DISTRIBUTION, MEASURE_DOUBLE, 30.0, 50.0) },
            },
                EPSILON);
        }
예제 #17
0
        public void TestRecordWithTagsThatDoNotMatchViewData()
        {
            Stats.State = StatsCollectionState.ENABLED;

            IView view = CreateCumulativeView(CreateRandomViewName(), MeasureDouble, Distribution, new List <string>()
            {
                Key
            });

            viewManager.RegisterView(view);
            statsRecorder
            .NewMeasureMap()
            .Put(MeasureDouble, 10.0)
            .Record(tagger.EmptyBuilder.Put("wrong key", Value).Build());
            statsRecorder
            .NewMeasureMap()
            .Put(MeasureDouble, 50.0)
            .Record(tagger.EmptyBuilder.Put("another wrong key", Value).Build());
            IViewData viewData = viewManager.GetView(view.Name);
            var       tv       = TagValues.Create(new List <string>()
            {
                MutableViewData.UnknownTagValue
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                // Won't Record the unregistered tag key, for missing registered keys will use default
                // tag value : "unknown/not set".
                { tv,
                  // Should Record stats with default tag value: "Key" : "unknown/not set".
                  StatsTestUtil.CreateAggregationData(Distribution, MeasureDouble, 10.0, 50.0) },
            },
                Epsilon);
        }
예제 #18
0
        public void TestViewDataWithMultipleTagKeys()
        {
            string key1 = "Key-1";
            string key2 = "Key-2";
            IView  view = CreateCumulativeView(CreateRandomViewName(), MeasureDouble, Distribution, new List <string>()
            {
                key1, key2
            });

            viewManager.RegisterView(view);
            statsRecorder
            .NewMeasureMap()
            .Put(MeasureDouble, 1.1)
            .Record(
                tagger
                .EmptyBuilder
                .Put(key1, "v1")
                .Put(key2, "v10")
                .Build());
            statsRecorder
            .NewMeasureMap()
            .Put(MeasureDouble, 2.2)
            .Record(
                tagger
                .EmptyBuilder
                .Put(key1, "v1")
                .Put(key2, "v20")
                .Build());
            statsRecorder
            .NewMeasureMap()
            .Put(MeasureDouble, 3.3)
            .Record(
                tagger
                .EmptyBuilder
                .Put(key1, "v2")
                .Put(key2, "v10")
                .Build());
            statsRecorder
            .NewMeasureMap()
            .Put(MeasureDouble, 4.4)
            .Record(
                tagger
                .EmptyBuilder
                .Put(key1, "v1")
                .Put(key2, "v10")
                .Build());
            IViewData viewData = viewManager.GetView(view.Name);
            var       tv1      = TagValues.Create(new List <string>()
            {
                "v1", "v10"
            });
            var tv2 = TagValues.Create(new List <string>()
            {
                "v1", "v20"
            });
            var tv3 = TagValues.Create(new List <string>()
            {
                "v2", "v10"
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv1, StatsTestUtil.CreateAggregationData(Distribution, MeasureDouble, 1.1, 4.4) },
                { tv2, StatsTestUtil.CreateAggregationData(Distribution, MeasureDouble, 2.2) },
                { tv3, StatsTestUtil.CreateAggregationData(Distribution, MeasureDouble, 3.3) },
            },
                Epsilon);
        }
예제 #19
0
        public void TestViewDataWithMultipleTagKeys()
        {
            TagKey key1 = TagKey.Create("Key-1");
            TagKey key2 = TagKey.Create("Key-2");

            viewManager.RegisterView(
                CreateCumulativeView(VIEW_NAME, MEASURE_DOUBLE, DISTRIBUTION, new List <TagKey>()
            {
                key1, key2
            }));
            statsRecorder
            .NewMeasureMap()
            .Put(MEASURE_DOUBLE, 1.1)
            .Record(
                tagger
                .EmptyBuilder
                .Put(key1, TagValue.Create("v1"))
                .Put(key2, TagValue.Create("v10"))
                .Build());
            statsRecorder
            .NewMeasureMap()
            .Put(MEASURE_DOUBLE, 2.2)
            .Record(
                tagger
                .EmptyBuilder
                .Put(key1, TagValue.Create("v1"))
                .Put(key2, TagValue.Create("v20"))
                .Build());
            statsRecorder
            .NewMeasureMap()
            .Put(MEASURE_DOUBLE, 3.3)
            .Record(
                tagger
                .EmptyBuilder
                .Put(key1, TagValue.Create("v2"))
                .Put(key2, TagValue.Create("v10"))
                .Build());
            statsRecorder
            .NewMeasureMap()
            .Put(MEASURE_DOUBLE, 4.4)
            .Record(
                tagger
                .EmptyBuilder
                .Put(key1, TagValue.Create("v1"))
                .Put(key2, TagValue.Create("v10"))
                .Build());
            IViewData viewData = viewManager.GetView(VIEW_NAME);
            var       tv1      = TagValues.Create(new List <TagValue>()
            {
                TagValue.Create("v1"), TagValue.Create("v10")
            });
            var tv2 = TagValues.Create(new List <TagValue>()
            {
                TagValue.Create("v1"), TagValue.Create("v20")
            });
            var tv3 = TagValues.Create(new List <TagValue>()
            {
                TagValue.Create("v2"), TagValue.Create("v10")
            });

            StatsTestUtil.AssertAggregationMapEquals(
                viewData.AggregationMap,
                new Dictionary <TagValues, IAggregationData>()
            {
                { tv1, StatsTestUtil.CreateAggregationData(DISTRIBUTION, MEASURE_DOUBLE, 1.1, 4.4) },
                { tv2, StatsTestUtil.CreateAggregationData(DISTRIBUTION, MEASURE_DOUBLE, 2.2) },
                { tv3, StatsTestUtil.CreateAggregationData(DISTRIBUTION, MEASURE_DOUBLE, 3.3) },
            },
                EPSILON);
        }