Skip to main content
Version: Next

Google Cloud BigQuery

Overview​

The Google Cloud BigQuery exporter streams feature flag evaluation and tracking events directly to BigQuery using the official streaming-insert API.
info

Google Cloud BigQuery is a bulk exporter. Events are collected in memory and streamed to BigQuery when FlushInterval or MaxEventInMemory is reached.

Configure the relay proxy​

To configure your relay proxy to use the Google Cloud BigQuery exporter, you need to add the following configuration to your relay proxy configuration file:

goff-proxy.yaml
# ...
exporters:
- kind: bigquery
projectID: "my-project-id"
datasetID: "goff_events"
tableName: "feature_flag_evaluations"
googleCredentials: |
{"type":"service_account","project_id":"my-project-id"}
autoMigrate: true
eventType: "feature"
# ...
info

In the relay proxy each exporter is wired to a single eventType (defaulting to feature). To export both evaluation and tracking events, declare two BigQuery exporters, one per eventType:

goff-proxy.yaml
# ...
exporters:
- kind: bigquery
projectID: "my-project-id"
datasetID: "goff_events"
tableName: "feature_flag_evaluations"
autoMigrate: true
eventType: "feature"
- kind: bigquery
projectID: "my-project-id"
datasetID: "goff_events"
tableName: "tracking_events"
autoMigrate: true
eventType: "tracking"
# ...
Field nameMandatoryTypeDefaultDescription
kindstringnoneValue should be bigquery.
This field is mandatory and describes which exporter you are using.
projectIDstringnoneID of the GCP project containing the BigQuery dataset.
datasetIDstringnoneBigQuery dataset where events will be inserted.
tableNamestringfeature_flag_evaluationsBigQuery table used by this exporter instance. Set it to your tracking table for eventType: "tracking".
googleCredentialsstringnoneGoogle credentials JSON. If empty, Application Default Credentials are used.
autoMigratebooleanfalseWhen true, the exporter creates the dataset and the table being written if they do not exist.
eventTypestringfeatureEvent type to export. Use feature for evaluation events or tracking for tracking events.

Configure the GO Module​

To configure your GO module to use the Google Cloud BigQuery exporter, you need to add the following configuration to your ffclient.Config{} object:

example.go
googleCredentials := []byte(`{...}`)

config := ffclient.Config{
// ...
DataExporters: []ffclient.DataExporter{
{
ExporterEventType: ffclient.FeatureEventExporter,
Exporter: &bigqueryexporter.Exporter{
ProjectID: "my-project-id",
DatasetID: "goff_events",
TableName: "feature_flag_evaluations",
AutoMigrate: true,
GoogleCredentials: googleCredentials,
},
},
{
ExporterEventType: ffclient.TrackingEventExporter,
Exporter: &bigqueryexporter.Exporter{
ProjectID: "my-project-id",
DatasetID: "goff_events",
TableName: "tracking_events",
AutoMigrate: true,
GoogleCredentials: googleCredentials,
},
},
},
// ...
}
err := ffclient.Init(config)
defer ffclient.Close()
FieldMandatoryDefaultDescription
ProjectIDnoneID of the GCP project containing the BigQuery dataset.
DatasetIDnoneBigQuery dataset where events will be inserted.
TableNamefeature_flag_evaluationsBigQuery table used by this exporter instance.
AutoMigratefalseWhen true, the exporter creates the dataset and the table being written if they do not exist.
GoogleCredentialsnoneGoogle credentials JSON. If empty, Application Default Credentials are used.

Authentication​

When GoogleCredentials is empty, the exporter relies on Application Default Credentials.

For the relay proxy, set googleCredentials to explicit credentials JSON when ADC is not available. For the GO module, pass explicit credentials JSON in GoogleCredentials.

AutoMigrate​

When autoMigrate / AutoMigrate is enabled, the exporter tries to create the configured dataset and the table it is about to write. Existing datasets and tables are treated as success.

The exporter checks the table configured for the current flush. For example, a tracking exporter with tableName: "tracking_events" ensures tracking_events.

Table schemas​

feature_flag_evaluations​

ColumnBigQuery typeSource field
kindSTRINGKind
context_kindSTRINGContextKind
user_keySTRINGUserKey
creation_dateINTEGERCreationDate
keySTRINGKey
variationSTRINGVariation
valueJSONValue
defaultBOOLDefault
versionSTRINGVersion
sourceSTRINGSource
metadataJSONMetadata

tracking_events​

ColumnBigQuery typeSource field
kindSTRINGKind
context_kindSTRINGContextKind
user_keySTRINGUserKey
creation_dateINTEGERCreationDate
keySTRINGKey
tracking_detailsJSONTrackingDetails
evaluation_contextJSONEvaluationContext

JSON columns are inserted as JSON-marshaled strings.