@@ -10,12 +10,10 @@ const { snsMiddlewareConfig } = require('./sns')
1010const { sqsMiddlewareConfig } = require ( './sqs' )
1111const { dynamoMiddlewareConfig } = require ( './dynamodb' )
1212const { lambdaMiddlewareConfig } = require ( './lambda' )
13- const { bedrockMiddlewareConfig } = require ( './bedrock' )
1413const MIDDLEWARE = Symbol ( 'nrMiddleware' )
1514
1615const middlewareByClient = {
1716 Client : middlewareConfig ,
18- BedrockRuntime : [ ...middlewareConfig , bedrockMiddlewareConfig ] ,
1917 Lambda : [ ...middlewareConfig , lambdaMiddlewareConfig ] ,
2018 SNS : [ ...middlewareConfig , snsMiddlewareConfig ] ,
2119 SQS : [ ...middlewareConfig , sqsMiddlewareConfig ] ,
@@ -31,13 +29,23 @@ module.exports = function instrumentSmithyClient(shim, smithyClientExport) {
3129 }
3230}
3331
32+ // Clients handled by subscriber-based instrumentation in
33+ // lib/subscribers/smithy-client/send.js. Skip them here to avoid
34+ // double middleware registration during the migration.
35+ const subscriberHandledClients = new Set ( [ 'BedrockRuntime' ] )
36+
3437function wrapSend ( shim , send ) {
3538 return function wrappedSend ( ) {
3639 // most clients we want to instrument aside from smithy-client
3740 // extend themselves to provide different names(i.e. - SNS and SNSClient)
3841 // we want to handle these the same by registering the sns middleware
3942 const client = this . constructor . name . replace ( / C l i e n t $ / , '' )
4043 shim . logger . trace ( 'Sending with client %s' , client )
44+
45+ if ( subscriberHandledClients . has ( client ) ) {
46+ return send . apply ( this , arguments )
47+ }
48+
4149 const config = this . config
4250 const middlewares = middlewareByClient [ client ] || middlewareByClient . Client
4351
0 commit comments