Event export pipeline
The event export pipeline turns feature evaluations and explicit tracking calls into event records. It routes each record to the configured exporters while keeping flag evaluation independent from slow or unavailable destination systems.
Event sources
The pipeline accepts two event types. A feature-evaluation event records a flag result when the flag asks for tracking. A tracking event records an application-defined action with its evaluation context and extra details.
Feature-evaluation events
A feature-evaluation event describes the result returned by a flag evaluation. It includes the flag key, user identity, context kind, variation, returned value, failure/default status, flag version, event source, and optional exporter metadata. The event is created only when the evaluation result has tracking enabled. variation.go.
The evaluation path creates this event in the background and sends it to the feature-event manager. This keeps event collection from blocking the caller that requested the flag value. The source is marked as SERVER for this path, while metadata comes from protected context fields intended for exporters. The event timestamp is stored as a Unix timestamp, and the payload supports JSON, CSV, and Parquet-oriented output formats. exporter/feature_event.go.
References: variation.go• L304-345 exporter/feature_event.go• L13-41 exporter/feature_event.go• L43-86 exporter/feature_event.go• L103-133
Tracking events
A tracking event describes a named action that the application sends through Track. It records the event name as its key, the user identity, the user or anonymous-user context kind, the full evaluation context, and application-supplied tracking details. tracking.go.
The event enters the tracking-event manager only when at least one tracking exporter is configured. This lets applications use explicit tracking without changing the feature-evaluation event stream. tracking.go.
References: tracking.go• L10-32 exporter/tracking_event.go• L10-38
Event routing
Configuration decides which event stream receives each exporter. The client builds one manager for feature events and one manager for tracking events, so an exporter consumes only the event type it is configured to receive.
Exporter selection
Each data-exporter configuration names a destination, a delivery mode, and flush limits. The event type is feature by default; setting it to tracking routes the exporter to the tracking stream instead. A single configuration and the list form are combined, so several destinations can receive the same stream independently. config_exporter.go, config.go.
The client creates the managers during startup. Offline mode does not initialize data export, and a missing manager means that events of that type are ignored rather than stored. feature_flag.go, config.go.
References: config_exporter.go• L9-36 config.go• L74-95 config.go• L176-187 feature_flag.go• L122-156
Shared event stream
Each event type has one in-memory event store shared by all exporters for that type. Every configured exporter gets its own consumer position, so one slow destination does not hold back another destination from reading the same events.
The manager adds an event once and then checks each consumer. A consumer can flush on its own schedule or when its pending count reaches its configured limit. This fan-out model makes multiple destinations independent while retaining one source record for the stream.
References: exporter/manager.go• L12-64 exporter/event_store.go• L13-39 exporter/event_store.go• L50-79
Queue and delivery
The event store provides the short-lived handoff between event creation and destination delivery. It uses ordered offsets for each exporter and advances an exporter only after its delivery callback succeeds.
Event store
The event store is an in-memory queue with per-consumer offsets. Adding an event appends it with a new offset. A consumer reads all events after its own offset, and successful processing moves that offset to the end of the read batch.
If delivery returns an error, the consumer offset does not move. The same events remain pending for a later flush. Periodic cleanup removes events only after every consumer has passed them, which preserves data for slower exporters.
References: exporter/event_store.go• L50-75 exporter/event_store.go• L98-127 exporter/event_store.go• L147-168 exporter/event_store.go• L194-232
Flush behavior
Bulk exporters collect events and flush them on a timer or when their pending count reaches MaxEventInMemory. Non-bulk exporters flush after each added event, which suits destinations that send one event at a time. exporter/data_exporter.go, exporter/manager.go.
If no values are supplied, a bulk exporter uses a 60-second flush interval and a 100,000-event memory limit. Queue cleanup uses a one-minute interval unless the client provides another value. These limits control delivery timing and memory use; they do not change the event payload. exporter/data_exporter.go, exporter/manager.go.
The delivery call receives a batch of exportable events through the exporter contract. The current contract accepts both feature and tracking events. Older contracts remain supported for feature events only. exporter/exporter.go, exporter/data_exporter.go.
References: exporter/data_exporter.go• L14-37 exporter/data_exporter.go• L74-123 exporter/data_exporter.go• L135-180 exporter/manager.go• L46-64
Shutdown delivery
Client shutdown first waits for background feature-event collection to finish. It then stops both managers, and each exporter flushes its pending events before the event store stops its cleanup task. feature_flag.go, exporter/data_exporter.go.
This order gives events already created by an evaluation a chance to enter the store before final delivery. It does not turn the in-memory queue into durable storage; events still depend on the process remaining available until shutdown completes.
References: feature_flag.go• L159-174 variation.go• L320-344 exporter/data_exporter.go• L93-106 exporter/manager.go• L67-81
The following diagram shows how an evaluation or tracking call becomes a stream record and then reaches each configured destination.
flowchart LR
A[Flag evaluation] --> B{Tracking enabled?}
B -- yes --> C[Feature event]
D[Track call] --> E[Tracking event]
C --> F[Event manager]
E --> G[Tracking event manager]
F --> H[Shared in-memory stream]
G --> I[Shared in-memory stream]
H --> J[Exporter consumer 1]
H --> K[Exporter consumer 2]
I --> L[Tracking exporter consumer]
J --> M[Configured destination]
K --> N[Configured destination]
L --> O[Configured destination]
Event delivery contract
An exporter is the destination-specific boundary of the pipeline. It declares whether it can receive batches and implements delivery for a collection of exportable events.
Exporter interface
The exporter contract exposes Export for delivery and IsBulk for scheduling. The event pipeline owns collection, timing, retry-on-error through the unchanged consumer offset, and shutdown flushes. The exporter owns the final encoding and write to its destination.
Every event supports JSON and template-based CSV formatting through the shared exportable-event contract. Destinations can also map the typed event fields to their own format, such as a table row, message, file record, or trace. exporter/exportable_event.go, exporter/exporter.go.
References: exporter/exportable_event.go• L7-18 exporter/exporter.go• L24-31
Exporter integrations
Built-in integrations deliver events to local files, logs, HTTP webhooks, cloud storage and data services, message queues or streams, and OpenTelemetry. The pipeline treats these integrations through the same contract, while each integration defines its destination format and delivery rules.
BigQuery and Redshift accept feature and tracking batches and map them to destination-specific event records. BigQuery can create the target table when enabled and keeps large inserts within service limits. Redshift can create the event table when enabled, sends rows in transactions, and waits for the cloud statement to finish before reporting success. These integrations are described in Event exporter integrations.
References: cmd/…/exporter.go• L119-153 exporter/…/exporter.go• L19-30 exporter/…/exporter.go• L20-50 exporter/…/exporter.go• L19-29 exporter/…/exporter.go• L70-123 exporter/…/exporter.go• L146-175 exporter/…/exporter.go• L216-265
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the
ExporterEventTypevalues aligned with the manager type selected during client startup. - Keep both event structs compatible with the fields expected by JSON, CSV, Parquet, and destination-specific encoders.
- Preserve the consumer-offset rule when changing delivery error handling. Advancing the offset before a successful export can lose events.
- Review shutdown ordering when changing background event collection or manager stop behavior. A change can leave events in the in-memory stream.
- Update destination validation when adding an exporter kind so configuration accepts the fields needed to create that destination.
- Keep feature and tracking destination schemas aligned with their event payloads. BigQuery row schemas and Redshift table columns must change together with event fields.
- Preserve destination batch limits and transaction completion checks when changing the BigQuery or Redshift exporters. A service limit or unfinished Redshift statement must remain visible as an export failure.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| No exporter is configured for an event type | The event is not stored or delivered | Configure a data exporter with the matching eventType |
| An exporter returns an error | Its consumer offset stays unchanged and the batch remains pending | Inspect exporter errors and make the destination available before the next flush |
| A bulk exporter reaches its memory limit | It flushes before the normal timer | Set MaxEventInMemory for the destination's expected event rate |
| A destination is slower than its peers | Only that destination's pending count grows; the other consumers continue | Watch destination health and queue pressure |
| The process exits before client shutdown completes | Events still held in memory can be lost | Call Close as part of controlled shutdown |
| A legacy exporter receives tracking events | The delivery path rejects the unsupported event type | Use the current exporter contract for tracking events |
| A BigQuery or Redshift batch exceeds destination limits | The export fails and the consumer keeps the events pending | Let the integration split batches and keep event payloads within destination field limits |
| A Redshift event cannot be encoded or is too large for its target column | The exporter skips that event and logs a warning, so the invalid event does not block later events | Keep event values JSON-compatible and monitor exporter warnings |
| A Redshift statement does not finish before its timeout | The transaction is cancelled and the export reports an error | Set a suitable statement timeout and keep the Redshift target available |
Key files
| File | Why to read it |
|---|---|
| variation.go | Shows when a tracked evaluation becomes a feature event and enters background collection |
| tracking.go | Shows how an explicit tracking call becomes a tracking event |
| feature_flag.go | Shows how event managers are created, started, and stopped |
| config_exporter.go | Defines event type and delivery controls exposed to client configuration |
| exporter/feature_event.go | Defines the feature-evaluation event payload and its shared output formats |
| exporter/tracking_event.go | Defines the tracking event payload |
| exporter/manager.go | Coordinates the shared stream and its exporter consumers |
| exporter/event_store.go | Defines offsets, pending-event processing, and safe queue cleanup |
| exporter/data_exporter.go | Defines flush timing, batch limits, delivery, and shutdown behavior |
| exporter/exporter.go | Defines the contract that destination integrations implement |
| exporter/…/exporter.go | Shows how both event types become bounded BigQuery row batches |
| exporter/…/exporter.go | Shows how both event types become validated Redshift transactions |
| cmd/…/exporter.go | Lists supported exporter kinds and validates destination requirements |