Skip to content

feat: Add an option to compress event payloads with gzip - #414

Open
abelonogov-ld wants to merge 3 commits into
mainfrom
andrey/event-compression-default-on
Open

abelonogov-ld wants to merge 3 commits into
mainfrom
andrey/event-compression-default-on

Conversation

@abelonogov-ld

@abelonogov-ld abelonogov-ld commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

The Android counterpart of launchdarkly/ios-client-sdk#543. Matches iOS's LDConfig.enableCompression, which is opt-in.

Describe the solution you've provided

Adds an opt-in setting to send event payloads gzip-encoded. Compression itself is java-sdk-internal's: DefaultEventSender already gzips analytics and diagnostic payloads and sets Content-Encoding: gzip when asked to, and ComponentsImpl was passing a hardcoded false.

  • EventProcessorBuilder.enableCompression(boolean), default false, named after iOS's LDConfig.enableCompression. Off by default because older Relay Proxy versions do not accept gzip-encoded event payloads, so existing applications see no change.
  • ComponentsImpl passes it to DefaultEventSender.
  • EventCompressionTest: a default event processor sends plain JSON with no Content-Encoding; with compression enabled it sends Content-Encoding: gzip and no plain JSON.
  • LDClientEventTest reads gzip-encoded bodies when present.
  • Contract tests: the service declares event-gzip and optional-event-gzip, as iOS does, and applies enableGzip from the harness.

Describe alternatives you've considered

Turning compression on by default. The client SDK cannot tell whether its events URL is a Relay Proxy, or which version, so a default of true would break applications sending events through an older Relay Proxy on upgrade.

Additional context

The diagnostic configuration payload is unchanged; it does not report this setting.

Verified: EventCompressionTest, 2 tests, 0 failures; instrumented tests compile.

Adds EventProcessorBuilder.enableCompression(boolean), defaulting to true,
and passes it to the event sender in place of the hardcoded false, so
analytics and diagnostic event payloads are sent gzip-encoded. Applications
sending events through a relay proxy that does not accept gzip-encoded
payloads can set it to false. Matches LDConfig.enableCompression in the iOS SDK.

The contract test service now declares event-gzip and optional-event-gzip
and applies enableGzip from the harness.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abelonogov-ld
abelonogov-ld requested a review from a team as a code owner October 20, 2026 00:37
abelonogov-ld and others added 2 commits October 19, 2026 18:23
Older Relay Proxy versions do not accept gzip-encoded event payloads, so
enableCompression is opt-in, matching iOS.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abelonogov-ld abelonogov-ld changed the title feat: Compress event payloads with gzip by default feat: Add an option to compress event payloads with gzip Oct 20, 2026

This branch has not been deployed

No deployments
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.

1 participant