π Export evaluation data
Overviewβ
Sometimes when you are using feature flags in your application, you may want to collect data on how the flags are being used. This is the reason why GO Feature Flag has the exporter concept, a mechanism that store an event for each evaluation of a flag.
About exportersβ
To export evaluation data, you have to configure the target where you want to export the data.
GO Feature Flag provides a list of built-in exporters that you can use out of the box. The goal is to let you choose the one that fits your needs the best.
During flag evaluation, the key, flag variation and other non-sensitive information used are collected and cached for a configurable period of time. When the cache is full or the cache duration is reached, the exporter is called with the list of events to store it where you want.
You have 2 different ways to specify a exporter depending on if you are using the GO Module or the Relay Proxy. In all the details pages of the exporters bellow you will have an example for both examples.
Available Exportersβ
Bellow is the full list of exporters that are available in GO Feature Flag.
Custom exporterβ
If you have a specific use case that is not covered by the built-in exporters, you can create your own custom exporter.
To create a custom exporter you must have a struct
that implements the exporter.Exporter interface.
type Exporter interface {
// Export will send the data to the exporter.
Export(context.Context, *fflog.FFLogger, []exporter.FeatureEvent) error
// IsBulk return false if we should directly send the data as soon as it is produced
// and true if we collect the data to send them in bulk.
IsBulk() bool
}
Export(...)
is called asynchronously with a list ofexporter.FeatureEvent
that have been collected. It is your responsibility to store them where you want.IsBulk()
function should return false if the exporter can handle the results in stream mode. If you decide to manage it in streaming mode, everytime we call a variation the Export function will be called with only on event in the list.
If you think your custom exporter could be useful for others, feel free to open a pull request to add it to the list of available exporters.
If you are using a custom exporter, it is easy to use it for the GO Module, but if you want to use it in the relay proxy you will have to recompile it yourself.