22using System . Collections . Concurrent ;
33using System . Collections . Generic ;
44using System . Linq ;
5+ using Sentry . Internal ;
56
67namespace Sentry
78{
@@ -11,6 +12,7 @@ namespace Sentry
1112 public class TransactionTracer : ITransaction
1213 {
1314 private readonly IHub _hub ;
15+ private readonly SentryStopwatch _stopwatch = SentryStopwatch . StartNew ( ) ;
1416
1517 /// <inheritdoc />
1618 public SpanId SpanId
@@ -50,7 +52,7 @@ public SentryId TraceId
5052 public string ? Release { get ; set ; }
5153
5254 /// <inheritdoc />
53- public DateTimeOffset StartTimestamp { get ; } = DateTimeOffset . UtcNow ;
55+ public DateTimeOffset StartTimestamp => _stopwatch . StartDateTimeOffset ;
5456
5557 /// <inheritdoc />
5658 public DateTimeOffset ? EndTimestamp { get ; internal set ; }
@@ -170,8 +172,10 @@ public TransactionTracer(IHub hub, string name, string operation)
170172 /// Initializes an instance of <see cref="Transaction"/>.
171173 /// </summary>
172174 public TransactionTracer ( IHub hub , ITransactionContext context )
173- : this ( hub , context . Name , context . Operation )
174175 {
176+ _hub = hub ;
177+ Name = context . Name ;
178+ Operation = context . Operation ;
175179 SpanId = context . SpanId ;
176180 ParentSpanId = context . ParentSpanId ;
177181 TraceId = context . TraceId ;
@@ -224,7 +228,7 @@ public ISpan StartChild(string operation) =>
224228 public void Finish ( )
225229 {
226230 Status ??= SpanStatus . UnknownError ;
227- EndTimestamp = DateTimeOffset . UtcNow ;
231+ EndTimestamp = _stopwatch . CurrentDateTimeOffset ;
228232
229233 foreach ( var span in _spans )
230234 {
0 commit comments