Repository navigation
[Bundles] Log entry size and search index stats - #5933
Open
apurvabhaleMS wants to merge 3 commits into
Open
apurvabhaleMS wants to merge 3 commits into
apurvabhaleMS wants to merge 3 commits into
Conversation
Add total bundle size, per-entry size buckets with the top large entries, and per-entry search index value buckets with the top heavy entries to the bundleStatistics log. This data informs the defaults for the upcoming bundle size and search parameter limits.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
PATCH search-index telemetry attributes counts to payload types rather than the indexed target resource types.
1 open finding
What changed in this PR
Extends existing bundle telemetry to inform future limits without enforcing new request restrictions.
Changes:
- Logs total bundle bytes and per-entry size summaries.
- Captures search-index counts in sequential and parallel execution.
- Adds tests for collection, thresholds, and top-five summaries.
| File | Description |
|---|---|
src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Persistence/ResourceWrapperFactoryTests.cs |
Tests bundle-only index-count capture. |
src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/Bundle/BundleHandlerStatistics.cs |
Adds size and index-count summaries. |
src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/Bundle/BundleHandlerParallelOperations.cs |
Collects parallel-entry statistics. |
src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/Bundle/BundleHandler.cs |
Records entry sizes, bundle totals, and index counts. |
src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerTests.cs |
Tests collection paths and Content-Length handling. |
src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerStatisticsTests.cs |
Tests buckets, ordering, caps, and empty summaries. |
src/Microsoft.Health.Fhir.Core/Features/Persistence/ResourceWrapperFactory.cs |
Stores index counts on bundle-entry request contexts. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Rename totalBundleBytes to bundleRequestBodyBytes and log null when Content-Length is absent. Rename entrySize to resourceSize and measure Binary JSON Patch entries by their base64-encoded data size. Record search index values even when an entry is cancelled during the 429 retry delay.
Use the routed resource type for search index statistics so PATCH entries are attributed to the indexed resource instead of the Parameters/Binary payload. Filter measured resources with Where per code scanning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Adds bundle size, per-entry size, and per-entry search index statistics to the existing
bundleStatisticslog. This data is needed to choose safe defaults for upcoming bundle limits (bundle size, resource size, and search index values per resource) before any limit is enforced. This PR only adds logging; request behavior does not change.New fields in
bundleStatistics:totalBundleBytesContent-Length; falls back to the sum of serialized entries when absent (chunked requests)entrySize.overXMiBentrySize.largesearchIndex.overNsearchIndex.heavyHow the data is collected:
BundleHandler.GenerateRequestalready serializes each entry to bytes; the length is stored onResourceExecutionContext. Sizes are registered for all entries when statistics are created, so they are logged even if the bundle fails partway.ResourceWrapperFactory.CreatestoressearchIndices.Counton the request context only whenExecutingBatchOrTransactionis true. The sequential and parallel bundle paths read it from the entry's request context after the entry executes.Related issues
Addresses AB#195352.
Testing
BundleHandlerStatisticsTests: buckets, top-5 ordering and cap,totalBundleBytes, and empty summaries.ResourceWrapperFactoryTests: count stored for bundle entries; not stored outside a bundle.BundleHandlerTests: end-to-end statistics for sequential and parallel batches;totalBundleBytesusesContent-Lengthwhen present.BundleHandlerTests,BundleHandlerStatisticsTests): 44 passed. R4 Core unit tests (ResourceWrapperFactoryTests): 7 passed. R4 and STU3 build without warnings.FHIR Team Checklist
Semver Change (docs)
Patch