Esempio n. 1
0
        /// <summary>
        /// Add a filter by Event Type
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public ReadFilter CombineFilter(ReadFilter filter)
        {
            Assert.IsNotNull(filter, "filter != null");
            foreach (var oneTraceRecordFilter in filter.TraceRecordFilters)
            {
                this.TraceRecordFilters.Add(oneTraceRecordFilter);
            }

            return(this);
        }
Esempio n. 2
0
 public Task <IEnumerable <TraceRecord> > ReadBackwardAsync(ReadFilter filter, int count, CancellationToken token)
 {
     return(this.ReadRecordsAsync(filter, count, false, token));
 }
Esempio n. 3
0
        private async Task <IEnumerable <TraceRecord> > ReadRecordsAsync(ReadFilter filter, int count, bool forwardDirection, CancellationToken token)
        {
            var iterationStartTime = this.boundStart;
            var iterationEndTime   = this.boundEnd;
            var traceResults       = new List <TraceRecord>();
            var timeSpanIncrement  = StartingQueryInterval;

            while (true)
            {
                if (forwardDirection)
                {
                    iterationEndTime = iterationStartTime + timeSpanIncrement;
                    if (iterationEndTime > this.boundEnd)
                    {
                        iterationEndTime = this.boundEnd;
                    }
                }
                else
                {
                    iterationStartTime = iterationEndTime - timeSpanIncrement;
                    if (iterationStartTime < this.boundStart)
                    {
                        iterationStartTime = this.boundStart;
                    }
                }

                if (iterationStartTime >= iterationEndTime)
                {
                    break;
                }

                var results = await this.traceStoreReader.ReadTraceRecordsAsync(new Common.Duration(iterationStartTime, iterationEndTime), filter, token).ConfigureAwait(false);

                traceResults.AddRange(results);

                // We already have enough results.
                if (traceResults.Count >= count)
                {
                    break;
                }

                // Double the query interval with each iteration
                timeSpanIncrement = TimeSpan.FromTicks(timeSpanIncrement.Ticks * 2);

                if (forwardDirection)
                {
                    iterationStartTime = iterationEndTime;
                }
                else
                {
                    iterationEndTime = iterationStartTime;
                }
            }

            if (forwardDirection)
            {
                return(traceResults.Take(count).OrderBy(item => item.TimeStamp));
            }
            else
            {
                return(traceResults.Take(count).OrderByDescending(item => item.TimeStamp));
            }
        }
Esempio n. 4
0
 public async Task <TraceRecord> ReadBackwardSingleAsync(ReadFilter filter, CancellationToken token)
 {
     return((await this.ReadBackwardAsync(filter, 1, token).ConfigureAwait(false)).SingleOrDefault());
 }