Class EventProcessorBuilder
Contains methods for configuring delivery of analytics events.
Inherited Members
Namespace: LaunchDarkly.Sdk.Server.Integrations
Assembly: LaunchDarkly.ServerSdk.dll
Syntax
public sealed class EventProcessorBuilder : IComponentConfigurer<IEventProcessor>, IDiagnosticDescription
Remarks
The SDK normally buffers analytics events and sends them to LaunchDarkly at intervals. If you want to customize this behavior, create a builder with SendEvents(), change its properties with the methods of this class, and pass it to Events(IComponentConfigurer<IEventProcessor>).
Examples
var config = Configuration.Builder(sdkKey)
.Events(
Components.SendEvents().Capacity(5000).FlushInterval(TimeSpan.FromSeconds(2))
)
.Build();
Constructors
View SourceEventProcessorBuilder()
Declaration
public EventProcessorBuilder()
Fields
| Edit this page View SourceDefaultCapacity
The default value for Capacity(int).
Declaration
public const int DefaultCapacity = 10000
Field Value
Type | Description |
---|---|
int |
DefaultContextKeysCapacity
The default value for ContextKeysCapacity(int).
Declaration
public const int DefaultContextKeysCapacity = 1000
Field Value
Type | Description |
---|---|
int |
DefaultContextKeysFlushInterval
The default value for ContextKeysFlushInterval(TimeSpan).
Declaration
public static readonly TimeSpan DefaultContextKeysFlushInterval
Field Value
Type | Description |
---|---|
TimeSpan |
DefaultDiagnosticRecordingInterval
The default value for DiagnosticRecordingInterval(TimeSpan).
Declaration
public static readonly TimeSpan DefaultDiagnosticRecordingInterval
Field Value
Type | Description |
---|---|
TimeSpan |
DefaultFlushInterval
The default value for FlushInterval(TimeSpan).
Declaration
public static readonly TimeSpan DefaultFlushInterval
Field Value
Type | Description |
---|---|
TimeSpan |
MinimumDiagnosticRecordingInterval
The minimum value for DiagnosticRecordingInterval(TimeSpan).
Declaration
public static readonly TimeSpan MinimumDiagnosticRecordingInterval
Field Value
Type | Description |
---|---|
TimeSpan |
Methods
| Edit this page View SourceAllAttributesPrivate(bool)
Sets whether or not all optional context attributes should be hidden from LaunchDarkly.
Declaration
public EventProcessorBuilder AllAttributesPrivate(bool allAttributesPrivate)
Parameters
Type | Name | Description |
---|---|---|
bool | allAttributesPrivate | true if all context attributes should be private |
Returns
Type | Description |
---|---|
EventProcessorBuilder | the builder |
Remarks
If this is true, all contextattribute values (other than the key) will be private, not just the attributes specified in PrivateAttributes(params string[]) or on a per-context basis with ContextBuilder methods. By default, it is false.
Build(LdClientContext)
Called internally by the SDK to create an implementation instance. Applications should not need to call this method.
Declaration
public IEventProcessor Build(LdClientContext context)
Parameters
Type | Name | Description |
---|---|---|
LdClientContext | context | provides configuration properties and other components from the current SDK client instance |
Returns
Type | Description |
---|---|
IEventProcessor | a instance of the component type |
Capacity(int)
Sets the capacity of the events buffer.
Declaration
public EventProcessorBuilder Capacity(int capacity)
Parameters
Type | Name | Description |
---|---|---|
int | capacity | the capacity of the event buffer |
Returns
Type | Description |
---|---|
EventProcessorBuilder | the builder |
Remarks
The client buffers up to this many events in memory before flushing. If the capacity is exceeded before the buffer is flushed (see FlushInterval(TimeSpan)), 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 DefaultCapacity. A zero or negative value will be changed to the default.
ContextKeysCapacity(int)
Sets the number of context keys that the event processor can remember at any one time.
Declaration
public EventProcessorBuilder ContextKeysCapacity(int contextKeysCapacity)
Parameters
Type | Name | Description |
---|---|---|
int | contextKeysCapacity | the maximum number of context keys to remember |
Returns
Type | Description |
---|---|
EventProcessorBuilder | the builder |
Remarks
To avoid sending duplicate context details in analytics events, the SDK maintains a cache of recently seen contexts, expiring at an interval set by ContextKeysFlushInterval(TimeSpan). The default value for the size of this cache is DefaultContextKeysCapacity. A zero or negative value will be changed to the default.
See Also
| Edit this page View SourceContextKeysFlushInterval(TimeSpan)
Sets the interval at which the event processor will reset its cache of known context keys.
Declaration
public EventProcessorBuilder ContextKeysFlushInterval(TimeSpan contextKeysFlushInterval)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | contextKeysFlushInterval | the flush interval |
Returns
Type | Description |
---|---|
EventProcessorBuilder | the builder |
Remarks
The default value is DefaultContextKeysFlushInterval. A zero or negative value will be changed to the default.
DescribeConfiguration(LdClientContext)
Called internally by the SDK to inspect the configuration. Applications do not need to call this method.
Declaration
public LdValue DescribeConfiguration(LdClientContext context)
Parameters
Type | Name | Description |
---|---|---|
LdClientContext | context | SDK configuration/component information |
Returns
Type | Description |
---|---|
LdValue | a JSON value |
DiagnosticRecordingInterval(TimeSpan)
Sets the interval at which periodic diagnostic data is sent.
Declaration
public EventProcessorBuilder DiagnosticRecordingInterval(TimeSpan diagnosticRecordingInterval)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | diagnosticRecordingInterval | the diagnostics interval |
Returns
Type | Description |
---|---|
EventProcessorBuilder | the builder |
Remarks
The default value is DefaultDiagnosticRecordingInterval; the minimum value is MinimumDiagnosticRecordingInterval. This property is ignored if DiagnosticOptOut(bool) is set to true.
FlushInterval(TimeSpan)
Sets the interval between flushes of the event buffer.
Declaration
public EventProcessorBuilder FlushInterval(TimeSpan flushInterval)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | flushInterval | the flush interval |
Returns
Type | Description |
---|---|
EventProcessorBuilder | the builder |
Remarks
Decreasing the flush interval means that the event buffer is less likely to reach capacity. The default value is DefaultFlushInterval. A zero or negative value will be changed to the default.
PrivateAttributes(params string[])
Marks a set of attribute names or subproperties as private.
Declaration
public EventProcessorBuilder PrivateAttributes(params string[] attributes)
Parameters
Type | Name | Description |
---|---|---|
string[] | attributes | a set of names or paths that will be removed from context data sent to LaunchDarkly |
Returns
Type | Description |
---|---|
EventProcessorBuilder | the builder |
Remarks
Any contexts 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 context with ContextBuilder methods.
If and only if a parameter starts with a slash, it is interpreted as a slash-delimited path that can denote a nested property within a JSON object. For instance, "/address/street" means that if there is an attribute called "address" that is a JSON object, and one of the object's properties is "street", the "street" property will be redacted from the analytics data but other properties within "address" will still be sent. This syntax also uses the JSON Pointer convention of escaping a literal slash character as "~1" and a tilde as "~0".
This method replaces any previous PrivateAttributes(params string[]) that were set on the same builder, rather than adding to them.