public void GetMetricsForExportedViews_ReturnsExpected() { var opts = new CloudFoundryForwarderOptions() { MicrometerMetricWriter = true }; var stats = new OpenCensusStats(); var tagsComponent = new TagsComponent(); var tagger = tagsComponent.Tagger; var ep = new CloudFoundryForwarderExporter(opts, stats); IMeasureDouble testMeasure = MeasureDouble.Create("test.total", "test", MeasureUnit.Bytes); SetupTestView(stats, Sum.Create(), testMeasure, "test.test1"); ITagContext context1 = tagger .EmptyBuilder .Put(TagKey.Create("a"), TagValue.Create("v1")) .Put(TagKey.Create("b"), TagValue.Create("v1")) .Put(TagKey.Create("c"), TagValue.Create("v1")) .Build(); long allKeyssum = 0; for (int i = 0; i < 10; i++) { allKeyssum = allKeyssum + i; stats.StatsRecorder.NewMeasureMap().Put(testMeasure, i).Record(context1); } var result = ep.GetMetricsForExportedViews(stats.ViewManager.AllExportedViews, 1L); Assert.NotNull(result); Assert.Single(result); var metric = result[0]; Assert.Equal("test.test1", metric.Name); Assert.Equal(1L, metric.Timestamp); Assert.Equal("gauge", metric.Type); Assert.Equal("bytes", metric.Unit); Assert.Equal(allKeyssum, metric.Value); var tags = metric.Tags; Assert.Equal("total", tags["statistic"]); Assert.Equal("v1", tags["a"]); Assert.Equal("v1", tags["b"]); Assert.Equal("v1", tags["c"]); }