Aws-xray-sdk-node: When adding object containing an array to meta data, the array is empty

Created on 5 Mar 2020  路  6Comments  路  Source: aws/aws-xray-sdk-node

image

Both the devices and inputs arrays should contain values - when logging the same things to CW logs (using console.log) I can see them. It only works (I can see the values) if I use JSON.stringify on the whole object.

Happens on 3.0.0-alpha.1, 2.5.0-experimental.1 and 2.5.0.

Interestingly, if I add the whole event object, it doesn't happen all all arrays. For example the values in these headers.

image

But when logging the full event object, it still removes the values from the inputs for example.

image

Am I missing something?

bug

Most helpful comment

Hi @GrzegorzKozub,

Thanks for raising this again. I mistakenly thought @chearmstrong was talking about the SDK's logger beforehand, not subsegment metadata. I was able to reproduce this issue, and it is a bug with the X-Ray backend service. We will work on fixing it as soon as we can.

All 6 comments

How are you making log statements? This is the expected format for logging with the X-Ray SDK's logger, it's a string message as the first argument followed by a object or string metadata argument:

AWSXRay.getLogger().info('message', metadataObj);

The logger uses JSON.stringify() on the metadata under the hood anyway, so any object should be fully printed. Here's the metadata formatter.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This happens to me when using addMetadata method from X-Ray SDK for Node.js.

Given subsegment is an instance of AWSXRay and result is a JSON object (not a string), I'm passing a JSON object like so:

subsegment.addMetadata('result', result, 'response');

Then, when looking at the metadata in xRay I can see the arrays on my object are empty. In my case these arrays are arrays of objects, like this:

[ { "foo" : "bar", "baz" : 2 }, { "foo" : "something", "baz" : 123 }, ... ]

Hi @GrzegorzKozub,

Thanks for raising this again. I mistakenly thought @chearmstrong was talking about the SDK's logger beforehand, not subsegment metadata. I was able to reproduce this issue, and it is a bug with the X-Ray backend service. We will work on fixing it as soon as we can.

Thanks for confirming it's a bug (and sorry for not being able to respond quickly). Will watch out for the fix.

This issue has been fixed, and such nested objects should now appear normally in your metadata :)

Was this page helpful?
0 / 5 - 0 ratings