Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default whitelist not working with AWS SDK v3 clients #443

Closed
blakemorgan opened this issue Jun 18, 2021 · 3 comments · Fixed by #444
Closed

Default whitelist not working with AWS SDK v3 clients #443

blakemorgan opened this issue Jun 18, 2021 · 3 comments · Fixed by #444
Assignees

Comments

@blakemorgan
Copy link
Contributor

I'm initializing AWS SDK v3 clients and tracing them with XRay, but no additional data is being added to the subsegments. The debug logs say that the operations are not whitelisted, even though when I look at the default aws_whitelist.json, I see the services and operations whitelisted -- the case of the services are different.

Here is how I'm initializing the clients:

const dynamoDBClient = AWSXRay.captureAWSv3Client(new DynamoDBClient({ }))
const s3Client = AWSXRay.captureAWSv3Client(new S3Client({ region: process.env.AWS_REGION }))

And here are the debug messages:

Call "DynamoDB.UpdateItem" is not whitelisted for additional data capturing. Ignoring.
Call "S3.PutObject" is not whitelisted for additional data capturing. Ignoring.

I've tried creating my own whitelist, but then I get the following error:

    TypeError: Cannot read property 'TableName' of undefined
        at Object.<anonymous> (/Users/btm296/Development/payments-ws/app/node_modules/aws-xray-sdk-core/dist/lib/patchers/call_capturer.js:82:24)
        at Array.forEach (<anonymous>)
        at captureCallParams (/Users/btm296/Development/payments-ws/app/node_modules/aws-xray-sdk-core/dist/lib/patchers/call_capturer.js:81:12)
        at CallCapturer.capture (/Users/btm296/Development/payments-ws/app/node_modules/aws-xray-sdk-core/dist/lib/patchers/call_capturer.js:58:13)
        at Aws.init (/Users/btm296/Development/payments-ws/app/node_modules/aws-xray-sdk-core/dist/lib/segments/attributes/aws.js:28:27)
        at new Aws (/Users/btm296/Development/payments-ws/app/node_modules/aws-xray-sdk-core/dist/lib/segments/attributes/aws.js:14:10)
        at buildAttributesFromMetadata (/Users/btm296/Development/payments-ws/app/node_modules/aws-xray-sdk-core/dist/lib/patchers/aws3_p.js:20:17)
        at /Users/btm296/Development/payments-ws/app/node_modules/aws-xray-sdk-core/dist/lib/patchers/aws3_p.js:92:35
        at processTicksAndRejections (internal/process/task_queues.js:95:5)

This is the whitelist I used:

AWSXRay.setAWSWhitelist({
  services: {
    DynamoDB: {
      operations: {
        Scan: {
          request_parameters: ['TableName']
        }
      }
    }
  }
})

Looking more into that stack trace, when I get to the captureCallParams() call with my own whitelist, response.request.params is undefined. When I do it with the default waitlist, I get the above error message because it can't find the service DynamoDB (it's expecting dyanmodb) and the function returns. However, if I look at it in a debugger before it returns, response.request.params is still undefined.

@blakemorgan
Copy link
Contributor Author

After further investigation, I realized the undefined value response.request.params is unrelated and was a red herring. Once I translated the service name to all lower case, the issue seemed to be resolved. I created a fix in #444.

@willarmiros
Copy link
Contributor

@blakemorgan so you are seeing the TableName recorded even with a V3 DynamoDB client? The aws_whitelist.json is intended for use with v2 clients, since I believe V3 clients deliver a differently formatted response. But that might not be the case if it's working with your custom whitelist.

@blakemorgan
Copy link
Contributor Author

@willarmiros I was not seeing the TableName recorded previously, but it was also not working with my custom whitelist. However, when I modified the source code locally with my PR, the debug messages were not appearing anymore, so I assume the default whitelist was being used successfully and that the TableName was being added to the request.

I couldn't confirm the TableName being added in the AWS console because I was just running it locally. I can confirm that before these changes, the TableName was not being added (I noticed that looking in the AWS console and that's what caused me to do more research).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants