Skip to content

Commit

Permalink
doc: Add Experimentation section
Browse files Browse the repository at this point in the history
  • Loading branch information
laynax committed Jul 26, 2024
1 parent b7c05df commit bff7874
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ SDK, the Go version.
- [Redis](#redis)
- [Profiling](#profiling)
- [Custom Metrics](#custom-metrics)
- [Experimentation](#experimentation)
- [Usage of StatSig](#usage-of-statsig)
- [Using the `go-sdk` in isolation](#using-the--go-sdk--in-isolation)
- [Developing the SDK](#developing-the-sdk)
- [Building the docker environment](#building-the-docker-environment)
Expand Down Expand Up @@ -1542,6 +1544,48 @@ func main() {
[rate]: <https://docs.datadoghq.com/developers/metrics/dogstatsd_metrics_submission/?tab=go#metric-submission-options>
[submit-metric]: <https://docs.datadoghq.com/developers/metrics/dogstatsd_metrics_submission/?tab=go>

## Experimentation

`go-sdk` comes with an integration with [StatSig](https://statsig.com) to leverage its experimentation and feature flag functionality.
Using the configuration details, namely the [data source
name](https://en.wikipedia.org/wiki/Data_source_name) (DSN) as their product,
statsig is able to open a connection and give the `go-sdk` users a preconfigured
ready-to-use database connection with an ORM attached. This can be done as
follows:

```go
package main
import (
sdkstatsig "github.com/scribd/go-sdk/pkg/statsig"
)
func main() {
// Loads the statsig configuration.
statsigConfig, err := sdkstatsig.NewConfig()
// Initialize statsig connection using the configuration.
sdkstatsig.Initialize(statsigConfig)
}
```

#### Usage of StatSig

After initializing the statsig client, one can start using experimentation or feature flag using the following
code:

```go
import (
sdkstatsig "github.com/scribd/go-sdk/pkg/statsig"
statsig "github.com/statsig-io/go-sdk"
)
func main() {
u := statsig.User{}
exampleExperiment := sdkstatsig.GetExperiment(u, "{experiment}")
examplefeatureFlag := sdkstatsig.GetFeatureFlag(u, "{feature_flag}")
}
```

## Using the `go-sdk` in isolation

The `go-sdk` is a standalone Go module. This means that it can be imported and
Expand Down

0 comments on commit bff7874

Please sign in to comment.