Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TraceEvent: expose timestamps in UTC format #1740

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
39 changes: 31 additions & 8 deletions src/TraceEvent/TraceEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,27 +240,40 @@ public RegisteredTraceEventParser Registered
/// <summary>
/// The time when session started logging.
/// </summary>
public DateTime SessionStartTime
public DateTime SessionStartTime => SessionStartTimeUTC.ToLocalTime();

/// <summary>
/// The time when session started logging in UTC format.
/// </summary>
public DateTime SessionStartTimeUTC => QPCTimeToDateTimeUTC(sessionStartTimeQPC);


/// <summary>
/// The time that the session stopped logging.
/// </summary>
public DateTime SessionEndTime
{
get
{
var ret = QPCTimeToDateTimeUTC(sessionStartTimeQPC);
return ret.ToLocalTime();
var ret = SessionEndTimeUTC.ToLocalTime();
Debug.Assert(SessionStartTime <= ret);
return ret;
}
}

/// <summary>
/// The time that the session stopped logging.
/// </summary>
public DateTime SessionEndTime
public DateTime SessionEndTimeUTC
{
get
{
var ret = QPCTimeToDateTimeUTC(sessionEndTimeQPC).ToLocalTime();
Debug.Assert(SessionStartTime <= ret);
var ret = QPCTimeToDateTimeUTC(sessionEndTimeQPC);
Debug.Assert(SessionStartTimeUTC <= ret);
return ret;
}
}

/// <summary>
/// The Session End time expressed as milliseconds from the start of the session
/// </summary>
Expand All @@ -277,7 +290,7 @@ public double SessionEndTimeRelativeMSec
/// <summary>
/// The difference between SessionEndTime and SessionStartTime;
/// </summary>
public TimeSpan SessionDuration { get { return SessionEndTime - SessionStartTime; } }
public TimeSpan SessionDuration { get { return SessionEndTimeUTC - SessionStartTimeUTC; } }

/// <summary>
/// The size of the trace, if it is known. Will return 0 if it is not known.
Expand Down Expand Up @@ -797,8 +810,18 @@ public TraceEventChannel Channel
/// </summary>
public DateTime TimeStamp
{
get { return traceEventSource.QPCTimeToDateTimeUTC(TimeStampQPC).ToLocalTime(); }
get { return TimeStampUTC.ToLocalTime(); }
}

/// <summary>
/// The time of the event in UTC format. This has much lower overhead than TimeStamp
/// because it saves a timezone conversion.
/// </summary>
public DateTime TimeStampUTC
{
get { return traceEventSource.QPCTimeToDateTimeUTC(TimeStampQPC); }
}

/// <summary>
/// Returns a double representing the number of milliseconds since the beginning of the session.
/// </summary>
Expand Down