Add details about aggregation pipelines & avoid get(default) parameter#644
Add details about aggregation pipelines & avoid get(default) parameter#644reyang merged 2 commits intocensus-instrumentation:masterfrom
Conversation
|
@tjzo please help to review. |
| def get(self, key): | ||
| return self.command_attrs[key] \ | ||
| if key in self.command_attrs else default | ||
| if key in self.command_attrs else None |
There was a problem hiding this comment.
Nit: might as well use self.command_attrs.get(key).
As best I can tell the commands aren't
Yeah that would be great, working on a getting one but so far we've only seen this in production and haven't been able to reproduce it locally. |
|
@c24t I was just able to confirm from production that the command causing the error is an empty dictionary. class DetectIncorrectCommand(pymongo.monitoring.CommandListener):
def started(self, event):
if not isinstance(event.command, bson.SON):
print('command for (%s) %s' % (type(event.command), event.command))Resulted in: And this is the same error we were seeing. Removing the use of the keyword arg ( |
|
@angelini would you update the |
|
@reyang it's been rebased and the changelog has been updated |
|
Thanks for your contribution! @angelini |
When issuing aggregations via Pymongo, they store the pipeline as a command attribute.
This PR adds support for storing the pipeline as a trace attribute.
We've also seen the following errors in production with a Mongo
3.6.12instance an Pymongo3.6.1.It seems like not all
event.commandobjects areSONinstances (https://github.com/mongodb/mongo-python-driver/blob/master/bson/son.py#L32).Since the
defaultkeyword argument isn't being used here, the default value isNone, I opted to remove the use of it.