Skip to content

Limit upload batches by event count#1459

Closed
bmehta001 wants to merge 8 commits into
microsoft:mainfrom
bmehta001:bhamehta/max-events-per-upload
Closed

Limit upload batches by event count#1459
bmehta001 wants to merge 8 commits into
microsoft:mainfrom
bmehta001:bhamehta/max-events-per-upload

Conversation

@bmehta001

@bmehta001 bmehta001 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add CFG_INT_TPM_MAX_EVENTS_PER_UPLOAD / maxEventsPerUpload with a default of 1500
  • apply the limit to upload contexts created by both scheduled uploads and max-latency immediate uploads
  • clamp configured values so non-positive values mean unlimited and oversized values cap at unsigned max
  • expose the configuration key through Android and Objective-C wrappers
  • add TPM coverage for default, override, clamping, and package-batching behavior

Context

OneCollector documents a per-request limit of 1500 events. The SDK already limits single-event and upload package size through maxBlobSize, but previously did not bound the event count when building an upload batch. A value of 0 preserves the existing unlimited behavior for callers that intentionally override the default.

Validation

  • git diff --check
  • msbuild Solutions\MSTelemetrySDK.sln /m:1 /nr:false /t:Tests\UnitTests /p:Configuration=Debug /p:Platform=Win32 /p:PlatformToolset=v145
  • Solutions\out\Debug\Win32\UnitTests\UnitTests.exe --gtest_filter=TransmissionPolicyManagerTests.* (43 tests)
  • msbuild Solutions\MSTelemetrySDK.sln /m:1 /nr:false /t:Tests\UnitTests /p:Configuration=Release /p:Platform=x64 /p:PlatformToolset=v145
  • Solutions\out\Release\x64\UnitTests\UnitTests.exe --gtest_filter=TransmissionPolicyManagerTests.* (43 tests)
  • GitHub Actions: Windows unit tests, Linux/macOS C++ CI, documentation, spellcheck, and CodeQL language analyzers completed successfully on the latest commit at the time of update; Android/Java checks were still running.

Enforce the OneCollector per-request event-count limit by applying
maxEventsPerUpload when upload contexts are created. Expose the new
configuration key through public C++, Android, and Objective-C surfaces,
and cover the default and override behavior in TPM tests.

Files changed:
- lib/include/public/ILogConfiguration.hpp
- lib/config/RuntimeConfig_Default.hpp
- lib/tpm/TransmissionPolicyManager.cpp
- tests/unittests/TransmissionPolicyManagerTests.cpp
- lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/LogConfigurationKey.java
- lib/android_build/app/src/androidTest/java/com/microsoft/applications/events/maesdktest/LogManagerDDVUnitTest.java
- wrappers/obj-c/ODWLogConfiguration.h
- wrappers/obj-c/ODWLogConfiguration.mm

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmehta001 bmehta001 requested a review from a team as a code owner June 1, 2026 16:48
bmehta001 and others added 2 commits June 1, 2026 12:13
Add TPM coverage that routes an upload through StorageObserver,
MemoryStorage, and Packager with maxEventsPerUpload set to 3. This proves
that the configured event-count limit reaches package creation and leaves
excess records queued for later batches.

Files changed:
- tests/unittests/TransmissionPolicyManagerTests.cpp

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CI failure: the integration-style max-events test used fake byte blobs,
which passed Release but tripped BondSplicer debug assertions because the
records were not valid Bond-serialized payloads. Serialize real
CsProtocol::Record payloads before storing records so the test exercises
the same package path without debug/release divergence.

Verified:
- Win32 Debug UnitTests build and TransmissionPolicyManagerTests.*
- x64 Release UnitTests build and TransmissionPolicyManagerTests.*

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new TPM configuration knob to cap the number of events included in a single upload request (defaulting to 1500, with 0 meaning unlimited), and wires that limit into upload-context creation paths so storage retrieval can respect it. It also exposes the key through Android/Objective-C wrappers and expands TPM unit test coverage to validate default behavior, overrides, and batching behavior.

