perfview icon indicating copy to clipboard operation
perfview copied to clipboard

AutoLogger rolls ETL files in a format not accepted by PerfView

Open jasbury1 opened this issue 3 years ago • 1 comments

AutoLogger can be configured to consume ETW events and publish the results in rolling ETL files with a given MaxFileSize

https://learn.microsoft.com/en-us/windows/win32/etw/configuring-and-starting-an-autologger-session

As the ETL files approach the file size limit, they are rolled in the following pattern:

  • ProviderName.etl.001, ProviderName.etl.002, ProviderName.etl.003, etc.

The presence of the number after the .etl extension means that these files are not recognized by the PerfView application. The user has to manually rename the files to an accepted format. In addition, the library function GetMergeAllLogFiles does not recognize files under the AutoLogger format, which means that consumers of this library are presented with a FileNotFound exception when trying to process these log files programmatically.

jasbury1 avatar Oct 30 '22 20:10 jasbury1

Current file matching:

 List<string> list = new List<string>();
 list.AddRange(Directory.GetFiles(text, fileNameWithoutExtension + ".etl"));
 list.AddRange(Directory.GetFiles(text, fileNameWithoutExtension + ".kernel*.etl"));
 list.AddRange(Directory.GetFiles(text, fileNameWithoutExtension + ".clr*.etl"));
 list.AddRange(Directory.GetFiles(text, fileNameWithoutExtension + ".user*.etl"));

Proposed fix:

var matchStr = @"^[^.]*((\.kernel.*)|(\.clr.*)|(\.user.*))?(\.etl)(\.\d+)?$"
var regex = new Regex(matchStr);
var files = Directory.GetFiles(path)
                .Select(f => regex.Match(f))
                .Where(m => m.Success)
                .Select(m => m.Groups[0].Value)
                .ToList();

jasbury1 avatar Oct 30 '22 23:10 jasbury1