private async Task <FabricEvent> GetPartitionEventsAsync(Duration duration, Guid instanceId, CancellationToken token) { var records = await this.traceStoreReader.ReadTraceRecordsAsync( duration, ReadFilter.CreateReadFilter(Mapping.EntityToEventsMap[EntityType.Partition].Select(item => item.UnderlyingType).ToList()), token).ConfigureAwait(false); var recordOfInterest = records.SingleOrDefault(item => item.ObjectInstanceId?.Id == instanceId); if (recordOfInterest != null) { return(PartitionEventAdapter.Convert(recordOfInterest)); } return(null); }
public async Task <IList <PartitionEvent> > GetPartitionEventsAsync(Guid partitionId, Duration duration, IList <Type> types, CancellationToken token) { await this.InitIfRequiredAsync(token).ConfigureAwait(false); var filter = FilterFactory.CreatePartitionFilter(this.traceStoreReader, types, partitionId); var allPartitionEvents = (await this.traceStoreReader.ReadTraceRecordsAsync(duration, filter, token).ConfigureAwait(false)).Select(oneRecord => PartitionEventAdapter.Convert(oneRecord)).ToList(); if (!this.traceStoreReader.IsPropertyLevelFilteringSupported() && partitionId != Guid.Empty) { allPartitionEvents = allPartitionEvents.Where(oneEvent => oneEvent.PartitionId == partitionId).ToList(); } // Today, only partition Events have correlation feature available, so we call decorate only for them. Subject to change in future. await this.DecorateCorrelationAttributeAsync(duration, allPartitionEvents.Cast <FabricEvent>().ToList(), token); return(allPartitionEvents); }