diff --git a/providers/go-feature-flag/pkg/controller/goff_api.go b/providers/go-feature-flag/pkg/controller/goff_api.go index 772d4d983..3a9057f51 100644 --- a/providers/go-feature-flag/pkg/controller/goff_api.go +++ b/providers/go-feature-flag/pkg/controller/goff_api.go @@ -22,8 +22,8 @@ type GoFeatureFlagApiOptions struct { // (This feature is available only if you are using GO Feature Flag relay proxy v1.7.0 or above) // Default: null APIKey string - // Metadata (optional) If we set metadata, it will be sent with every data collection requests along with the events. - Metadata map[string]interface{} + // ExporterMetadata (optional) If we set metadata, it will be sent with every data collection requests along with the events. + ExporterMetadata map[string]interface{} } type GoFeatureFlagAPI struct { @@ -44,7 +44,7 @@ func (g *GoFeatureFlagAPI) CollectData(events []model.FeatureEvent) error { reqBody := model.DataCollectorRequest{ Events: events, - Meta: g.options.Metadata, + Meta: g.options.ExporterMetadata, } jsonData, err := json.Marshal(reqBody) diff --git a/providers/go-feature-flag/pkg/controller/goff_api_test.go b/providers/go-feature-flag/pkg/controller/goff_api_test.go index f28d98049..74ee3de17 100644 --- a/providers/go-feature-flag/pkg/controller/goff_api_test.go +++ b/providers/go-feature-flag/pkg/controller/goff_api_test.go @@ -28,9 +28,9 @@ func Test_CollectDataAPI(t *testing.T) { name: "Valid api call", wantErr: assert.NoError, options: controller.GoFeatureFlagApiOptions{ - Endpoint: "http://localhost:1031", - APIKey: "", - Metadata: map[string]interface{}{"openfeature": true, "provider": "go"}, + Endpoint: "http://localhost:1031", + APIKey: "", + ExporterMetadata: map[string]interface{}{"openfeature": true, "provider": "go"}, }, events: []model.FeatureEvent{ { @@ -75,9 +75,9 @@ func Test_CollectDataAPI(t *testing.T) { name: "Valid api call with API Key", wantErr: assert.NoError, options: controller.GoFeatureFlagApiOptions{ - Endpoint: "http://localhost:1031", - APIKey: "my-key", - Metadata: map[string]interface{}{"openfeature": true, "provider": "go"}, + Endpoint: "http://localhost:1031", + APIKey: "my-key", + ExporterMetadata: map[string]interface{}{"openfeature": true, "provider": "go"}, }, events: []model.FeatureEvent{ { diff --git a/providers/go-feature-flag/pkg/provider.go b/providers/go-feature-flag/pkg/provider.go index 3f8f78369..2d9123405 100644 --- a/providers/go-feature-flag/pkg/provider.go +++ b/providers/go-feature-flag/pkg/provider.go @@ -55,17 +55,17 @@ func NewProviderWithContext(ctx context.Context, options ProviderOptions) (*Prov cacheCtrl := controller.NewCache(options.FlagCacheSize, options.FlagCacheTTL, options.DisableCache) // Adding metadata to the GO Feature Flag provider to be sent to the exporter - if options.GOFeatureFlagMetadata == nil { - options.GOFeatureFlagMetadata = make(map[string]interface{}) + if options.ExporterMetadata == nil { + options.ExporterMetadata = make(map[string]interface{}) } - options.GOFeatureFlagMetadata["provider"] = "go" - options.GOFeatureFlagMetadata["openfeature"] = true + options.ExporterMetadata["provider"] = "go" + options.ExporterMetadata["openfeature"] = true goffAPI := controller.NewGoFeatureFlagAPI(controller.GoFeatureFlagApiOptions{ - Endpoint: options.Endpoint, - HTTPClient: options.HTTPClient, - APIKey: options.APIKey, - Metadata: options.GOFeatureFlagMetadata, + Endpoint: options.Endpoint, + HTTPClient: options.HTTPClient, + APIKey: options.APIKey, + ExporterMetadata: options.ExporterMetadata, }) dataCollectorManager := controller.NewDataCollectorManager( goffAPI, diff --git a/providers/go-feature-flag/pkg/provider_options.go b/providers/go-feature-flag/pkg/provider_options.go index 9366f8abc..e67380e76 100644 --- a/providers/go-feature-flag/pkg/provider_options.go +++ b/providers/go-feature-flag/pkg/provider_options.go @@ -63,9 +63,12 @@ type ProviderOptions struct { // default: 120000ms FlagChangePollingInterval time.Duration - // GOFeatureFlagMetadata (optional) is the metadata we send to the GO Feature Flag relay proxy when we report the + // ExporterMetadata (optional) is the metadata we send to the GO Feature Flag relay proxy when we report the // evaluation data usage. - GOFeatureFlagMetadata map[string]interface{} + // + // ‼️Important: If you are using a GO Feature Flag relay proxy before version v1.41.0, the information of this + // field will not be added to your feature events. + ExporterMetadata map[string]interface{} } func (o *ProviderOptions) Validation() error { diff --git a/providers/go-feature-flag/pkg/provider_test.go b/providers/go-feature-flag/pkg/provider_test.go index 1d633f738..9130527f7 100644 --- a/providers/go-feature-flag/pkg/provider_test.go +++ b/providers/go-feature-flag/pkg/provider_test.go @@ -982,12 +982,12 @@ func TestProvider_DataCollectorHook(t *testing.T) { t.Run("DataCollectorHook is called for success and call API", func(t *testing.T) { cli := mockClient{} options := gofeatureflag.ProviderOptions{ - Endpoint: "https://gofeatureflag.org/", - HTTPClient: NewMockClient(cli.roundTripFunc), - DisableCache: false, - DataFlushInterval: 100 * time.Millisecond, - DisableDataCollector: false, - GOFeatureFlagMetadata: map[string]interface{}{"toto": 123, "tata": "titi"}, + Endpoint: "https://gofeatureflag.org/", + HTTPClient: NewMockClient(cli.roundTripFunc), + DisableCache: false, + DataFlushInterval: 100 * time.Millisecond, + DisableDataCollector: false, + ExporterMetadata: map[string]interface{}{"toto": 123, "tata": "titi"}, } provider, err := gofeatureflag.NewProvider(options) defer provider.Shutdown()