File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
test/Sentry.Tests/Protocol Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## Unreleased
4+
5+ ### Fixes
6+
7+ - Unfinished spans are now correctly stored and retrieved by the CachingTransport ([ #3533 ] ( https://github.com/getsentry/sentry-dotnet/pull/3533 ) )
8+
39## 4.10.0
410
511### Features
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ public static SentrySpan FromJson(JsonElement json)
154154 var parentSpanId = json . GetPropertyOrNull ( "parent_span_id" ) ? . Pipe ( SpanId . FromJson ) ;
155155 var traceId = json . GetPropertyOrNull ( "trace_id" ) ? . Pipe ( SentryId . FromJson ) ?? SentryId . Empty ;
156156 var startTimestamp = json . GetProperty ( "start_timestamp" ) . GetDateTimeOffset ( ) ;
157- var endTimestamp = json . GetProperty ( "timestamp" ) . GetDateTimeOffset ( ) ;
157+ var endTimestamp = json . GetPropertyOrNull ( "timestamp" ) ? . GetDateTimeOffset ( ) ;
158158 var operation = json . GetPropertyOrNull ( "op" ) ? . GetString ( ) ?? "unknown" ;
159159 var description = json . GetPropertyOrNull ( "description" ) ? . GetString ( ) ;
160160 var status = json . GetPropertyOrNull ( "status" ) ? . GetString ( ) ? . Replace ( "_" , "" ) . ParseEnum < SpanStatus > ( ) ;
Original file line number Diff line number Diff line change @@ -246,6 +246,27 @@ public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()
246246 } ) ;
247247 }
248248
249+ [ Fact ]
250+ public void SerializeObject_TransactionContainsUnfinishedSpan_SerializesDeserializesValidObject ( )
251+ {
252+ // Arrange
253+ SentryTransaction capturedTransaction = null ;
254+ var hub = Substitute . For < IHub > ( ) ;
255+ hub . CaptureTransaction ( Arg . Do < SentryTransaction > ( t => capturedTransaction = t ) ) ;
256+
257+ var transaction = new TransactionTracer ( hub , "test.name" , "test.operation" ) ;
258+ transaction . StartChild ( "child_op123" , "child_desc123" ) ;
259+ transaction . Finish ( SpanStatus . Aborted ) ;
260+
261+ // Act
262+ var actualString = capturedTransaction . ToJsonString ( _testOutputLogger ) ;
263+ var actualTransaction = Json . Parse ( actualString , SentryTransaction . FromJson ) ;
264+
265+ // Assert
266+ Assert . Single ( actualTransaction . Spans ) ; // Sanity Check
267+ Assert . Null ( actualTransaction . Spans . First ( ) . EndTimestamp ) ;
268+ }
269+
249270 [ Fact ]
250271 public void StartChild_LevelOne_Works ( )
251272 {
You can’t perform that action at this time.
0 commit comments