Changes:

  • Added CFG_INT_TPM_MAX_EVENTS_PER_UPLOAD / maxEventsPerUpload (default 1500) to the runtime configuration surface.
  • Applied the configured max-event-count to EventsUploadContext created by both scheduled uploads and immediate (max-latency) uploads.
  • Exposed the key in Android and Objective-C wrappers and added/updated tests to validate default + override + packaging behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
wrappers/obj-c/ODWLogConfiguration.mm Defines the new Objective-C configuration key constant for max events per upload.
wrappers/obj-c/ODWLogConfiguration.h Declares the new Objective-C configuration key constant for max events per upload.
tests/unittests/TransmissionPolicyManagerTests.cpp Adds test coverage asserting default/overridden max event count and validates batching behavior via storage retrieval.
lib/tpm/TransmissionPolicyManager.cpp Sets requestedMaxCount on created upload contexts based on runtime config.
lib/include/public/ILogConfiguration.hpp Adds public config key constant CFG_INT_TPM_MAX_EVENTS_PER_UPLOAD with documentation.
lib/config/RuntimeConfig_Default.hpp Adds default value 1500 for CFG_INT_TPM_MAX_EVENTS_PER_UPLOAD under the TPM config map.
lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/LogConfigurationKey.java Exposes maxEventsPerUpload through the Android configuration key enum.
lib/android_build/app/src/androidTest/java/com/microsoft/applications/events/maesdktest/LogManagerDDVUnitTest.java Extends Android default-config test to assert the new default value (1500).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/unittests/TransmissionPolicyManagerTests.cpp
Comment 3336129493: the max-events tests modified the shared runtime
configuration and manually restored it, which could leak state if a fatal
ASSERT returned early. Add a scoped restoration helper and use it in both
config-mutating tests so the previous value is restored on every exit path.
  Verified in tests/unittests/TransmissionPolicyManagerTests.cpp.

Validation:
- Win32 Debug UnitTests build and TransmissionPolicyManagerTests.*
- x64 Release UnitTests build and TransmissionPolicyManagerTests.*

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Comment thread wrappers/obj-c/ODWLogConfiguration.h
Comment thread wrappers/obj-c/ODWLogConfiguration.mm
Comment thread tests/unittests/TransmissionPolicyManagerTests.cpp Outdated
Comment thread tests/unittests/TransmissionPolicyManagerTests.cpp Outdated
Comment thread tests/unittests/TransmissionPolicyManagerTests.cpp Outdated
Comments 3336266349/3336266435: Obj-C wrapper comments described the
max-events key as a TPM map rather than a scalar key. Update both comments
to describe max events per upload request and the 0=unlimited behavior.

Comments 3336266468/3336266492/3336266521: redundant mock expectations
implied uploadAsync should route through the mock even though these tests
call uploadAsyncParent directly. Remove the no-op expectations.

Validation:
- Win32 Debug UnitTests build and TransmissionPolicyManagerTests.*
- x64 Release UnitTests build and TransmissionPolicyManagerTests.*

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Comment thread tests/unittests/TransmissionPolicyManagerTests.cpp
Comment thread tests/unittests/TransmissionPolicyManagerTests.cpp Outdated
Comment thread lib/tpm/TransmissionPolicyManager.cpp Outdated
Comment thread lib/tpm/TransmissionPolicyManager.cpp Outdated
Comment 3336387520: the scoped test helper restored the prior config as
unsigned, which could fail to restore the exact Variant value. Store and
restore the previous value as Variant.

Comments 3336387612/3336387635: maxEventsPerUpload converted Variant to
unsigned directly in both upload paths. Add one helper that treats
non-positive values as 0/unlimited and caps oversized values at unsigned
max, then use it for scheduled and immediate uploads.

Comment 3336387579: remove the duplicate paused(false) call in the
batching test.

Validation:
- Win32 Debug UnitTests build and TransmissionPolicyManagerTests.* (43 tests)
- x64 Release UnitTests build and TransmissionPolicyManagerTests.* (43 tests)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@bmehta001 bmehta001 self-assigned this Jun 1, 2026
@bmehta001 bmehta001 closed this Jun 3, 2026
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.

2 participants