Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Add EventPipe Config File Option MultiFileSec #20548

Merged
merged 5 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Simplify trace naming logic.
  • Loading branch information
brianrob committed Oct 24, 2018
commit e5990384a7be60995a1fee248c27b40dda205fa0
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private static EventPipeConfiguration BuildConfigFromFile(string configFilePath)
}

// Build the full path to the trace file.
string traceFileName = BuildTraceFileName(multiFileSec > 0);
string traceFileName = BuildTraceFileName();
string outputFile = Path.Combine(outputPath, traceFileName);

// Get the circular buffer size.
Expand Down Expand Up @@ -252,7 +252,7 @@ private static EventPipeConfiguration BuildConfigFromFile(string configFilePath)
private static EventPipeConfiguration BuildConfigFromEnvironment()
{
// Build the full path to the trace file.
string traceFileName = BuildTraceFileName(false);
string traceFileName = BuildTraceFileName();
string outputFilePath = Path.Combine(Config_EventPipeOutputPath, traceFileName);

// Create a new configuration object.
Expand Down Expand Up @@ -281,19 +281,9 @@ private static string BuildConfigFileName()
return GetAppName() + ConfigFileSuffix;
}

private static string BuildTraceFileName(bool multiFile)
private static string BuildTraceFileName()
{
string traceFileName;
if (multiFile)
{
traceFileName = GetAppName() + "." + Win32Native.GetCurrentProcessId();
}
else
{
traceFileName = GetAppName() + "." + Win32Native.GetCurrentProcessId() + NetPerfFileExtension;
}

return traceFileName;
return GetAppName() + "." + Win32Native.GetCurrentProcessId() + NetPerfFileExtension;
}

private static string GetAppName()
Expand Down
12 changes: 10 additions & 2 deletions src/vm/eventpipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,21 @@ void EventPipe::GetNextFilePath(EventPipeSession *pSession, SString &nextTraceFi
}
CONTRACTL_END;

// If multiFileTraceLengthInSeconds == 0 then s_pOutputPath is the full path to the trace file.
// Otherwise s_pOutputPath is the path and base name of the trace file. It needs the file index and suffix appended to it to produce the fill path.
// Set the full path to the requested trace file as the next file path.
nextTraceFilePath.Set(s_pOutputPath);

// If multiple files have been requested, then add a sequence number to the trace file name.
UINT64 multiFileTraceLengthInSeconds = pSession->GetMultiFileTraceLengthInSeconds();
if(multiFileTraceLengthInSeconds > 0)
{
// Remove the ".netperf" file extension if it exists.
SString::Iterator netPerfExtension = nextTraceFilePath.End();
if(nextTraceFilePath.FindBack(netPerfExtension, W(".netperf")))
{
nextTraceFilePath.Truncate(netPerfExtension);
}

// Add the sequence number and the ".netperf" file extension.
WCHAR strNextIndex[21];
swprintf_s(strNextIndex, 21, W(".%u.netperf"), s_nextFileIndex++);
nextTraceFilePath.Append(strNextIndex);
Expand Down