Exemplo n.º 1
0
        public HttpClientDesktopObserver(IMetricsOptions options, IStats censusStats, ITags censusTags, ILogger <HttpClientDesktopObserver> logger)
            : base(OBSERVER_NAME, DIAGNOSTIC_NAME, options, censusStats, censusTags, logger)
        {
            PathMatcher = new Regex(options.EgressIgnorePattern);

            clientTimeMeasure  = MeasureDouble.Create("client.desk.totalTime", "Total request time", MeasureUnit.MilliSeconds);
            clientCountMeasure = MeasureLong.Create("client.core.totalRequests", "Total request count", "count");

            var view = View.Create(
                ViewName.Create("http.desktop.client.request.time"),
                "Total request time",
                clientTimeMeasure,
                Distribution.Create(BucketBoundaries.Create(new List <double>()
            {
                0.0, 1.0, 5.0, 10.0, 100.0
            })),
                new List <ITagKey>()
            {
                statusTagKey, uriTagKey, methodTagKey, clientTagKey
            });

            ViewManager.RegisterView(view);

            view = View.Create(
                ViewName.Create("http.desktop.client.request.count"),
                "Total request counts",
                clientCountMeasure,
                Sum.Create(),
                new List <ITagKey>()
            {
                statusTagKey, uriTagKey, methodTagKey, clientTagKey
            });
            ViewManager.RegisterView(view);
        }
Exemplo n.º 2
0
 public void TestRecord_MeasureTypeNotMatch()
 {
     TestRecord_MeasureNotMatch(
         MeasureLong.Create(MEASURE_NAME, "measure", MEASURE_UNIT),
         MeasureDouble.Create(MEASURE_NAME, "measure", MEASURE_UNIT),
         10.0);
 }
Exemplo n.º 3
0
        public OwinHostingObserver(IMetricsOptions options, IStats censusStats, ITags censusTags, ILogger <OwinHostingObserver> logger)
            : base(OBSERVER_NAME, DIAGNOSTIC_NAME, options, censusStats, censusTags, logger)
        {
            PathMatcher = new Regex(options.IngressIgnorePattern);

            responseTimeMeasure = MeasureDouble.Create("server.owin.totalTime", "Total request time", MeasureUnit.MilliSeconds);
            serverCountMeasure  = MeasureLong.Create("server.owin.totalRequests", "Total request count", "count");

            var view = View.Create(
                ViewName.Create("http.server.request.time"),
                "Total request time",
                responseTimeMeasure,
                Distribution.Create(BucketBoundaries.Create(new List <double>()
            {
                0.0, 1.0, 5.0, 10.0, 100.0
            })),
                new List <ITagKey>()
            {
                statusTagKey, exceptionTagKey, methodTagKey, uriTagKey
            });

            ViewManager.RegisterView(view);

            view = View.Create(
                ViewName.Create("http.server.request.count"),
                "Total request counts",
                serverCountMeasure,
                Sum.Create(),
                new List <ITagKey>()
            {
                statusTagKey, exceptionTagKey, methodTagKey, uriTagKey
            });

            ViewManager.RegisterView(view);
        }
Exemplo n.º 4
0
        public void TestMatch()
        {
            List <IMeasure> measures =
                new List <IMeasure>()
            {
                MeasureDouble.Create("measure1", "description", "1"),
                MeasureLong.Create("measure2", "description", "1"),
            };
            List <String> outputs = new List <string>();

            foreach (IMeasure measure in measures)
            {
                outputs.Add(
                    measure.Match(
                        (arg) =>
                {
                    return("double");
                },
                        (arg) =>
                {
                    return("long");
                },
                        (arg) =>
                {
                    throw new ArgumentException();
                }));
            }

            Assert.Equal(new List <string>()
            {
                "double", "long"
            }, outputs);
        }
Exemplo n.º 5
0
 public void TestMultipleViews_DifferentMeasureTypes()
 {
     TestMultipleViews_DifferentMeasures(
         MeasureDouble.Create(MEASURE_NAME, MEASURE_DESCRIPTION, MEASURE_UNIT),
         MeasureLong.Create(MEASURE_NAME_2, MEASURE_DESCRIPTION, MEASURE_UNIT),
         1.1,
         5000);
 }
Exemplo n.º 6
0
        public void Testmeasurelongcomponents()
        {
            IMeasure measurement = MeasureLong.Create("Bar", "The description of Bar", "1");

            Assert.Equal("Bar", measurement.Name);
            Assert.Equal("The description of Bar", measurement.Description);
            Assert.Equal("1", measurement.Unit);
        }
