private void WritePartitionExecutionTimeline(ClientSideMetrics clientSideMetrics)
        {
            this.WriteBeforePartitionExecutionTimeline();

            foreach (FetchExecutionRange fetchExecutionRange in clientSideMetrics.FetchExecutionRanges.OrderBy(fetchExecutionRange => fetchExecutionRange.StartTime))
            {
                this.WriteFetchExecutionRange(fetchExecutionRange);
            }

            this.WriteAfterPartitionExecutionTimeline();
        }
        private void WriteClientSideMetrics(ClientSideMetrics clientSideMetrics)
        {
            this.WriteBeforeClientSideMetrics();

            this.WriteRetries(clientSideMetrics.Retries);
            this.WriteRequestCharge(clientSideMetrics.RequestCharge);
            this.WritePartitionExecutionTimeline(clientSideMetrics);
            this.WriteSchedulingMetrics(clientSideMetrics);

            this.WriteAfterClientSideMetrics();
        }
예제 #3
0
        internal QueryMetrics(
            List <Guid> activityIds,
            long retrievedDocumentCount,
            long retrievedDocumentSize,
            long outputDocumentCount,
            long outputDocumentSize,
            long indexHitDocumentCount,
            TimeSpan totalQueryExecutionTime,
            QueryPreparationTimes queryPreparationTimes,
            TimeSpan indexLookupTime,
            TimeSpan documentLoadTime,
            TimeSpan vmExecutionTime,
            RuntimeExecutionTimes runtimeExecutionTimes,
            TimeSpan documentWriteTime,
            ClientSideMetrics clientSideMetrics)
        {
            if (activityIds == null)
            {
                throw new ArgumentNullException($"{nameof(activityIds)} can not be null.");
            }

            if (queryPreparationTimes == null)
            {
                throw new ArgumentNullException($"{nameof(queryPreparationTimes)} can not be null.");
            }

            if (runtimeExecutionTimes == null)
            {
                throw new ArgumentNullException($"{nameof(runtimeExecutionTimes)} can not be null.");
            }

            if (clientSideMetrics == null)
            {
                throw new ArgumentNullException($"{nameof(clientSideMetrics)} can not be null.");
            }

            this.ActivityIds             = activityIds;
            this.RetrievedDocumentCount  = retrievedDocumentCount;
            this.RetrievedDocumentSize   = retrievedDocumentSize;
            this.OutputDocumentCount     = outputDocumentCount;
            this.OutputDocumentSize      = outputDocumentSize;
            this.IndexHitDocumentCount   = indexHitDocumentCount;
            this.TotalQueryExecutionTime = totalQueryExecutionTime;
            this.QueryPreparationTimes   = queryPreparationTimes;
            this.IndexLookupTime         = indexLookupTime;
            this.DocumentLoadTime        = documentLoadTime;
            this.VMExecutionTime         = vmExecutionTime;
            this.RuntimeExecutionTimes   = runtimeExecutionTimes;
            this.DocumentWriteTime       = documentWriteTime;
            this.ClientSideMetrics       = clientSideMetrics;
        }
        private void WriteSchedulingMetrics(ClientSideMetrics clientSideMetrics)
        {
            this.WriteBeforeSchedulingMetrics();

            foreach (Tuple <string, SchedulingTimeSpan> partitionSchedulingTimeSpan in clientSideMetrics.PartitionSchedulingTimeSpans.OrderBy(x => x.Item2.ResponseTime))
            {
                string             partitionId        = partitionSchedulingTimeSpan.Item1;
                SchedulingTimeSpan schedulingTimeSpan = partitionSchedulingTimeSpan.Item2;

                this.WritePartitionSchedulingTimeSpan(partitionId, schedulingTimeSpan);
            }

            this.WriteAfterSchedulingMetrics();
        }
예제 #5
0
        /// <summary>
        /// Creates a new QueryMetrics that is the sum of all elements in an IEnumerable.
        /// </summary>
        /// <param name="queryMetricsList">The IEnumerable to aggregate.</param>
        /// <returns>A new QueryMetrics that is the sum of all elements in an IEnumerable.</returns>
        internal static QueryMetrics CreateFromIEnumerable(IEnumerable <QueryMetrics> queryMetricsList)
        {
            if (queryMetricsList == null)
            {
                throw new ArgumentNullException("queryMetricsList");
            }

            List <Guid> activityIds             = new List <Guid>();
            long        retrievedDocumentCount  = 0;
            long        retrievedDocumentSize   = 0;
            long        outputDocumentCount     = 0;
            long        outputDocumentSize      = 0;
            long        indexHitDocumentCount   = 0;
            TimeSpan    totalQueryExecutionTime = new TimeSpan();
            List <QueryPreparationTimes> queryPreparationTimesList = new List <QueryPreparationTimes>();
            TimeSpan indexLookupTime  = new TimeSpan();
            TimeSpan documentLoadTime = new TimeSpan();
            TimeSpan vmExecutionTime  = new TimeSpan();
            List <RuntimeExecutionTimes> runtimeExecutionTimesList = new List <RuntimeExecutionTimes>();
            TimeSpan documentWriteTime = new TimeSpan();
            List <ClientSideMetrics> clientSideMetricsList = new List <ClientSideMetrics>();

            foreach (QueryMetrics queryMetrics in queryMetricsList)
            {
                if (queryMetrics == null)
                {
                    throw new ArgumentNullException("queryMetricsList can not have null elements");
                }

                activityIds              = activityIds.Concat(queryMetrics.ActivityIds.Where((activityId) => activityId != Guid.Empty)).ToList();
                retrievedDocumentCount  += queryMetrics.RetrievedDocumentCount;
                retrievedDocumentSize   += queryMetrics.RetrievedDocumentSize;
                outputDocumentCount     += queryMetrics.OutputDocumentCount;
                outputDocumentSize      += queryMetrics.OutputDocumentSize;
                indexHitDocumentCount   += queryMetrics.IndexHitDocumentCount;
                totalQueryExecutionTime += queryMetrics.TotalQueryExecutionTime;
                queryPreparationTimesList.Add(queryMetrics.QueryPreparationTimes);
                indexLookupTime  += queryMetrics.IndexLookupTime;
                documentLoadTime += queryMetrics.DocumentLoadTime;
                vmExecutionTime  += queryMetrics.VMExecutionTime;
                runtimeExecutionTimesList.Add(queryMetrics.RuntimeExecutionTimes);
                documentWriteTime += queryMetrics.DocumentWriteTime;
                clientSideMetricsList.Add(queryMetrics.ClientSideMetrics);
            }

            return(new QueryMetrics(
                       activityIds,
                       retrievedDocumentCount,
                       retrievedDocumentSize,
                       outputDocumentCount,
                       outputDocumentSize,
                       indexHitDocumentCount,
                       totalQueryExecutionTime,
                       QueryPreparationTimes.CreateFromIEnumerable(queryPreparationTimesList),
                       indexLookupTime,
                       documentLoadTime,
                       vmExecutionTime,
                       RuntimeExecutionTimes.CreateFromIEnumerable(runtimeExecutionTimesList),
                       documentWriteTime,
                       ClientSideMetrics.CreateFromIEnumerable(clientSideMetricsList)));
        }