Skip to content

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.

NOTE

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:

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

NOTE

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:

yaml
# ...
exporters:
  - kind: bigquery
    projectID: "my-project-id"
    datasetID: "semaphore_events"
    tableName: "feature_flag_evaluations"
    autoMigrate: true
    eventType: "feature"
  - kind: bigquery
    projectID: "my-project-id"
    datasetID: "semaphore_events"
    tableName: "tracking_events"
    autoMigrate: true
    eventType: "tracking"
# ...
Field nameMandatoryTypeDefaultDescription
kindYesstringnoneValue should be bigquery.
This field is mandatory and describes which exporter you are using.
projectIDYesstringnoneID of the GCP project containing the BigQuery dataset.
datasetIDYesstringnoneBigQuery dataset where events will be inserted.
tableNameNostringfeature_flag_evaluationsBigQuery table used by this exporter instance. Set it to your tracking table for eventType: "tracking".
googleCredentialsNostringnoneGoogle credentials JSON. If empty, Application Default Credentials are used.
autoMigrateNobooleanfalseWhen true, the exporter creates the dataset and the table being written if they do not exist.
eventTypeNostringfeatureEvent 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:

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

config := ffclient.Config{
    // ...
    DataExporters: []ffclient.DataExporter{
        {
            ExporterEventType: ffclient.FeatureEventExporter,
            Exporter: &bigqueryexporter.Exporter{
                ProjectID:         "my-project-id",
                DatasetID:         "semaphore_events",
                TableName:         "feature_flag_evaluations",
                AutoMigrate:       true,
                GoogleCredentials: googleCredentials,
            },
        },
        {
            ExporterEventType: ffclient.TrackingEventExporter,
            Exporter: &bigqueryexporter.Exporter{
                ProjectID:         "my-project-id",
                DatasetID:         "semaphore_events",
                TableName:         "tracking_events",
                AutoMigrate:       true,
                GoogleCredentials: googleCredentials,
            },
        },
    },
    // ...
}
client, err := ffclient.New(config)
defer client.Close()
FieldMandatoryDefaultDescription
ProjectIDYesnoneID of the GCP project containing the BigQuery dataset.
DatasetIDYesnoneBigQuery dataset where events will be inserted.
TableNameNofeature_flag_evaluationsBigQuery table used by this exporter instance.
AutoMigrateNofalseWhen true, the exporter creates the dataset and the table being written if they do not exist.
GoogleCredentialsNononeGoogle 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.

Released under the MIT License.