Exemplo n.º 7
0
        public CLRRuntimeObserver(IMetricsOptions options, IStats censusStats, ITags censusTags, ILogger <CLRRuntimeObserver> logger)
            : base(OBSERVER_NAME, DIAGNOSTIC_NAME, options, censusStats, censusTags, logger)
        {
            memoryUsedMeasure      = MeasureLong.Create("memory.used.value", "Current CLR memory usage", MeasureUnit.Bytes);
            collectionCountMeasure = MeasureLong.Create("collection.count", "Garbage collection count", "count");
            activeThreadsMeasure   = MeasureLong.Create("active.thread.value", "Active thread count", "count");
            availThreadsMeasure    = MeasureLong.Create("avail.thread.value", "Available thread count", "count");

            memoryTagValues             = Tagger.CurrentBuilder.Put(memoryAreaKey, heapArea).Build();
            threadPoolWorkerTagValues   = Tagger.CurrentBuilder.Put(threadKindKey, threadPoolWorkerKind).Build();
            threadPoolCompPortTagValues = Tagger.CurrentBuilder.Put(threadKindKey, threadPoolComppKind).Build();

            RegisterViews();
        }
Exemplo n.º 8
0
        public void PreventRegisteringDifferentMeasureWithSameName()
        {
            IMeasureDouble measure1 = MeasureDouble.Create("measure", "description", "1");
            IMeasureLong   measure2 = MeasureLong.Create("measure", "description", "1");
            IView          view1    =
                View.Create(
                    VIEW_NAME, VIEW_DESCRIPTION, measure1, DISTRIBUTION, new List <ITagKey>()
            {
                KEY
            });
            IView view2 =
                View.Create(
                    VIEW_NAME_2, VIEW_DESCRIPTION, measure2, DISTRIBUTION, new List <ITagKey>()
            {
                KEY
            });

            TestFailedToRegisterView(view1, view2, "A different measure with the same name is already registered");
        }
