Open huonw opened 3 years ago
Thanks, the other thing I can come up with is that, removing the duplicate reference in trace context may not be able to fully render the actual structure of the metadata. And in some cases where the mutual references are a lot and simply replacing them with empty dict may cause more confusion (cause people don't know where these objects actually point to) unless the developer has a very clear picture of the mutual reference for each metadata. But anyway, let's leave it open to see how many customers encounter this issue.
+1
+1
+1
+1
+1, encountering this with sqlalchemy engine.
Following from https://github.com/aws/aws-xray-sdk-python/issues/298:
It'd be also really good if this code [
aws_xray_sdk.core.utils.conversion.metadata_to_dict
] didn't overflow the stack on circular objects like this, because doing so is:unreliable (stack overflow can lead to problems like we see here)
One option that's still recursion is to manually avoid re-serialising things. This is pretty similar to what currently happens, in that nested objects will be replaced by
{}
:The original example would then become something like
{"x": {}}
, and and similarly for:Thanks for providing the idea. One possibly very common case I would concern is that, for metadata that is very big but has no mutual references at all, walking through the new recursion will not only require the same time complexity, but will also introduce new space complexity for maintaining a temp list as big as the metadata. I can see this is not a very soon (but definitely worthwhile) enhancement we would consider to update at this moment.