Skip to content

Commit 56c6775

Browse files
Merge branch 'main' into exporter-metadata-context
2 parents 5e4e7f6 + 6aca2c0 commit 56c6775

File tree

8 files changed

+128
-17
lines changed

8 files changed

+128
-17
lines changed

.goreleaser.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ archives:
205205

206206
- id: goff-lambda
207207
name_template: "go-feature-flag-aws-lambda_{{ .Version }}"
208-
format: zip
208+
formats: zip
209209
builds:
210210
- go-feature-flag-lambda
211211

openfeature/provider_tests/dotnet-integration-tests/ProviderTests/ProviderTests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="FluentAssertions" Version="8.0.0" />
13+
<PackageReference Include="FluentAssertions" Version="8.0.1" />
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
1515
<PackageReference Include="NUnit" Version="4.3.2" />
1616
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />

openfeature/provider_tests/go-integration-tests/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/thomaspoignant/go-feature-flag/openfeature/provider_tests/go-i
33
go 1.22.5
44

55
require (
6-
github.com/open-feature/go-sdk v1.14.0
7-
github.com/open-feature/go-sdk-contrib/providers/go-feature-flag v0.2.1
6+
github.com/open-feature/go-sdk v1.14.1
7+
github.com/open-feature/go-sdk-contrib/providers/go-feature-flag v0.2.2
88
github.com/stretchr/testify v1.10.0
99
)
1010

openfeature/provider_tests/go-integration-tests/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
1111
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
1212
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
1313
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
14-
github.com/open-feature/go-sdk v1.14.0 h1:+B+Z94QS4HXPAn6OnaWWjMNAJkHlh6pIqW2Y1194yF8=
15-
github.com/open-feature/go-sdk v1.14.0/go.mod h1:t337k0VB/t/YxJ9S0prT30ISUHwYmUd/jhUZgFcOvGg=
16-
github.com/open-feature/go-sdk-contrib/providers/go-feature-flag v0.2.1 h1:gSOuM77DaqDRmXRxxYpefHqquafnU+1OoIT7umew6iU=
17-
github.com/open-feature/go-sdk-contrib/providers/go-feature-flag v0.2.1/go.mod h1:q2VhNjhNzet8gPQQ3kH9Bwj1v71YaHL3ge7503ll4rE=
14+
github.com/open-feature/go-sdk v1.14.1 h1:jcxjCIG5Up3XkgYwWN5Y/WWfc6XobOhqrIwjyDBsoQo=
15+
github.com/open-feature/go-sdk v1.14.1/go.mod h1:t337k0VB/t/YxJ9S0prT30ISUHwYmUd/jhUZgFcOvGg=
16+
github.com/open-feature/go-sdk-contrib/providers/go-feature-flag v0.2.2 h1:shnvK5jfVX84L8g5ISbgbdMjIHjMBlqwiB94J5T8Qso=
17+
github.com/open-feature/go-sdk-contrib/providers/go-feature-flag v0.2.2/go.mod h1:q2VhNjhNzet8gPQQ3kH9Bwj1v71YaHL3ge7503ll4rE=
1818
github.com/open-feature/go-sdk-contrib/providers/ofrep v0.1.4 h1:BElq1EOES8DfLjW6UIFMNVG7w9MzoeC7JpD/1rXouhk=
1919
github.com/open-feature/go-sdk-contrib/providers/ofrep v0.1.4/go.mod h1:jrD4UG3ZCzuwImKHlyuIN2iWeYjlOX5+zJ/sX45efuE=
2020
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

website/.ci/sdkVersions.go

