You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repo contains the [Confidence](https://confidence.spotify.com/) Go SDK.
3
+
This repo contains the [Confidence](https://confidence.spotify.com/) Go SDK and the Confidence OpenFeature provider. We recommend using the [OpenFeature Go SDK](https://github.com/open-feature/go-sdk) to access Confidence feature flags.
4
4
5
-
## Adding the dependency
5
+
6
+
## Confidence OpenFeature Go Provider
7
+
8
+
Before starting to use the provider, it can be helpful to read through the general [OpenFeature docs](https://docs.openfeature.dev/) and get familiar with the concepts.
9
+
10
+
Get started by adding the dependencies:
6
11
<!---x-release-please-start-version-->
7
12
```
13
+
require (
14
+
github.com/open-feature/go-sdk v1.7.0
15
+
)
8
16
require (
9
17
github.com/spotify/confidence-sdk-go v0.4.5
10
18
)
11
19
```
12
20
<!---x-release-please-end-->
13
21
14
-
## Creating and using the SDK
15
-
16
-
Below is an example for how to create an instance of the Confidence SDK, and then resolve a flag with a boolean attribute.
22
+
### Creating and using the flag provider
17
23
18
-
The SDK is configured via `SetAPIConfig(...)` and `*c.NewAPIConfig(...)`, with which you can set the api key for authentication.
19
-
Optionally, a custom resolve API url can be configured if, for example, the resolver service is running on a locally deployed side-car (`NewAPIConfigWithUrl(...)`).
24
+
Below is an example for how to obtain an OpenFeature _client_ using the Confidence flag provider, and then resolve
25
+
a flag with a boolean attribute.
20
26
27
+
The Provider constructor accepts a confidence instance: `NewFlagProvider(confidenceSdk)`, please refer to [this section](#creating-and-using-the-sdk)
28
+
for more detailed information on how to set that up.
21
29
22
-
You can retrieve properties on the flag variant using property dot notation, meaning `test-flag.boolean-key` will retrieve the attribute `boolean-key` on the flag `test-flag`.
30
+
You can retrieve attributes on the flag variant using property dot notation, meaning `test-flag.boolean-key` will retrieve
31
+
the attribute `boolean-key` on the flag `test-flag`.
23
32
24
-
You can also use only the flag name `test-flag` and retrieve all values as a map with `GetObjectFlag()`.
33
+
You can also use only the flag name `test-flag` and retrieve all values as a map with `client.ObjectValue()`.
25
34
26
35
The flag's schema is validated against the requested data type, and if it doesn't match it will fall back to the default value.
27
36
28
37
```go
29
38
import (
39
+
o "github.com/open-feature/go-sdk/openfeature"
30
40
c "github.com/spotify/confidence-sdk-go/pkg/confidence"
41
+
p "github.com/spotify/confidence-sdk-go/pkg/provider"
The flag will be applied immediately, meaning that Confidence will count the targeted user as having received the treatment once they have have been evaluated.
44
-
45
-
### Tracking
46
-
47
-
Confidence support event tracking through the SDK. The `Track()` function accepts an en event name and a map of arbitrary data connected to the event.
48
-
The current context will also be appended to the event data.
The SDK includes telemetry functionality that helps monitor SDK performance and usage. By default, telemetry is enabled and collects metrics (anonymously) such as resolve latency and request status. This data is used by the Confidence team, and in certain cases it is also exposed to the SDK adopters. You can disable telemetry by setting `DisableTelemetry: true` in the `APIConfig`:
Unless specifically configured using the `ConfidenceBuilder``setLogger()` function; Confidence uses the default instance of [slog](https://pkg.go.dev/log/slog) for logging valuable information during runtime.
72
63
When getting started with Confidence, we suggest you configure [slog](https://pkg.go.dev/log/slog) to emit debug level information:
@@ -78,58 +69,71 @@ h := slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: programLevel})
78
69
slog.SetDefault(slog.New(h))
79
70
```
80
71
81
-
##Demo app
72
+
### Telemetry
82
73
83
-
To run the demo app, replace the `CLIENT_SECRET` with client secret setup in the
84
-
[Confidence](https://confidence.spotify.com/) console, the flags with existing flags and execute
85
-
the app with `cd demo && go run GoDemoApp.go`.
74
+
The SDK includes telemetry functionality that helps monitor SDK performance and usage. By default, telemetry is enabled and collects metrics (anonymously) such as resolve latency and request status. This data is used by the Confidence team, and in certain cases it is also exposed to the SDK adopters. You can disable telemetry by setting `DisableTelemetry: true` in the `APIConfig`:
The SDK can be combined with the [OpenFeature Go SDK](https://github.com/open-feature/go-sdk), the repo also contains an OpenFeature Provider. Before starting to use the provider, it can be helpful to read through the general [OpenFeature docs](https://docs.openfeature.dev/)
90
-
and get familiar with the concepts.
91
-
It's also important to add the underlying OpenFeature SDK dependency:
84
+
### Adding the dependency
85
+
<!---x-release-please-start-version-->
92
86
```
93
87
require (
94
-
github.com/open-feature/go-sdk v1.7.0
88
+
github.com/spotify/confidence-sdk-go v0.4.5
95
89
)
96
90
```
91
+
<!---x-release-please-end-->
97
92
98
-
### Creating and using the flag provider
93
+
### Creating and using the SDK
99
94
100
-
Below is an example for how to create a OpenFeature client using the Confidence flag provider, and then resolve
101
-
a flag with a boolean attribute.
95
+
Below is an example for how to create an instance of the Confidence SDK, and then resolve a flag with a boolean attribute.
102
96
103
-
The Provider constructor accepts a confidence instance: `NewFlagProvider(confidenceSdk)`, please refer to the previous sections
104
-
of this readme for more detailed information on how to set that up.
97
+
The SDK is configured via `SetAPIConfig(...)` and `*c.NewAPIConfig(...)`, with which you can set the api key for authentication.
98
+
Optionally, a custom resolve API url can be configured if, for example, the resolver service is running on a locally deployed side-car (`NewAPIConfigWithUrl(...)`).
105
99
106
-
You can retrieve attributes on the flag variant using property dot notation, meaning `test-flag.boolean-key` will retrieve
107
-
the attribute `boolean-key` on the flag `test-flag`.
108
100
109
-
You can also use only the flag name `test-flag` and retrieve all values as a map with `client.ObjectValue()`.
101
+
You can retrieve properties on the flag variant using property dot notation, meaning `test-flag.boolean-key` will retrieve the attribute `boolean-key` on the flag `test-flag`.
102
+
103
+
You can also use only the flag name `test-flag` and retrieve all values as a map with `GetObjectFlag()`.
110
104
111
105
The flag's schema is validated against the requested data type, and if it doesn't match it will fall back to the default value.
112
106
113
107
```go
114
108
import (
115
-
o "github.com/open-feature/go-sdk/openfeature"
116
109
c "github.com/spotify/confidence-sdk-go/pkg/confidence"
117
-
p "github.com/spotify/confidence-sdk-go/pkg/provider"
The flag will be applied immediately, meaning that Confidence will count the targeted user as having received the treatment once they have have been evaluated.
0 commit comments