Microsoft.ApplicationInsights.Extensibility.MetricManager.Flush()

Here are the examples of the csharp api class Microsoft.ApplicationInsights.Extensibility.MetricManager.Flush() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

7 Examples 7

1. Example

Project: ApplicationInsights-SDK-Labs
Source File: MetricManagerTests.cs
[TestCategory(TestCategoryNames.NeedsAggregationCycleCompletion)]
        [TestMethod]
        publi/n ..... /n //View Source file for more details /n }

2. Example

Project: ApplicationInsights-SDK-Labs
Source File: MetricSeriesTests.cs
[TestCategory(TestCategoryNames.NeedsAggregationCycleCompletion)]
        [TestMethod]
        publi/n ..... /n //View Source file for more details /n }

3. Example

Project: ApplicationInsights-SDK-Labs
Source File: TelemetryConfigurationExtensionsTests.cs
private static void Metrics_SpecifiedPipeline(TelemetryConfiguration telemetryPipeline)
        { 
 /n ..... /n //View Source file for more details /n }

4. Example

Project: ApplicationInsights-dotnet
Source File: MetricManager.cs
public void Dispose()
        {
            this.snapshotTimer.Dispose();
            this.Flush();
        }

5. Example

Project: ApplicationInsights-SDK-Labs
Source File: MetricTests.cs
[TestCategory(TestCategoryNames.NeedsAggregationCycleCompletion)]
        [TestMethod]
        publi/n ..... /n //View Source file for more details /n }

6. Example

Project: ApplicationInsights-dotnet
Source File: MetricManagerTest.cs
[TestMethod]
        public void FlushCreatesAggregatedMetricTelemetry()
        {
            // Arrange
            var sentTelemetry = new List<ITelemetry>();

            var client = this.InitializeTelemetryClient(sentTelemetry);
            using (MetricManager manager = new MetricManager(client))
            {
                Metric metric = manager.CreateMetric("Test Metric");

                metric.Track(42);

                // Act
                manager.Flush();

                // Assert
                Assert.AreEqual(1, sentTelemetry.Count);

                var aggregatedMetric = (MetricTelemetry)sentTelemetry.Single();
                Assert.IsNotNull(aggregatedMetric);
            }
        }

7. Example

Project: ApplicationInsights-dotnet
Source File: MetricManagerTest.cs
[TestMethod]
        public void EqualMetricsAreCombinedIntoSignleAggregatedStatsStructure()
        {
            // Arrange
            var sentTelemetry = new List<ITelemetry>();

            var client = this.InitializeTelemetryClient(sentTelemetry);

            Metric metric1 = null;
            Metric metric2 = null;

            using (MetricManager manager = new MetricManager(client))
            {
                // note: on first go aggregators may be different because manager may
                // snapshot after first got created but before the second
                for (int i = 0; i < 2; i++)
                {
                    metric1 = manager.CreateMetric("Test Metric");
                    metric2 = manager.CreateMetric("Test Metric");

                    // Act
                    metric1.Track(10);
                    metric2.Track(5);

                    manager.Flush();

                    if (sentTelemetry.Count == 1)
                    {
                        break;
                    }
                    else
                    {
                        sentTelemetry.Clear();
                    }
                }
            }

            // Assert
            Assert.AreEqual(1, sentTelemetry.Count);

            var aggregatedMetric = (MetricTelemetry)sentTelemetry.Single();

            Assert.AreEqual(2, aggregatedMetric.Count);
            Assert.AreEqual(15, aggregatedMetric.Sum);
        }