Class EventProcessorBuilder
- java.lang.Object
-
- com.launchdarkly.sdk.server.integrations.EventProcessorBuilder
-
- All Implemented Interfaces:
EventProcessorFactory
public abstract class EventProcessorBuilder extends java.lang.Object implements EventProcessorFactory
Contains methods for configuring delivery of analytics events.The SDK normally buffers analytics events and sends them to LaunchDarkly at intervals. If you want to customize this behavior, create a builder with
Components.sendEvents()
, change its properties with the methods of this class, and pass it toLDConfig.Builder.events(EventProcessorFactory)
:LDConfig config = new LDConfig.Builder() .events(Components.sendEvents().capacity(5000).flushIntervalSeconds(2)) .build();
Note that this class is abstract; the actual implementation is created by calling
Components.sendEvents()
.- Since:
- 4.12.0
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
allAttributesPrivate
protected java.net.URI
baseURI
protected int
capacity
static int
DEFAULT_CAPACITY
The default value forcapacity(int)
.static java.time.Duration
DEFAULT_DIAGNOSTIC_RECORDING_INTERVAL
The default value fordiagnosticRecordingInterval(Duration)
: 15 minutes.static java.time.Duration
DEFAULT_FLUSH_INTERVAL
The default value forflushInterval(Duration)
: 5 seconds.static int
DEFAULT_USER_KEYS_CAPACITY
The default value foruserKeysCapacity(int)
.static java.time.Duration
DEFAULT_USER_KEYS_FLUSH_INTERVAL
The default value foruserKeysFlushInterval(Duration)
: 5 minutes.protected java.time.Duration
diagnosticRecordingInterval
protected EventSenderFactory
eventSenderFactory
protected java.time.Duration
flushInterval
protected boolean
inlineUsersInEvents
static java.time.Duration
MIN_DIAGNOSTIC_RECORDING_INTERVAL
The minimum value fordiagnosticRecordingInterval(Duration)
: 60 seconds.protected java.util.Set<UserAttribute>
privateAttributes
protected int
userKeysCapacity
protected java.time.Duration
userKeysFlushInterval
-
Constructor Summary
Constructors Constructor Description EventProcessorBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EventProcessorBuilder
allAttributesPrivate(boolean allAttributesPrivate)
Sets whether or not all optional user attributes should be hidden from LaunchDarkly.EventProcessorBuilder
baseURI(java.net.URI baseURI)
Sets a custom base URI for the events service.EventProcessorBuilder
capacity(int capacity)
Set the capacity of the events buffer.EventProcessorBuilder
diagnosticRecordingInterval(java.time.Duration diagnosticRecordingInterval)
Sets the interval at which periodic diagnostic data is sent.EventProcessorBuilder
eventSender(EventSenderFactory eventSenderFactory)
Specifies a custom implementation for event delivery.EventProcessorBuilder
flushInterval(java.time.Duration flushInterval)
Sets the interval between flushes of the event buffer.EventProcessorBuilder
inlineUsersInEvents(boolean inlineUsersInEvents)
Sets whether to include full user details in every analytics event.EventProcessorBuilder
privateAttributeNames(java.lang.String... attributeNames)
Marks a set of attribute names as private.EventProcessorBuilder
privateAttributes(UserAttribute... attributes)
Marks a set of attribute names as private.EventProcessorBuilder
userKeysCapacity(int userKeysCapacity)
Sets the number of user keys that the event processor can remember at any one time.EventProcessorBuilder
userKeysFlushInterval(java.time.Duration userKeysFlushInterval)
Sets the interval at which the event processor will reset its cache of known user keys.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.launchdarkly.sdk.server.interfaces.EventProcessorFactory
createEventProcessor
-
-
-
-
Field Detail
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITY
The default value forcapacity(int)
.- See Also:
- Constant Field Values
-
DEFAULT_DIAGNOSTIC_RECORDING_INTERVAL
public static final java.time.Duration DEFAULT_DIAGNOSTIC_RECORDING_INTERVAL
The default value fordiagnosticRecordingInterval(Duration)
: 15 minutes.
-
DEFAULT_FLUSH_INTERVAL
public static final java.time.Duration DEFAULT_FLUSH_INTERVAL
The default value forflushInterval(Duration)
: 5 seconds.
-
DEFAULT_USER_KEYS_CAPACITY
public static final int DEFAULT_USER_KEYS_CAPACITY
The default value foruserKeysCapacity(int)
.- See Also:
- Constant Field Values
-
DEFAULT_USER_KEYS_FLUSH_INTERVAL
public static final java.time.Duration DEFAULT_USER_KEYS_FLUSH_INTERVAL
The default value foruserKeysFlushInterval(Duration)
: 5 minutes.
-
MIN_DIAGNOSTIC_RECORDING_INTERVAL
public static final java.time.Duration MIN_DIAGNOSTIC_RECORDING_INTERVAL
The minimum value fordiagnosticRecordingInterval(Duration)
: 60 seconds.
-
allAttributesPrivate
protected boolean allAttributesPrivate
-
baseURI
protected java.net.URI baseURI
-
capacity
protected int capacity
-
diagnosticRecordingInterval
protected java.time.Duration diagnosticRecordingInterval
-
flushInterval
protected java.time.Duration flushInterval
-
inlineUsersInEvents
protected boolean inlineUsersInEvents
-
privateAttributes
protected java.util.Set<UserAttribute> privateAttributes
-
userKeysCapacity
protected int userKeysCapacity
-
userKeysFlushInterval
protected java.time.Duration userKeysFlushInterval
-
eventSenderFactory
protected EventSenderFactory eventSenderFactory
-
-
Method Detail
-
allAttributesPrivate
public EventProcessorBuilder allAttributesPrivate(boolean allAttributesPrivate)
Sets whether or not all optional user attributes should be hidden from LaunchDarkly.If this is
true
, all user attribute values (other than the key) will be private, not just the attributes specified inprivateAttributeNames(String...)
or on a per-user basis withLDUser.Builder
methods. By default, it isfalse
.- Parameters:
allAttributesPrivate
- true if all user attributes should be private- Returns:
- the builder
- See Also:
privateAttributeNames(String...)
,LDUser.Builder
-
baseURI
public EventProcessorBuilder baseURI(java.net.URI baseURI)
Sets a custom base URI for the events service.You will only need to change this value in the following cases:
- You are using the Relay Proxy with
event forwarding enabled. Set
streamUri
to the base URI of the Relay Proxy instance. - You are connecting to a test server or a nonstandard endpoint for the LaunchDarkly service.
- Parameters:
baseURI
- the base URI of the events service; null to use the default- Returns:
- the builder
- You are using the Relay Proxy with
event forwarding enabled. Set
-
capacity
public EventProcessorBuilder capacity(int capacity)
Set the capacity of the events buffer.The client buffers up to this many events in memory before flushing. If the capacity is exceeded before the buffer is flushed (see
flushInterval(Duration)
, events will be discarded. Increasing the capacity means that events are less likely to be discarded, at the cost of consuming more memory.The default value is
DEFAULT_CAPACITY
.- Parameters:
capacity
- the capacity of the event buffer- Returns:
- the builder
-
diagnosticRecordingInterval
public EventProcessorBuilder diagnosticRecordingInterval(java.time.Duration diagnosticRecordingInterval)
Sets the interval at which periodic diagnostic data is sent.The default value is
DEFAULT_DIAGNOSTIC_RECORDING_INTERVAL
; the minimum value isMIN_DIAGNOSTIC_RECORDING_INTERVAL
. This property is ignored ifLDConfig.Builder.diagnosticOptOut(boolean)
is set totrue
.- Parameters:
diagnosticRecordingInterval
- the diagnostics interval; null to use the default- Returns:
- the builder
- See Also:
LDConfig.Builder.diagnosticOptOut(boolean)
-
eventSender
public EventProcessorBuilder eventSender(EventSenderFactory eventSenderFactory)
Specifies a custom implementation for event delivery.The standard event delivery implementation sends event data via HTTP/HTTPS to the LaunchDarkly events service endpoint (or any other endpoint specified with
baseURI(URI)
. Providing a custom implementation may be useful in tests, or if the event data needs to be stored and forwarded.- Parameters:
eventSenderFactory
- a factory for anEventSender
implementation- Returns:
- the builder
-
flushInterval
public EventProcessorBuilder flushInterval(java.time.Duration flushInterval)
Sets the interval between flushes of the event buffer.Decreasing the flush interval means that the event buffer is less likely to reach capacity.
The default value is
DEFAULT_FLUSH_INTERVAL
.- Parameters:
flushInterval
- the flush interval; null to use the default- Returns:
- the builder
-
inlineUsersInEvents
public EventProcessorBuilder inlineUsersInEvents(boolean inlineUsersInEvents)
Sets whether to include full user details in every analytics event.The default is
false
: events will only include the user key, except for one "index" event that provides the full details for the user).- Parameters:
inlineUsersInEvents
- true if you want full user details in each event- Returns:
- the builder
-
privateAttributeNames
public EventProcessorBuilder privateAttributeNames(java.lang.String... attributeNames)
Marks a set of attribute names as private.Any users sent to LaunchDarkly with this configuration active will have attributes with these names removed. This is in addition to any attributes that were marked as private for an individual user with
LDUser.Builder
methods.Using
privateAttributes(UserAttribute...)
is preferable to avoid the possibility of misspelling a built-in attribute.- Parameters:
attributeNames
- a set of names that will be removed from user data set to LaunchDarkly- Returns:
- the builder
- See Also:
allAttributesPrivate(boolean)
,LDUser.Builder
-
privateAttributes
public EventProcessorBuilder privateAttributes(UserAttribute... attributes)
Marks a set of attribute names as private.Any users sent to LaunchDarkly with this configuration active will have attributes with these names removed. This is in addition to any attributes that were marked as private for an individual user with
LDUser.Builder
methods.- Parameters:
attributes
- a set of attributes that will be removed from user data set to LaunchDarkly- Returns:
- the builder
- See Also:
allAttributesPrivate(boolean)
,LDUser.Builder
,privateAttributeNames(java.lang.String...)
-
userKeysCapacity
public EventProcessorBuilder userKeysCapacity(int userKeysCapacity)
Sets the number of user keys that the event processor can remember at any one time.To avoid sending duplicate user details in analytics events, the SDK maintains a cache of recently seen user keys, expiring at an interval set by
userKeysFlushInterval(Duration)
.The default value is
DEFAULT_USER_KEYS_CAPACITY
.- Parameters:
userKeysCapacity
- the maximum number of user keys to remember- Returns:
- the builder
-
userKeysFlushInterval
public EventProcessorBuilder userKeysFlushInterval(java.time.Duration userKeysFlushInterval)
Sets the interval at which the event processor will reset its cache of known user keys.The default value is
DEFAULT_USER_KEYS_FLUSH_INTERVAL
.- Parameters:
userKeysFlushInterval
- the flush interval; null to use the default- Returns:
- the builder
-
-