Skip to content

CLOUDP-332646: fix structured logging using desugared logger #2532

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

Merged
merged 1 commit into from
Jul 21, 2025

Conversation

s-urbaniak
Copy link
Collaborator

@s-urbaniak s-urbaniak commented Jul 21, 2025

Summary

#2525 introduced structured logging output.

However, this internally uses the sugared logger which does not take key value pairs and renders a msg field only.

{
  "level": "DEBUG",
  "time": "2025-07-21T12:08:02.749+0200",
  "msg": "JSON diff text{url 15 0 https://cloud-qa.mongodb.com/api/atlas/v2/groups/687e0db8823af9166efd3a18/flexClusters/test <nil>} {diff 15 0  {\n-  \"backupSettings\": {\n-    \"enabled\": true\n-  },\n-  \"clusterType\": \"REPLICASET\",\n-  \"connectionStrings\": {\n-    \"standard\": \"mongodb://ac-vcv4uwg-shard-00-00.7oqlwif.mongodb-qa.net:27017,ac-vcv4uwg-shard-00-01.7oqlwif.mongodb-qa.net:27017,ac-vcv4uwg-shard-00-02.7oqlwif.mongodb-qa.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-eznwg7-shard-0\",\n-    \"standardSrv\": \"mongodb+srv://test.7oqlwif.mongodb-qa.net\"\n-  },\n-  \"createDate\": \"2025-07-21T09:52:06Z\",\n-  \"groupId\": \"687e0db8823af9166efd3a18\",\n-  \"id\": \"687e0dc6426db7026b5f38ac\",\n-  \"mongoDBVersion\": \"8.0.11\",\n-  \"name\": \"test\",\n-  \"providerSettings\": {\n-    \"backingProviderName\": \"AWS\",\n-    \"diskSizeGB\": 5,\n-    \"providerName\": \"FLEX\",\n-    \"regionName\": \"US_EAST_1\"\n-  },\n-  \"stateName\": \"IDLE\",\n   \"tags\": [\n   ],\n-  \"terminationProtectionEnabled\": true,\n+  \"terminationProtectionEnabled\": false,\n-  \"versionReleaseSystem\": \"LTS\"\n }\n <nil>}"
}

This needs to use the desugar'ed logger to properly render output the url and diff fields separately:

{
  "level": "DEBUG",
  "time": "2025-07-21T12:22:20.004+0200",
  "msg": "JSON diff",
  "url": "https://cloud-qa.mongodb.com/api/atlas/v2/groups/687e0db8823af9166efd3a18/flexClusters/test",
  "diff": " {\n-  \"backupSettings\": {\n-    \"enabled\": true\n-  },\n-  \"clusterType\": \"REPLICASET\",\n-  \"connectionStrings\": {\n-    \"standard\": \"mongodb://ac-vcv4uwg-shard-00-00.7oqlwif.mongodb-qa.net:27017,ac-vcv4uwg-shard-00-01.7oqlwif.mongodb-qa.net:27017,ac-vcv4uwg-shard-00-02.7oqlwif.mongodb-qa.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-eznwg7-shard-0\",\n-    \"standardSrv\": \"mongodb+srv://test.7oqlwif.mongodb-qa.net\"\n-  },\n-  \"createDate\": \"2025-07-21T09:52:06Z\",\n-  \"groupId\": \"687e0db8823af9166efd3a18\",\n-  \"id\": \"687e0dc6426db7026b5f38ac\",\n-  \"mongoDBVersion\": \"8.0.11\",\n-  \"name\": \"test\",\n-  \"providerSettings\": {\n-    \"backingProviderName\": \"AWS\",\n-    \"diskSizeGB\": 5,\n-    \"providerName\": \"FLEX\",\n-    \"regionName\": \"US_EAST_1\"\n-  },\n-  \"stateName\": \"IDLE\",\n   \"tags\": [\n   ],\n-  \"terminationProtectionEnabled\": true,\n+  \"terminationProtectionEnabled\": false,\n-  \"versionReleaseSystem\": \"LTS\"\n }\n"
}

This now properly works with a structured logging tool as well:

 1 | diff: |
 2 |    {
 3 |   -  "backupSettings": {
 4 |   -    "enabled": true
 5 |   -  },
 6 |   -  "clusterType": "REPLICASET",
 7 |   -  "connectionStrings": {
 8 |   -    "standard": "mongodb://ac-vcv4uwg-shard-00-00.7oqlwif.mongodb-qa.net:27017,ac-vcv4uwg-shard-00-01.7oqlwif.mongodb-qa.net:27017,ac-vcv4uwg-shard-00-02.7oqlwif.mongodb-qa.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-eznwg7-shard-0",
 9 |   -    "standardSrv": "mongodb+srv://test.7oqlwif.mongodb-qa.net"
10 |   -  },
11 |   -  "createDate": "2025-07-21T09:52:06Z",
12 |   -  "groupId": "687e0db8823af9166efd3a18",
13 |   -  "id": "687e0dc6426db7026b5f38ac",
14 |   -  "mongoDBVersion": "8.0.11",
15 |   -  "name": "test",
16 |   -  "providerSettings": {
17 |   -    "backingProviderName": "AWS",
18 |   -    "diskSizeGB": 5,
19 |   -    "providerName": "FLEX",
20 |   -    "regionName": "US_EAST_1"
21 |   -  },
22 |   -  "stateName": "IDLE",
23 |      "tags": [
24 |      ],
25 |   -  "terminationProtectionEnabled": false,
26 |   +  "terminationProtectionEnabled": true,
27 |   -  "versionReleaseSystem": "LTS"
28 |    }
29 | level: DEBUG
30 | msg: JSON diff
31 | time: 2025-07-21T12:24:37.761+0200
32 | url: https://cloud-qa.mongodb.com/api/atlas/v2/groups/687e0db8823af9166efd3a18/flexClusters/test

Proof of Work

unit tests still apply

Checklist

  • Have you linked a jira ticket and/or is the ticket in the title?
  • Have you checked whether your jira ticket required DOCSP changes?
  • Have you checked for release_note changes?
  • Have you signed our CLA?

Reminder (Please remove this when merging)

  • Please try to Approve or Reject Changes the PR, keep PRs in review as short as possible
  • Remember the following Communication Standards - use comment prefixes for clarity:
    • blocking: Must be addressed before approval.
    • follow-up: Can be addressed in a later PR or ticket.
    • q: Clarifying question.
    • nit: Non-blocking suggestions.
    • note: Side-note, non-actionable. Example: Praise
    • --> no prefix is considered a question

@s-urbaniak s-urbaniak changed the title real fix CLOUDP-332646: fix structured logging using desugared logger Jul 21, 2025
@s-urbaniak s-urbaniak marked this pull request as ready for review July 21, 2025 10:32
@s-urbaniak s-urbaniak requested a review from a team as a code owner July 21, 2025 10:32
@s-urbaniak
Copy link
Collaborator Author

merging as we know cloud-qa is flaky.

@s-urbaniak s-urbaniak merged commit 8d27a52 into main Jul 21, 2025
72 of 82 checks passed
@s-urbaniak s-urbaniak deleted the CLOUDP-332646 branch July 21, 2025 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants