| 26 | import { getAWS, execute } from '../aws/SDK2'; |
| 27 | |
| 28 | class AWS2DynamoDBPlugin implements SwPlugin { |
| 29 | readonly module = 'aws-sdk'; |
| 30 | readonly versions = '2.*'; |
| 31 | |
| 32 | install(installer: PluginInstaller): void { |
| 33 | const AWS = getAWS(installer); |
| 34 | const DocumentClient = AWS.DynamoDB.DocumentClient; |
| 35 | |
| 36 | function instrument(name: string): void { |
| 37 | const _func = DocumentClient.prototype[name]; |
| 38 | |
| 39 | DocumentClient.prototype[name] = function (params: any, callback?: any): any { |
| 40 | const span = ContextManager.current.newExitSpan(`AWS/DynamoDB/${name}`, Component.AWS_DYNAMODB, Component.HTTP); |
| 41 | |
| 42 | span.component = Component.AWS_DYNAMODB; |
| 43 | span.layer = SpanLayer.DATABASE; |
| 44 | // span.peer = `${this.service.endpoint.host ?? '<unknown>'}:${this.service.endpoint.port ?? '<unknown>'}`; |
| 45 | |
| 46 | span.tag(Tag.dbType('DynamoDB')); |
| 47 | span.tag(Tag.dbStatement(name)); |
| 48 | |
| 49 | return execute(span, this, _func, params, callback); |
| 50 | }; |
| 51 | } |
| 52 | |
| 53 | instrument('batchGet'); |
| 54 | instrument('batchWrite'); |
| 55 | instrument('delete'); |
| 56 | instrument('get'); |
| 57 | instrument('put'); |
| 58 | instrument('query'); |
| 59 | instrument('scan'); |
| 60 | instrument('update'); |
| 61 | instrument('transactGet'); |
| 62 | instrument('transactWrite'); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | // noinspection JSUnusedGlobalSymbols |
| 67 | export default new AWS2DynamoDBPlugin(); |
nothing calls this directly
no outgoing calls
no test coverage detected