+42-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type Versions struct {
1717
Pypi Pypi `json:"pypi,omitempty"`
1818
Nuget Nuget `json:"nuget,omitempty"`
1919
GO GO `json:"go,omitempty"`
20+
Swift Swift `json:"swift,omitempty"`
2021
}
2122
type Maven struct {
2223
Sdk string `json:"sdk,omitempty"`
@@ -43,6 +44,10 @@ type Nuget struct {
4344
Provider string `json:"provider,omitempty"`
4445
}
4546

47+
type Swift struct {
48+
Provider string `json:"provider,omitempty"`
49+
}
50+
4651
type GO struct {
4752
Provider string `json:"provider,omitempty"`
4853
SDK string `json:"sdk,omitempty"`
@@ -51,7 +56,11 @@ type GO struct {
5156
func main() {
5257
var wg sync.WaitGroup
5358
versions := Versions{}
54-
wg.Add(14)
59+
wg.Add(15)
60+
go func() {
61+
defer wg.Done()
62+
versions.Swift.Provider = getSwiftVersion("go-feature-flag/openfeature-swift-provider")
63+
}()
5564
go func() {
5665
defer wg.Done()
5766
versions.Maven.Android = getMavenVersion("dev.openfeature", "android-sdk")
@@ -296,3 +305,35 @@ func getGOVersion(packageName string) string {
296305
}
297306
return res.Version
298307
}
308+
309+
func getSwiftVersion(repoSlug string) string {
310+
//
311+
u := url.URL{
312+
Scheme: "https",
313+
Host: "api.github.com",
314+
Path: fmt.Sprintf("repos/%s/releases/latest", repoSlug),
315+
}
316+
317+
resp, err := http.Get(u.String())
318+
if err != nil {
319+
log.Fatal(err)
320+
}
321+
defer resp.Body.Close()
322+
323+
body, err := io.ReadAll(resp.Body)
324+
if err != nil {
325+
log.Fatal(err)
326+
}
327+
328+
type githubRes struct {
329+
TagName string `json:"tag_name,omitempty"`
330+
}
331+
332+
var res githubRes
333+
err = json.Unmarshal(body, &res)
334+
if err != nil {
335+
log.Fatal(err)
336+
}
337+
338+
return res.TagName
339+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: Introducing Exporter Metadata in the GO Feature Flag Provider for OpenFeature.
3+
description: Exporter metadata in the GO Feature Flag provider for OpenFeature allows enriching evaluation events with static context data like environment or app version for improved observability and analysis.
4+
authors: [thomaspoignant]
5+
tags: [openfeature,exporter]
6+
---
7+
8+
# Introducing Exporter Metadata in the GO Feature Flag Provider for OpenFeature
9+
10+
This blog post dives into a new functionality introduced in the GO Feature Flag provider for OpenFeature: exporter metadata. We'll explore how it works and how you can leverage it to enrich your evaluation events with valuable static information.
11+
12+
## What is Exporter Metadata?
13+
Exporter metadata is an object you can configure when initializing your GO Feature Flag provider for OpenFeature.
14+
15+
It allows you to specify a set of static information that you want to consistently include with all your evaluation events.
16+
A good example of information you might include in exporter metadata is the environment in which your application is running,
17+
the version of the application or anything that helps you when you analyze your evaluation data.
18+
19+
This data is then forwarded to the exporter and incorporated into your feature events as a new field called `metadata`.
20+
<!--truncate-->
21+
## Why Use Exporter Metadata?
22+
23+
Including exporter metadata in your evaluation events offers several advantages:
24+
- **Enhanced Context**: By adding static information to your events, you can provide richer context for analysis. This can include details about the environment (e.g., development, staging, production), the application version, or any other relevant data that sheds light on feature usage patterns.
25+
- **Improved Observability**: With exporter metadata, you gain a more comprehensive view of feature evaluation across different contexts. This can be particularly useful for debugging purposes or identifying trends in feature adoption for specific environments or application versions.
26+
- **Simplified Data Enrichment**: Exporter metadata eliminates the need to manually inject context information into every evaluation event. This streamlines your code and ensures consistency in the data you collect.
27+
28+
## How to Use Exporter Metadata
29+
30+
In all providers that support exporter metadata, you can pass a map of key-value pairs to the `ExporterMetadata` field in the provider's configuration.
31+
Value can be a `string`, a `bool`, an `int` or a `float64`.
32+
33+
This map will be included in all evaluation events sent to the exporter and added to the `metadata` field by the exporter.
34+
35+
Here's an example of how you can configure exporter metadata in the Kotlin provider:
36+
```kotlin
37+
val options =
38+
GoFeatureFlagOptions(
39+
endpoint = "https://mygoffserver.com/",
40+
exporterMetadata = mapOf("device" to "Pixel 4", "appVersion" to "1.0.0")
41+
)
42+
43+
val provider = GoFeatureFlagProvider(options)
44+
```
45+
In this example, we're passing some information that can help to understand the context of the evaluation events such as the device type and the appVersion.
46+
47+
With this configuration, all evaluation events sent to the exporter will include the `metadata` field with the specified key-value pairs.
48+
And it will look like this:
49+
50+
```json
51+
{"kind":"feature","contextKind":"user","userKey":"4f433951-4c8c-42b3-9f18-8c9a5ed8e9eb","creationDate":1737465936,"key":"REDIRECTION","variation":"on","value":true,"default":false,"version":"","source":"PROVIDER_CACHE", "metadata": {"device": "Pixel 4", "appVersion":"1.0.0", "openfeature": true, "provider": "android"}}
52+
```
53+
54+
## Which Providers Support Exporter Metadata?
55+
To be able to use exporter metadata, you need to use the relay-proxy in version `v1.41.0` or above and as minimum the following version of the providers:
56+
- **GO**: `v0.2.2`
57+
- **Kotlin**: `v0.3.0`
58+
- **Java**: `v0.4.1`
59+
- **NodeJS**: `v0.7.4`
60+
- **Web**: `v0.2.4`
61+
- **Python**: `v0.4.0`
62+
- **Swift**: `v0.3.0`
63+
64+
## Conclusion
65+
Exporter metadata provides a powerful mechanism to enrich your evaluation events with static information in the GO Feature Flag provider for OpenFeature.
66+
By incorporating this functionality, you can gain deeper insights into feature usage patterns and streamline your data collection process.
67+
68+
This blog post has provided a brief introduction to exporter metadata.
69+
We encourage you to experiment with this feature and explore its potential to enhance your feature flag evaluation practices.

website/docs/sdk/client_providers/openfeature_swift.mdx

+8-7
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ sidebar_position: 20
33
title: Swift
44
description: How to use the OpenFeature Swift SDK for your iOS/tvOS/macOS application
55
---
6-
import Tabs from '@theme/Tabs';
7-
import TabItem from '@theme/TabItem';
6+
import versions from '@site/static/sdk-versions.json';
7+
import CodeBlock from '@theme/CodeBlock';
88

99
# Swift SDK
1010
[![version](https://img.shields.io/github/v/release/go-feature-flag/openfeature-swift-provider?label=Swift&amp;display_name=tag&style=flat-square&logo=Swift)](https://github.com/go-feature-flag/openfeature-swift-provider)
1111

1212
In conjuction with the [OpenFeature SDK](https://openfeature.dev/docs/reference/concepts/provider) you will be able to evaluate your feature flags in your **iOS**/**tvOS**/**macOS** applications.
1313

14-
For documentation related to flags management in GO Feasture Flag, refer to the [GO Feature Flag documentation website](https://gofeatureflag.org/docs).
14+
For documentation related to flags management in GO Feature Flag, refer to the [GO Feature Flag documentation website](https://gofeatureflag.org/docs).
1515

1616
### Functionalities:
1717
- Managed the integration of the OpenFeature Swift SDK and GO Feature Flag relay-proxy.
@@ -23,9 +23,11 @@ For documentation related to flags management in GO Feasture Flag, refer to the
2323
### Swift Package Manager
2424

2525
In the dependencies section of Package.swift add:
26-
```swift
27-
.package(url: "https://github.com/go-feature-flag/openfeature-swift-provider.git", from: "0.1.0")
28-
```
26+
<CodeBlock
27+
language="swift">
28+
.package(url: "https://github.com/go-feature-flag/openfeature-swift-provider.git", from: "{versions.swift.provider.substr(1, versions.swift.provider.length)}")
29+
</CodeBlock>
30+
2931

3032
and in the target dependencies section add:
3133
```swift
@@ -58,7 +60,6 @@ The only required option to create a `GoFeatureFlagProvider` is the URL to your
5860
import GOFeatureFlag
5961
import OpenFeature
6062

61-
6263
let options = GoFeatureFlagProviderOptions(endpoint: "https://your_domain.io")
6364
let provider = GoFeatureFlagProvider(options: options)
6465

website/static/sdk-versions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"maven":{"sdk":"1.13.0","providerKt":"0.2.0","providerJava":"0.4.0","android":"0.3.2"},"npm":{"core":"1.6.0","webSDK":"1.4.0","providerServer":"0.7.3","providerWeb":"0.2.3"},"pypi":{"sdk":"0.7.4","provider":"0.3.0"},"nuget":{"sdk":"2.2.0","provider":"0.2.0"},"go":{"provider":"v0.2.1","sdk":"v1.14.0"}}
1+
{"maven":{"sdk":"1.14.0","providerKt":"0.3.0","providerJava":"0.4.1","android":"0.3.3"},"npm":{"core":"1.6.0","serverSDK":"1.17.0","webSDK":"1.4.0","providerWeb":"0.2.5"},"pypi":{"sdk":"0.7.4","provider":"0.4.0"},"nuget":{"sdk":"2.2.0","provider":"0.2.0"},"go":{"provider":"v0.2.2","sdk":"v1.14.1"},"swift":{"provider":"v0.3.0"}}

0 commit comments

Comments
 (0)