@@ -28,13 +28,18 @@ public Fixture()
2828 private readonly Fixture _fixture = new ( ) ;
2929
3030 [ Fact ]
31- public async Task CompleteAsync_CallsInnerClient ( )
31+ public async Task CompleteAsync_CallsInnerClient_AndSetsData ( )
3232 {
3333 // Arrange
34+ var transaction = _fixture . Hub . StartTransaction ( "test-nonstreaming" , "test" ) ;
35+ _fixture . Hub . ConfigureScope ( scope => scope . Transaction = transaction ) ;
36+ SentrySdk . ConfigureScope ( scope => scope . Transaction = transaction ) ;
37+
3438 var inner = Substitute . For < IChatClient > ( ) ;
3539 var sentryChatClient = new SentryChatClient ( inner ) ;
3640 var message = new ChatMessage ( ChatRole . Assistant , "ok" ) ;
3741 var chatResponse = new ChatResponse ( message ) ;
42+
3843 inner . GetResponseAsync ( Arg . Any < IList < ChatMessage > > ( ) , Arg . Any < ChatOptions > ( ) , Arg . Any < CancellationToken > ( ) )
3944 . Returns ( Task . FromResult ( chatResponse ) ) ;
4045
@@ -45,14 +50,20 @@ public async Task CompleteAsync_CallsInnerClient()
4550 Assert . Equal ( [ message ] , res . Messages ) ;
4651 await inner . Received ( 1 ) . GetResponseAsync ( Arg . Any < IList < ChatMessage > > ( ) , Arg . Any < ChatOptions > ( ) ,
4752 Arg . Any < CancellationToken > ( ) ) ;
53+ var spans = transaction . Spans ;
54+ var chatSpan = spans . FirstOrDefault ( s => s . Operation == SentryAIConstants . SpanAttributes . ChatOperation ) ;
55+ Assert . NotNull ( chatSpan ) ;
56+ Assert . Equal ( SpanStatus . Ok , chatSpan . Status ) ;
57+ Assert . True ( chatSpan . IsFinished ) ;
58+ Assert . Equal ( "chat" , chatSpan . Data [ SentryAIConstants . SpanAttributes . OperationName ] ) ;
59+ Assert . Equal ( "ok" , chatSpan . Data [ SentryAIConstants . SpanAttributes . ResponseText ] ) ;
4860 }
4961
5062 [ Fact ]
5163 public async Task CompleteStreamingAsync_CallsInnerClient_AndSetsSpanData ( )
5264 {
5365 // Arrange - Use Fixture Hub to start transaction
5466 var transaction = _fixture . Hub . StartTransaction ( "test-streaming" , "test" ) ;
55-
5667 _fixture . Hub . ConfigureScope ( scope => scope . Transaction = transaction ) ;
5768 SentrySdk . ConfigureScope ( scope => scope . Transaction = transaction ) ;
5869
0 commit comments