Skip to content

Commit

Permalink
rename field to ExporterMetadata
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Poignant <[email protected]>
  • Loading branch information
thomaspoignant committed Jan 14, 2025
1 parent 284c8db commit 05b9c11
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
6 changes: 3 additions & 3 deletions providers/go-feature-flag/pkg/controller/goff_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions providers/go-feature-flag/pkg/controller/goff_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
Expand Down Expand Up @@ -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{
{
Expand Down
16 changes: 8 additions & 8 deletions providers/go-feature-flag/pkg/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions providers/go-feature-flag/pkg/provider_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions providers/go-feature-flag/pkg/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 05b9c11

Please sign in to comment.