Skip to content

Commit

Permalink
DRIVERS-2452 Add database name to the "command failed" and "command s…
Browse files Browse the repository at this point in the history
…ucceeded" log messages (#1436)
  • Loading branch information
qingyang-hu authored Jun 26, 2023
1 parent 5d389fb commit 6b267dd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ The following key-value pairs MUST be included in all command messages:
- String
- The command name.

* - databaseName
- String
- The database name.

* - requestId
- Int
- The driver-generated request ID.
Expand Down Expand Up @@ -456,10 +460,6 @@ In addition to the common fields, command started messages MUST contain the foll
`logging specification <../logging/logging.rst#configurable-max-document-length>`_, and MUST be replaced with an empty document
"{ }" if the command is considered sensitive.

* - databaseName
- String
- The database name.

The unstructured form SHOULD be as follows, using the values defined in the structured format above to fill in placeholders as appropriate:

Command "{{commandName}}" started on database "{{databaseName}}" using a connection with driver-generated ID {{driverConnectionId}}
Expand Down Expand Up @@ -495,7 +495,7 @@ In addition to the common fields, command succeeded messages MUST contain the fo

The unstructured form SHOULD be as follows, using the values defined in the structured format above to fill in placeholders as appropriate:

Command "{{commandName}}" succeeded in {{durationMS}} ms using a connection with driver-generated ID {{driverConnectionId}} and
Command "{{commandName}}" succeeded on database "{{databaseName}}" in {{durationMS}} ms using a connection with driver-generated ID {{driverConnectionId}} and
server-generated ID {{serverConnectionId}} to {{serverHost}}:{{serverPort}} with service ID {{serviceId}}. The requestID is
{{requestId}} and the operation ID is {{operationId}}. Command reply: {{command}}

Expand Down Expand Up @@ -528,7 +528,7 @@ In addition to the common fields, command failed messages MUST contain the follo

The unstructured form SHOULD be as follows, using the values defined in the structured format above to fill in placeholders as appropriate:

Command "{{commandName}}" failed in {{durationMS}} ms using a connection with driver-generated ID {{driverConnectionId}} and
Command "{{commandName}}" failed on database "{{databaseName}}" in {{durationMS}} ms using a connection with driver-generated ID {{driverConnectionId}} and
server-generated ID {{serverConnectionId}} to {{serverHost}}:{{serverPort}} with service ID {{serviceId}}. The requestID is
{{requestId}} and the operation ID is {{operationId}}. Error: {{error}}

Expand Down Expand Up @@ -571,3 +571,4 @@ Changelog
clearly label connection IDs and use more readable server address representations.
:2023-03-23: Updated ``serverConnectionId`` field to be Int64 as long-running servers can return Int64.
:2023-06-13: Added ``databaseName`` field to ``CommandFailedEvent`` and ``CommandSucceededEvent``.
Updated suggested unstructured forms of log messages reflecting the changes.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"component": "command",
"data": {
"message": "Command succeeded",
"databaseName": "logging-tests",
"commandName": "ping",
"reply": {
"$$type": "string"
Expand Down Expand Up @@ -177,6 +178,7 @@
"component": "command",
"data": {
"message": "Command failed",
"databaseName": "logging-tests",
"commandName": "find",
"failure": {
"$$exists": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ tests:
component: command
data:
message: "Command succeeded"
databaseName: *databaseName
commandName: *commandName
reply: { $$type: string }
requestId: { $$type: [int, long] }
serverHost: { $$type: string }
serverPort: { $$type: [int, long] }
durationMS: { $$type: [double, int, long] }

- description: "A failed command"
operations:
- name: &commandName find
Expand All @@ -85,10 +86,10 @@ tests:
component: command
data:
message: "Command failed"
databaseName: *databaseName
commandName: *commandName
failure: { $$exists: true }
requestId: { $$type: [int, long] }
serverHost: { $$type: string }
serverPort: { $$type: [int, long] }
durationMS: { $$type: [double, int, long] }

0 comments on commit 6b267dd

Please sign in to comment.