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
Copy file name to clipboardExpand all lines: content/en/feature_flags/server/go.md
+58-6Lines changed: 58 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,11 +24,10 @@ This guide explains how to install and enable the SDK, create an OpenFeature cli
24
24
25
25
Before setting up the Go Feature Flags SDK, ensure you have:
26
26
27
-
-**Go 1.23 or later**
28
27
-**Datadog Agent 7.55 or later** with [Remote Configuration][2] enabled
29
-
-**Datadog Go tracer**(`dd-trace-go/v2`) installed and configured
28
+
-**Datadog Go tracer**`dd-trace-go` version 2.4.0 or later
30
29
31
-
Set the following environment variables to enable feature flags:
30
+
Set the following environment variables:
32
31
33
32
{{< code-block lang="bash" >}}
34
33
# Required: Enable the feature flags provider
@@ -57,11 +56,14 @@ go get github.com/open-feature/go-sdk/openfeature
57
56
58
57
Start the Datadog tracer and register the Datadog OpenFeature provider. The tracer must be started first because it enables Remote Configuration, which delivers flag configurations to your application.
59
58
59
+
### Blocking initialization
60
+
61
+
Use `SetProviderAndWait` to block until the initial flag configuration is received. This ensures flags are ready before your application starts handling requests.
// Register the provider with OpenFeature and wait for initialization
86
+
// Register the provider and wait for initialization (default 30s timeout)
85
87
if err := openfeature.SetProviderAndWait(provider); err != nil {
86
88
log.Fatalf("Failed to set provider: %v", err)
87
89
}
88
90
91
+
// Create the OpenFeature client
92
+
client := openfeature.NewClient("my-service")
93
+
89
94
// Your application code here
90
95
}
91
96
{{< /code-block >}}
92
97
93
-
<divclass="alert alert-info"><code>SetProviderAndWait</code> blocks until the initial flag configuration is received from Remote Config. This can take a few seconds on first startup.</div>
98
+
To specify a custom timeout, use `SetProviderAndWaitWithContext`:
0 commit comments