Exemple #1
0
 public static void HydrateTraceMeasurements(this MeasurementStore store, MeasuredTrace measuredTrace)
 {
     // TODO Go back to dynamically discovering types rather than using hard coded list. For now this works better with EF
     // TODO Move filtering to db engine rather than client side. This is super inneficient, but working around EF
     foreach (var m in store.Set <CpuSampled>().Include(m => m.Trace).Where(m => string.Equals(m.Trace.PackageFileName, measuredTrace.PackageFileName, StringComparison.OrdinalIgnoreCase)))
     {
         measuredTrace.AddMeasurement(m);
     }
     foreach (var m in store.Set <BootPhase>().Include(m => m.Trace).Where(m => string.Equals(m.Trace.PackageFileName, measuredTrace.PackageFileName, StringComparison.OrdinalIgnoreCase)))
     {
         measuredTrace.AddMeasurement(m);
     }
     foreach (var m in store.Set <WinlogonSubscriberTask>().Include(m => m.Trace).Where(m => string.Equals(m.Trace.PackageFileName, measuredTrace.PackageFileName, StringComparison.OrdinalIgnoreCase)))
     {
         measuredTrace.AddMeasurement(m);
     }
     foreach (var m in store.Set <DiskIo>().Include(m => m.Trace).Where(m => string.Equals(m.Trace.PackageFileName, measuredTrace.PackageFileName, StringComparison.OrdinalIgnoreCase)))
     {
         measuredTrace.AddMeasurement(m);
     }
     foreach (var m in store.Set <LogicalDisk>().Include(m => m.Trace).Where(m => string.Equals(m.Trace.PackageFileName, measuredTrace.PackageFileName, StringComparison.OrdinalIgnoreCase)))
     {
         measuredTrace.AddMeasurement(m);
     }
     foreach (var m in store.Set <PhysicalDisk>().Include(m => m.Trace).Where(m => string.Equals(m.Trace.PackageFileName, measuredTrace.PackageFileName, StringComparison.OrdinalIgnoreCase)))
     {
         measuredTrace.AddMeasurement(m);
     }
     foreach (var m in store.Set <TraceAttribute>().Include(m => m.Trace).Where(m => string.Equals(m.Trace.PackageFileName, measuredTrace.PackageFileName, StringComparison.OrdinalIgnoreCase)))
     {
         measuredTrace.AddMeasurement(m);
     }
 }
Exemple #2
0
 public static void HydrateTraceMeasurements <TMeasurement>(this MeasurementStore store,
                                                            MeasuredTrace measuredTrace) where TMeasurement : class, IMeasurement
 {
     foreach (var mm in store.Set <TMeasurement>().Include(m => m.Trace).Where(m => m.Trace == measuredTrace))
     {
         measuredTrace.AddMeasurement(mm);
     }
 }
Exemple #3
0
        public static int DiscoverOneBatch(ProcessingConfig processingConfig, MeasurementStoreConfig storeConfig)
        {
            var totalDiscoveries = 0;

            using (var store = new MeasurementStore(storeConfig))
            {
                foreach (var incomingDataPath in processingConfig.IncomingDataPaths)
                {
                    var discoveredCount = 0;
                    RichLog.Log.StartDiscoverFiles(incomingDataPath);
                    foreach (var filter in processingConfig.IncomingFilePatterns)
                    {
                        foreach (
                            var fileSystemEntryPath in
                            Directory.EnumerateFileSystemEntries(incomingDataPath, filter,
                                                                 SearchOption.AllDirectories))
                        {
                            var fileInfo    = new FileInfo(fileSystemEntryPath);
                            var sparseTrace = new MeasuredTrace
                            {
                                PackageFileName     = fileInfo.Name,
                                PackageFileNameFull =
                                    CalculateDestinationPath(fileSystemEntryPath, processingConfig, true)
                            };
                            if (!store.Traces.Any(t => t.IsSameDataPackage(sparseTrace)))
                            {
                                store.Traces.Add(sparseTrace);
                                store.SaveChanges();
                            }
                            var dbTrace = store.Traces.Include(t => t.ProcessingRecords).First(t => t.IsSameDataPackage(sparseTrace));
                            var lastPr  = dbTrace.ProcessingRecords.Latest();
                            if (lastPr == null || lastPr.ProcessingState != ProcessingState.Discovered)
                            {
                                store.Set <ProcessingRecord>().Add(new ProcessingRecord
                                {
                                    MeasuredTrace   = dbTrace,
                                    ProcessingState = ProcessingState.Discovered,
                                    StateChangeTime = DateTime.UtcNow,
                                    Path            = fileSystemEntryPath
                                });
                                store.SaveChanges();
                                discoveredCount++;
                                totalDiscoveries++;
                            }
                        }
                    }
                    RichLog.Log.StopDiscoverFiles(incomingDataPath, discoveredCount);
                }
            }
            return(totalDiscoveries);
        }
        public int SaveTraceAndMeasurements(MeasuredTrace measuredTrace)
        {
            var changeCount = 0;

            if (
                Traces.Any(
                    t =>
                    string.Equals(t.PackageFileName, measuredTrace.PackageFileName,
                                  StringComparison.OrdinalIgnoreCase)))
            {
                Traces.Update(measuredTrace);
            }
            else
            {
                Traces.Add(measuredTrace);
            }
            changeCount += SaveChanges();
            foreach (var m in measuredTrace.GetMeasurementsAll())
            {
                AddMeasurementByTypeInfer(m);
            }
            changeCount += SaveChanges();
            return(changeCount);
        }
Exemple #5
0
 public static MeasuredTrace GetTraceWithRecordsFromSparseTrace(this MeasurementStore store, MeasuredTrace measuredTrace)
 {
     return
         (store.Traces.Include(t => t.ProcessingRecords)
          .Where(t => t.IsSameDataPackage(measuredTrace))
          .SingleOrDefault());
 }