File tree Expand file tree Collapse file tree
packages/server-utils/src/integrations/tracing-channel/aws-sdk/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,11 +58,19 @@ export class BedrockRuntimeServiceExtension implements ServiceExtension {
5858 }
5959
6060 public responseHook ( response : NormalizedResponse , span : Span ) : void {
61+ const commandName = response . request . commandName ;
62+
6163 if ( ! span . isRecording ( ) ) {
64+ // Streaming spans are ended by the wrapped stream (the subscriber's `deferSpanEnd` suppresses
65+ // the helper's own `end()`). When the span isn't recording we skip wrapping, so end it here to
66+ // avoid leaking an open span. Non-streaming commands are ended by the helper, so leave them.
67+ if ( commandName === 'ConverseStream' || commandName === 'InvokeModelWithResponseStream' ) {
68+ span . end ( ) ;
69+ }
6270 return ;
6371 }
6472
65- switch ( response . request . commandName ) {
73+ switch ( commandName ) {
6674 case 'Converse' :
6775 return this . _responseHookConverse ( response , span ) ;
6876 case 'ConverseStream' :
You can’t perform that action at this time.
0 commit comments