Exemple #1
0
        // Could be very long
        public async Task <Segment <IRecentFunctionEntry> > GetRecentFunctionInstancesAsync(
            RecentFunctionQuery queryParams,
            string continuationToken)
        {
            TableQuery <RecentPerFuncEntity> rangeQuery = RecentPerFuncEntity.GetRecentFunctionsQuery(queryParams);

            var iter = await EpochTableIterator.NewAsync(_tableLookup);

            var results = await iter.SafeExecuteQuerySegmentedAsync <RecentPerFuncEntity>(rangeQuery, queryParams.Start, queryParams.End);

            return(results.As <IRecentFunctionEntry>());
        }
Exemple #2
0
        public async Task <Segment <IAggregateEntry> > GetAggregateStatsAsync(FunctionId functionId, DateTime start, DateTime end, string continuationToken)
        {
            functionId.Validate();
            if (start > end)
            {
                throw new ArgumentOutOfRangeException("start");
            }

            var iter = await EpochTableIterator.NewAsync(_tableLookup);

            var rangeQuery = TimelineAggregateEntity.GetQuery(functionId, start, end);

            var results = await iter.SafeExecuteQuerySegmentedAsync <TimelineAggregateEntity>(rangeQuery, start, end);

            return(results.As <IAggregateEntry>());
        }
Exemple #3
0
        public async Task <FunctionVolumeTimelineEntry[]> GetVolumeAsync(DateTime startTime, DateTime endTime, int numberBuckets)
        {
            var query = InstanceCountEntity.GetQuery(startTime, endTime);

            var iter = await EpochTableIterator.NewAsync(_tableLookup);

            var results = await iter.SafeExecuteQuerySegmentedAsync <InstanceCountEntity>(query, startTime, endTime);

            InstanceCountEntity[] rows = results.Results;

            var startTicks = startTime.Ticks;
            var endTicks   = endTime.Ticks;
            var data       = ProjectionHelper.Work(rows, startTicks, endTicks, numberBuckets);

            int[]  totalCounts      = new int[numberBuckets];
            double bucketWidthTicks = ((double)(endTicks - startTicks)) / numberBuckets;

            foreach (var row in rows)
            {
                int idx = (int)((row.GetTicks() - startTicks) / bucketWidthTicks);
                if (idx >= 0 && idx < numberBuckets)
                {
                    totalCounts[idx] += row.TotalThisPeriod;
                }
            }

            // coerce data
            var chart = new FunctionVolumeTimelineEntry[numberBuckets];

            for (int i = 0; i < numberBuckets; i++)
            {
                var    ticks = data[i].Item1;
                var    time  = new DateTime(ticks);
                double value = data[i].Item2;
                chart[i] = new FunctionVolumeTimelineEntry
                {
                    Time           = time,
                    Volume         = value,
                    InstanceCounts = totalCounts[i]
                };
            }

            return(chart);
        }
Exemple #4
0
        public async Task <Segment <ActivationEvent> > GetActiveContainerTimelineAsync(DateTime start, DateTime end, string continuationToken)
        {
            var query = ContainerActiveEntity.GetQuery(start, end);

            var iter = await EpochTableIterator.NewAsync(_tableLookup);

            var segment = await iter.SafeExecuteQuerySegmentedAsync <ContainerActiveEntity>(
                query, start, end);

            var results = segment.Results;

            List <ActivationEvent>      l      = new List <ActivationEvent>();
            Dictionary <string, string> intern = new Dictionary <string, string>();

            foreach (var result in results)
            {
                var    name = result.GetContainerName();
                string internedName;
                if (!intern.TryGetValue(name, out internedName))
                {
                    intern[name] = name;
                    internedName = name;
                }

                var timeBucket = result.GetStartBucket();
                l.Add(new ActivationEvent
                {
                    ContainerName   = name,
                    StartTimeBucket = timeBucket,
                    StartTime       = TimeBucket.ConvertToDateTime(timeBucket),
                    Length          = result.GetLength()
                });
            }

            return(new Segment <ActivationEvent>(l.ToArray(), null));
        }