@@ -152,14 +152,14 @@ export class BedrockInstrumentation extends InstrumentationBase {
152152
153153 try {
154154 const input = params . input as bedrock . InvokeModelCommandInput ;
155- const [ vendor , model ] = input . modelId
156- ? input . modelId . split ( "." )
157- : [ "" , "" ] ;
155+ const { modelVendor , model } = this . _extractVendorAndModel (
156+ input . modelId || "" ,
157+ ) ;
158158
159159 attributes = {
160- [ SpanAttributes . LLM_SYSTEM ] : vendor ,
160+ [ SpanAttributes . LLM_SYSTEM ] : "AWS" ,
161161 [ SpanAttributes . LLM_REQUEST_MODEL ] : model ,
162- [ SpanAttributes . LLM_RESPONSE_MODEL ] : model ,
162+ [ SpanAttributes . LLM_RESPONSE_MODEL ] : input . modelId ,
163163 [ SpanAttributes . LLM_REQUEST_TYPE ] : LLMRequestTypeValues . COMPLETION ,
164164 } ;
165165
@@ -168,7 +168,7 @@ export class BedrockInstrumentation extends InstrumentationBase {
168168
169169 attributes = {
170170 ...attributes ,
171- ...this . _setRequestAttributes ( vendor , requestBody ) ,
171+ ...this . _setRequestAttributes ( modelVendor , requestBody ) ,
172172 } ;
173173 }
174174 } catch ( e ) {
@@ -199,6 +199,13 @@ export class BedrockInstrumentation extends InstrumentationBase {
199199 : { } ;
200200
201201 if ( SpanAttributes . LLM_SYSTEM in attributes ) {
202+ const modelId = attributes [
203+ SpanAttributes . LLM_RESPONSE_MODEL
204+ ] as string ;
205+ const { modelVendor, model } = this . _extractVendorAndModel ( modelId ) ;
206+
207+ span . setAttribute ( SpanAttributes . LLM_RESPONSE_MODEL , model ) ;
208+
202209 if ( ! ( result . body instanceof Object . getPrototypeOf ( Uint8Array ) ) ) {
203210 const rawRes = result . body as AsyncIterable < bedrock . ResponseStream > ;
204211
@@ -235,7 +242,7 @@ export class BedrockInstrumentation extends InstrumentationBase {
235242 }
236243
237244 let responseAttributes = this . _setResponseAttributes (
238- attributes [ SpanAttributes . LLM_SYSTEM ] ,
245+ modelVendor ,
239246 parsedResponse ,
240247 true ,
241248 ) ;
@@ -266,7 +273,7 @@ export class BedrockInstrumentation extends InstrumentationBase {
266273 const parsedResponse = JSON . parse ( jsonString ) ;
267274
268275 const responseAttributes = this . _setResponseAttributes (
269- attributes [ SpanAttributes . LLM_SYSTEM ] ,
276+ modelVendor ,
270277 parsedResponse ,
271278 ) ;
272279
@@ -494,4 +501,19 @@ export class BedrockInstrumentation extends InstrumentationBase {
494501 ? this . _config . traceContent
495502 : true ;
496503 }
504+
505+ private _extractVendorAndModel ( modelId : string ) : {
506+ modelVendor : string ;
507+ model : string ;
508+ } {
509+ if ( ! modelId ) {
510+ return { modelVendor : "" , model : "" } ;
511+ }
512+
513+ const parts = modelId . split ( "." ) ;
514+ return {
515+ modelVendor : parts [ 0 ] || "" ,
516+ model : parts [ 1 ] || "" ,
517+ } ;
518+ }
497519}
0 commit comments