Exemplo n.º 9
0
 private static IMeasureLong MakeSimpleMeasureLong(String measure)
 {
     return(MeasureLong.Create(measure, measure + " description", "1"));
 }
        public void Main()
        {
            var statsComponent = new StatsComponent();
            var viewManager    = statsComponent.ViewManager;
            var statsRecorder  = statsComponent.StatsRecorder;
            var tagsComponent  = new TagsComponent();
            var tagger         = tagsComponent.Tagger;

            ITagKey FRONTEND_KEY            = TagKey.Create("my.org/keys/frontend");
            ITagKey FRONTEND_OS_KEY         = TagKey.Create("my.org/keys/frontend/os");
            ITagKey FRONTEND_OS_VERSION_KEY = TagKey.Create("my.org/keys/frontend/os/version");

            IMeasureLong VIDEO_SIZE = MeasureLong.Create("my.org/measure/video_size", "size of processed videos", "MBy");

            IViewName VIDEO_SIZE_BY_FRONTEND_VIEW_NAME = ViewName.Create("my.org/views/video_size_byfrontend");
            IView     VIDEO_SIZE_BY_FRONTEND_VIEW      = View.Create(
                VIDEO_SIZE_BY_FRONTEND_VIEW_NAME,
                "processed video size over time",
                VIDEO_SIZE,
                Distribution.Create(BucketBoundaries.Create(new List <double>()
            {
                0.0, 256.0, 65536.0
            })),
                new List <ITagKey>()
            {
                FRONTEND_KEY
            });

            IViewName VIDEO_SIZE_ALL_VIEW_NAME = ViewName.Create("my.org/views/video_size_all");
            IView     VIDEO_SIZE_VIEW_ALL      = View.Create(
                VIDEO_SIZE_ALL_VIEW_NAME,
                "processed video size over time",
                VIDEO_SIZE,
                Distribution.Create(BucketBoundaries.Create(new List <double>()
            {
                0.0, 256.0, 65536.0
            })),
                new List <ITagKey>()
            {
            });


            IViewName VIDEO_SIZE_TOTAL_VIEW_NAME = ViewName.Create("my.org/views/video_size_total");
            IView     VIDEO_SIZE_TOTAL           = View.Create(
                VIDEO_SIZE_TOTAL_VIEW_NAME,
                "total video size over time",
                VIDEO_SIZE,
                Sum.Create(),
                new List <ITagKey>()
            {
                FRONTEND_KEY
            });

            IViewName VIDEOS_PROCESSED_VIEW_NAME = ViewName.Create("my.org/views/videos_processed");
            IView     VIDEOS_PROCESSED           = View.Create(
                VIDEOS_PROCESSED_VIEW_NAME,
                "total video processed",
                VIDEO_SIZE,
                Count.Create(),
                new List <ITagKey>()
            {
                FRONTEND_KEY
            });

            viewManager.RegisterView(VIDEO_SIZE_VIEW_ALL);
            viewManager.RegisterView(VIDEO_SIZE_BY_FRONTEND_VIEW);
            viewManager.RegisterView(VIDEO_SIZE_TOTAL);
            viewManager.RegisterView(VIDEOS_PROCESSED);

            ITagContext context1 = tagger
                                   .EmptyBuilder
                                   .Put(FRONTEND_KEY, TagValue.Create("front1"))
                                   .Build();
            ITagContext context2 = tagger
                                   .EmptyBuilder
                                   .Put(FRONTEND_KEY, TagValue.Create("front2"))
                                   .Build();

            long sum = 0;

            for (int i = 0; i < 10; i++)
            {
                sum = sum + (25648 * i);
                if (i % 2 == 0)
                {
                    statsRecorder.NewMeasureMap().Put(VIDEO_SIZE, 25648 * i).Record(context1);
                }
                else
                {
                    statsRecorder.NewMeasureMap().Put(VIDEO_SIZE, 25648 * i).Record(context2);
                }
            }

            IViewData viewDataByFrontend = viewManager.GetView(VIDEO_SIZE_BY_FRONTEND_VIEW_NAME);
            var       viewDataAggMap     = viewDataByFrontend.AggregationMap.ToList();

            output.WriteLine(viewDataByFrontend.ToString());

            IViewData viewDataAll       = viewManager.GetView(VIDEO_SIZE_ALL_VIEW_NAME);
            var       viewDataAggMapAll = viewDataAll.AggregationMap.ToList();

            output.WriteLine(viewDataAll.ToString());

            IViewData viewData1       = viewManager.GetView(VIDEO_SIZE_TOTAL_VIEW_NAME);
            var       viewData1AggMap = viewData1.AggregationMap.ToList();

            output.WriteLine(viewData1.ToString());

            IViewData viewData2       = viewManager.GetView(VIDEOS_PROCESSED_VIEW_NAME);
            var       viewData2AggMap = viewData2.AggregationMap.ToList();

            output.WriteLine(viewData2.ToString());

            output.WriteLine(sum.ToString());
        }
        public void Main2()
        {
            var statsComponent = new StatsComponent();
            var viewManager    = statsComponent.ViewManager;
            var statsRecorder  = statsComponent.StatsRecorder;
            var tagsComponent  = new TagsComponent();
            var tagger         = tagsComponent.Tagger;

            ITagKey FRONTEND_KEY            = TagKey.Create("my.org/keys/frontend");
            ITagKey FRONTEND_OS_KEY         = TagKey.Create("my.org/keys/frontend/os");
            ITagKey FRONTEND_OS_VERSION_KEY = TagKey.Create("my.org/keys/frontend/os/version");

            IMeasureLong VIDEO_SIZE = MeasureLong.Create("my.org/measure/video_size", "size of processed videos", "MBy");

            IViewName VIDEO_SIZE_VIEW_NAME = ViewName.Create("my.org/views/video_size_byfrontend");
            IView     VIDEO_SIZE_VIEW      = View.Create(
                VIDEO_SIZE_VIEW_NAME,
                "processed video size over time",
                VIDEO_SIZE,
                Distribution.Create(BucketBoundaries.Create(new List <double>()
            {
                0.0, 256.0, 65536.0
            })),
                new List <ITagKey>()
            {
                FRONTEND_KEY, FRONTEND_OS_KEY, FRONTEND_OS_VERSION_KEY
            });


            viewManager.RegisterView(VIDEO_SIZE_VIEW);


            ITagContext context1 = tagger
                                   .EmptyBuilder
                                   .Put(FRONTEND_KEY, TagValue.Create("front1"))
                                   .Put(FRONTEND_OS_KEY, TagValue.Create("windows"))
                                   .Build();
            ITagContext context2 = tagger
                                   .EmptyBuilder
                                   .Put(FRONTEND_KEY, TagValue.Create("front2"))
                                   .Put(FRONTEND_OS_VERSION_KEY, TagValue.Create("1.1.1"))
                                   .Build();

            long sum = 0;

            for (int i = 0; i < 10; i++)
            {
                sum = sum + (25648 * i);
                if (i % 2 == 0)
                {
                    statsRecorder.NewMeasureMap().Put(VIDEO_SIZE, 25648 * i).Record(context1);
                }
                else
                {
                    statsRecorder.NewMeasureMap().Put(VIDEO_SIZE, 25648 * i).Record(context2);
                }
            }

            IViewData videoSizeView  = viewManager.GetView(VIDEO_SIZE_VIEW_NAME);
            var       viewDataAggMap = videoSizeView.AggregationMap.ToList();
            var       view           = viewManager.AllExportedViews.ToList()[0];

            for (int i = 0; i < view.Columns.Count; i++)
            {
                output.WriteLine(view.Columns[i] + "=" + GetTagValues(i, viewDataAggMap));
            }

            var keys = new List <ITagValue>()
            {
                TagValue.Create("1.1.1")
            };

            var results = videoSizeView.AggregationMap.Where((kvp) =>
            {
                foreach (var key in keys)
                {
                    if (!kvp.Key.Values.Contains(key))
                    {
                        return(false);
                    }
                }
                return(true);
            });

            output.WriteLine(videoSizeView.ToString());

            output.WriteLine(sum.ToString());
        }
Exemplo n.º 12
0
 public void TestMeasureLongEquals()
 {
     Assert.Equal(MeasureLong.Create("name", "description", "bit/s"), MeasureLong.Create("name", "description", "bit/s"));
     Assert.NotEqual(MeasureLong.Create("name", "description", "bit/s"), MeasureLong.Create("name", "description 2", "bit/s"));
 }
Exemplo n.º 13
0
 public void TestMeasureDoubleIsNotEqualToMeasureLong()
 {
     Assert.NotEqual(MeasureDouble.Create("name", "description", "bit/s"), (IMeasure)MeasureLong.Create("name", "description", "bit/s"));
 }