Skip to content

feat: Enable gzip option for events in server SDK #67

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 2 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/sdk/server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ext.versions = [
"guava": "32.0.1-jre",
"jackson": "2.11.2",
"launchdarklyJavaSdkCommon": "2.1.1",
"launchdarklyJavaSdkInternal": "1.4.0",
"launchdarklyJavaSdkInternal": "1.5.0",
"launchdarklyLogging": "1.1.0",
"okhttp": "4.9.3", // specify this for the SDK build instead of relying on the transitive dependency from okhttp-eventsource
"okhttpEventsource": "4.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static class SdkConfigEventParams {
boolean allAttributesPrivate;
int capacity;
boolean enableDiagnostics;
boolean enableGzip;
String[] globalPrivateAttributes;
Long flushIntervalMs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ private LDConfig buildSdkConfig(SdkConfigParams params, String tag) {
} else {
endpoints.events(params.events.baseUri);
EventProcessorBuilder eb = Components.sendEvents()
.allAttributesPrivate(params.events.allAttributesPrivate);
.allAttributesPrivate(params.events.allAttributesPrivate)
.enableGzipCompression(params.events.enableGzip);
if (params.events.capacity > 0) {
eb.capacity(params.events.capacity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ public class TestService {
"client-prereq-events",
"context-type",
"evaluation-hooks",
"event-gzip",
"event-sampling",
"filtering",
"inline-context-all",
"migrations",
"optional-event-gzip",
"server-side",
"service-endpoints",
"strongly-typed",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public EventProcessor build(ClientContext context) {
null, // use default request path for server-side events
null, // use default request path for client-side events
0, // 0 means default retry delay
enableGzipCompression,
context.getBaseLogger().subLogger(Loggers.EVENTS_LOGGER_NAME));
} else {
eventSender = new EventSenderWrapper(eventSenderConfigurer.build(context));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public abstract class EventProcessorBuilder implements ComponentConfigurer<Event
protected int userKeysCapacity = DEFAULT_USER_KEYS_CAPACITY;
protected Duration userKeysFlushInterval = DEFAULT_USER_KEYS_FLUSH_INTERVAL;
protected ComponentConfigurer<EventSender> eventSenderConfigurer = null;
protected boolean enableGzipCompression = false;

/**
* Sets whether or not all optional user attributes should be hidden from LaunchDarkly.
Expand Down Expand Up @@ -211,4 +212,20 @@ public EventProcessorBuilder userKeysFlushInterval(Duration userKeysFlushInterva
this.userKeysFlushInterval = userKeysFlushInterval == null ? DEFAULT_USER_KEYS_FLUSH_INTERVAL : userKeysFlushInterval;
return this;
}

/**
* Enables gzip compression for event payloads.
* <p>
* When enabled, event payloads will be compressed using gzip before being sent to LaunchDarkly.
* This can significantly reduce bandwidth usage when sending large event payloads.
* <p>
* The default value is false.
*
* @param enableGzipCompression whether to enable gzip compression
* @return the builder
*/
public EventProcessorBuilder enableGzipCompression(boolean enableGzipCompression) {
this.enableGzipCompression = enableGzipCompression;
return this;
}
}