@@ -42,7 +42,9 @@ public abstract class StreamTransformerBase(ILogger logger) : IStreamTransformer
4242
4343 public Task < Stream > TransformAsync ( Stream rawStream , CancellationToken cancellationToken = default )
4444 {
45- using var activity = StreamTransformerActivitySource . StartActivity ( "gen_ai.agent" ) ;
45+ using var activity = StreamTransformerActivitySource . StartActivity ( $ "chat { GetAgentId ( ) } ", ActivityKind . Client ) ;
46+ _ = ( activity ? . SetTag ( "gen_ai.operation.name" , "chat" ) ) ;
47+ _ = ( activity ? . SetTag ( "gen_ai.request.model" , GetAgentId ( ) ) ) ;
4648 _ = ( activity ? . SetTag ( "gen_ai.agent.name" , GetAgentId ( ) ) ) ;
4749 _ = ( activity ? . SetTag ( "gen_ai.provider.name" , GetAgentProvider ( ) ) ) ;
4850
@@ -74,7 +76,7 @@ public Task<Stream> TransformAsync(Stream rawStream, CancellationToken cancellat
7476 /// </summary>
7577 private async Task ProcessPipeAsync ( PipeReader reader , PipeWriter writer , Activity ? parentActivity , CancellationToken cancellationToken )
7678 {
77- using var activity = StreamTransformerActivitySource . StartActivity ( "StreamTransformer.ProcessPipeAsync " ) ;
79+ using var activity = StreamTransformerActivitySource . StartActivity ( "gen_ai.agent.pipe " ) ;
7880 _ = ( activity ? . SetTag ( "transformer.type" , GetType ( ) . Name ) ) ;
7981
8082 try
@@ -204,14 +206,12 @@ protected async Task WriteEventAsync(AskAiEvent? transformedEvent, PipeWriter wr
204206 _ = ( activity ? . SetTag ( "gen_ai.provider.name" , GetAgentProvider ( ) ) ) ;
205207 _ = ( activity ? . SetTag ( "gen_ai.response.token_type" , transformedEvent . GetType ( ) . Name ) ) ;
206208
207- // Add GenAI response event for each token/chunk
208- _ = ( activity ? . AddEvent ( new ActivityEvent ( "gen_ai.client.inference.operation.details " ,
209+ // Add GenAI completion event for each token/chunk
210+ _ = ( activity ? . AddEvent ( new ActivityEvent ( "gen_ai.content.completion " ,
209211 timestamp : DateTimeOffset . UtcNow ,
210212 tags :
211213 [
212- new KeyValuePair < string , object ? > ( "gen_ai.operation.name" , "chat" ) ,
213- new KeyValuePair < string , object ? > ( "gen_ai.response.model" , GetAgentId ( ) ) ,
214- new KeyValuePair < string , object ? > ( "gen_ai.output.messages" , JsonSerializer . Serialize ( transformedEvent , AskAiEventJsonContext . Default . AskAiEvent ) )
214+ new KeyValuePair < string , object ? > ( "gen_ai.completion" , JsonSerializer . Serialize ( transformedEvent , AskAiEventJsonContext . Default . AskAiEvent ) )
215215 ] ) ) ) ;
216216
217217 // Serialize as base AskAiEvent type to include the type discriminator
0 commit comments