[JAVA-2698] Include more of the command document when logging command execution Created: 08/Dec/17  Updated: 28/Oct/23  Resolved: 09/Jan/18

Status: Closed
Project: Java Driver
Component/s: Monitoring
Affects Version/s: None
Fix Version/s: 3.7.0

Type: New Feature Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on JAVA-2721 Add ability to cap the size of JSON g... Closed
Duplicate
is duplicated by JAVA-2804 Log queries Closed
is duplicated by JAVA-1322 Log command line friendly queries and... Closed
Related
is related to JAVA-2697 Include elapsed time and request id w... Closed

 Description   

Currently the logging of a command looks like this:

Sending command {find : BsonString{value='mycoll'}}

which makes it more difficult than necessary to determine the contents of the command. Instead, the driver should log a fixed number of characters from the relaxed extended JSON representation of the command:

Sending command {"find" : "myColl", filter : { "open" : true }, lim...

Suggested character count: 100



 Comments   
Comment by Githook User [ 09/Jan/18 ]

Author:

{'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}

Message: JAVA-2697, JAVA-2698: Log successful and failed command events, including elapsed time, request id, and truncated (at 1000 characters) JSON representation of the command. Logs now look like this (against a 3.6 server)

10:37:29.099 [cluster-ClusterId

{value='5a466138741fc252712a6d71', description='null'}-127.0.0.1:27017] DEBUG org.mongodb.driver.protocol.command - Sending command '{ "ismaster" : 1, "$db" : "admin" } ...' with request id 4 to database admin on connection [connectionId{localValue:1, serverValue:1958}] to server 127.0.0.1:27017
10:37:29.104 [cluster-ClusterId{value='5a466138741fc252712a6d71', description='null'}

-127.0.0.1:27017] DEBUG org.mongodb.driver.protocol.command - Execution of command with request id 4 completed successfully in 22.44 ms on connection [connectionId

{localValue:1, serverValue:1958}

] to server 127.0.0.1:27017
10:37:29.154 [main] DEBUG org.mongodb.driver.protocol.command - Sending command '{ "insert" : "test", "ordered" : true, "writeConcern" :

{ "w" : 0 }

, "$db" : "test", "documents" : [{ "_id" :

{ "$oid" : "5a466139741fc252712a6d72" }

, "bytes" : { "$binary" : { "base64" : "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ...' with request id 8 to database test on connection [connectionId

{localValue:2, serverValue:1959}

] to server 127.0.0.1:27017
10:37:29.154 [main] DEBUG org.mongodb.driver.protocol.command - Execution of one-way command with request id 8 completed successfully in 24.02 ms on connection [connectionId

{localValue:2, serverValue:1959}

] to server 127.0.0.1:27017
10:37:29.161 [main] DEBUG org.mongodb.driver.protocol.command - Sending command '{ "ping" : 1, "$db" : "admin", "lsid" : { "id" : { "$binary" :

{ "base64" : "1VaSnyegTCy9yXzgsmP0FQ==", "subType" : "04" }

} } } ...' with request id 9 to database admin on connection [connectionId

{localValue:2, serverValue:1959}

] to server 127.0.0.1:27017
10:37:29.162 [main] DEBUG org.mongodb.driver.protocol.command - Execution of command with request id 9 completed successfully in 1.46 ms on connection [connectionId

{localValue:2, serverValue:1959}

] to server 127.0.0.1:27017
10:37:29.163 [main] DEBUG org.mongodb.driver.protocol.command - Sending command '{ "unknown" : 1, "$db" : "admin", "lsid" : { "id" : { "$binary" :

{ "base64" : "1VaSnyegTCy9yXzgsmP0FQ==", "subType" : "04" }

} } } ...' with request id 10 to database admin on connection [connectionId

{localValue:2, serverValue:1959}

] to server 127.0.0.1:27017
10:37:29.175 [main] DEBUG org.mongodb.driver.protocol.command - Execution of command with request id 10 failed to complete successfully in 5.34 ms on connection [connectionId

{localValue:2, serverValue:1959}

] to server 127.0.0.1:27017
com.mongodb.MongoCommandException: Command failed with error 59: 'no such command: 'unknown', bad cmd: '{ unknown: 1, $db: "admin", lsid:

{ id: UUID("d556929f-27a0-4c2c-bdc9-7ce0b263f415") }

}'' on server 127.0.0.1:27017. The full response is { "operationTime" : { "$timestamp" :

{ "t" : 1514556771, "i" : 1 }

}, "ok" : 0.0, "errmsg" : "no such command: 'unknown', bad cmd: '{ unknown: 1, $db: \"admin\", lsid:

{ id: UUID(\"d556929f-27a0-4c2c-bdc9-7ce0b263f415\") }

}'", "code" : 59, "codeName" : "CommandNotFound" }
at com.mongodb.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:164)
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/a93299f7a9a18e9febabfd8445a24af0f8a8c194

Comment by Githook User [ 09/Jan/18 ]

Author:

{'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}

Message: JAVA-2698: Add ability in JsonWriter to abort execution of the pipe method based on whether the max length of the JSON text has been reached.

Implemented by adding an abortPipe() method in AbstractBsonWriter which just returns true, and overriding it in JsonWriter
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/8a07eeb25e0a88dd59d726c595920cc4f2c53f14

Comment by Githook User [ 09/Jan/18 ]

Author:

{'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}

Message: JAVA-2698: Add asBsonReader to BsonDocument so that subclasses can determine the most efficient
implemenation of BsonReader to use

The default implementation just returns a BsonDocumentReader
RawBsonDocument and ByteBufBsonDocument override it to return a BsonBinaryReader
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/0d19db19c2b1803cd06e3a01b17193de4cb1c848

Comment by Githook User [ 09/Jan/18 ]

Author:

{'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}

Message: JAVA-2698: BsonReader extends Closeable

Note: this is a backwards-breaking change for any implementation of BsonReader that don't already implement Closeable
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/827427e5c0da062c81c92c63af078f7782f83dbc

Generated at Thu Feb 08 08:57:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.