Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRIVERS-2452 Add database name to the "command failed" and "command succeeded" log messages #1436

Merged
merged 1 commit into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted that the schema defines data as an object (here), so a new field here has no impact on the schema version.

Check unified test format files against schema / build (pull_request)

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] }