CommandStartedEvent::getCommand() not instance of Explainable
I'm trying to build a verbose mode in our MongoDB wrapper library. I was able to implement debug output leveraging CommandSubscriber interface. This part works.
However what I would also like to do is create support for automatic explaining of queries that are being executed. This is not possible due to inconsistency in MongoDB (php) library.
- CommandStartedEvent::getCommand() is not an instance of Explainable interface. It's just a deserialized object. There is no way to fetch the original command object to be able to do explain.
- Neither it is possible to remember such command object when creating it. As these are generated within the library itself. See functions of Collection class for example.
1
vote
Miroslav
shared this idea
-
Jérôme commented
These events are triggered by the mongodb extension, which has no idea about our Explainable command objects. The command object from the event can be passed to the explain command as-is: https://www.mongodb.com/docs/manual/reference/command/explain/