Skip to content

Adjust logging to avoid expensive CosmosException.getMessage() diagnostics json serialization#49321

Draft
jaxpod70 wants to merge 1 commit into
Azure:mainfrom
jaxpod70:jmck/logging-0
Draft

Adjust logging to avoid expensive CosmosException.getMessage() diagnostics json serialization#49321
jaxpod70 wants to merge 1 commit into
Azure:mainfrom
jaxpod70:jmck/logging-0

Conversation

@jaxpod70
Copy link
Copy Markdown

Description

Fixes excessive log line sizes in the ChangeFeedProcessor's partition processing loop caused by CosmosException.getMessage() serializing the full CosmosDiagnostics payload (request timelines, region contacts, retry history, metadata) into JSON when logged at WARN level.

Under heavy DB connection load, this produces multi-MB log lines (30+ MB observed) on every transient error (429 throttles, timeouts, connectivity issues) across all leased partitions concurrently. This causes log ingestion pipeline throttling/rejection, increased storage costs, and memory pressure from repeated serialization in a hot loop.

Fix: Split the existing log statement into two tiers in both epkversion.PartitionProcessorImpl and pkversion.PartitionProcessorImpl:

  • WARN level: Uses CosmosException.getShortMessage() via parameterized logging — lightweight, no diagnostics payload
  • DEBUG level: Logs the full exception (with diagnostics + stack trace) for deep troubleshooting when needed

This preserves observability for operators at default log levels while eliminating the excessive payload.

Related Issue

49320

All SDK Contribution checklist:

General Guidelines and Best Practices (https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md#developer-guide)

Testing Guidelines (https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md#building-and-unit-testing)

  • Pull request includes test coverage for the included changes.

@github-actions github-actions Bot added Community Contribution Community members are working on the issue Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. labels May 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your contribution @jaxpod70! We will review the pull request and get back to you soon.

@jaxpod70
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution Community members are working on the issue Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant