コード例 #1
0
        private async Task FlushCoreAsync()
        {
            await FlushTimelineAggregateAsync(true);
            await FlushIntancesAsync(true);

            if (_container != null)
            {
                await _instanceLogger.StopAsync();

                await _container.StopAsync();
            }
        }
コード例 #2
0
        public async Task FunctionInstance()
        {
            var table = GetNewLoggingTable();

            try
            {
                ILogReader reader = LogFactory.NewReader(table);
                TimeSpan   poll   = TimeSpan.FromMilliseconds(50);
                TimeSpan   poll5  = TimeSpan.FromMilliseconds(poll.TotalMilliseconds * 5);

                var logger1 = new CloudTableInstanceCountLogger("c1", table, 100)
                {
                    PollingInterval = poll
                };

                Guid g1 = Guid.NewGuid();

                DateTime startTime = DateTime.UtcNow;
                logger1.Increment(g1);
                await Task.Delay(poll5); // should get at least 1 poll entry in

                logger1.Decrement(g1);
                await Task.WhenAll(logger1.StopAsync());

                DateTime endTime = DateTime.UtcNow;

                // Now read.
                // We may get an arbitrary number of raw poll entries since the
                // low poll latency combined with network delay can be unpredictable.
                var values = await reader.GetVolumeAsync(startTime, endTime, 1);

                double totalVolume = (from value in values select value.Volume).Sum();
                Assert.True(totalVolume > 0);

                double totalInstance = (from value in values select value.InstanceCounts).Sum();
                Assert.Equal(1, totalInstance);
            }
            finally
            {
                table.DeleteIfExists();
            }
        }