Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

niko/go-sdk-docs #553

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

niko/go-sdk-docs #553

wants to merge 4 commits into from

Conversation

nikomancy
Copy link
Contributor

What?

Moving the Go docs into the format similar to what we have for node.

Why?

  • The goal is to make the learning journey for engineers working with specific SDKs easier.
  • Content is easier to find in the TOC, improving navigability.
  • Code samples for typed examples have been added for ease of use.
  • Boilerplate prose docs have been added to allow engineers to learn about relevant conceptual information alongside the code without having to context switch to other parts of the docs.

Review instructions

  • Code samples were created through inference and need to be validated.

Todo before merge

  • Update redirects
  • Delete go.md

 On branch niko/go-to-new-template
 Changes to be committed:
	new file:   docs/sdks/server-sdks/go/_category_.json
	new file:   docs/sdks/server-sdks/go/assignments.mdx
	new file:   docs/sdks/server-sdks/go/bandits.mdx
	new file:   docs/sdks/server-sdks/go/initialization.mdx
	new file:   docs/sdks/server-sdks/go/intro.mdx
	new file:   docs/sdks/server-sdks/go/quickstart.mdx
Copy link

netlify bot commented Dec 16, 2024

Deploy Preview for eppo-data-docs ready!

Name Link
🔨 Latest commit 86c59ac
🔍 Latest deploy log https://app.netlify.com/sites/eppo-data-docs/deploys/6764202268480b0008b206ea
😎 Deploy Preview https://deploy-preview-553--eppo-data-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

docs/sdks/server-sdks/go/quickstart.mdx Outdated Show resolved Hide resolved
Comment on lines +31 to +39
import (
"github.com/eppo-exp/eppo-go-sdk/eppo"
)

config := eppo.NewConfig("<SDK-KEY>")
client, err := eppo.Init(config)
if err != nil {
log.Fatal("Failed to initialize Eppo client:", err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐛 This example is off. The one in initialization section is correct

Comment on lines +100 to +112
type MyLogger struct{}

func (l *MyLogger) LogAssignment(assignment *eppo.Assignment) error {
// Replace with your logging logic
log.Printf("Logging assignment: %+v", assignment)
return nil
}

config := eppo.NewConfig(
"<SDK-KEY>",
eppo.WithAssignmentLogger(&MyLogger{}),
)
client, err := eppo.Init(config)
Copy link
Collaborator

@rasendubi rasendubi Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐛 same here. Go SDK doesn't have NewConfig. See examples in initialization section

docs/sdks/server-sdks/go/quickstart.mdx Outdated Show resolved Hide resolved
docs/sdks/server-sdks/go/quickstart.mdx Outdated Show resolved Hide resolved

### Action Contexts

Next, supply a map with actions and their attributes: `actions: map[string]Attributes`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Next, supply a map with actions and their attributes: `actions: map[string]Attributes`.
Next, supply a map with actions and their attributes: `actions: map[string]ContextAttributes`.

All actions supplied are considered to be valid; if an action should not be shown to a user, do not include it in this map.

The action attributes are similar to the `subject_attributes` but hold action-specific information.
You can use `Attributes{}` to create an empty attribute context.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can use `Attributes{}` to create an empty attribute context.
You can use `ContextAttributes{}` to create an empty attribute context.


The `result` is an instance of `BanditResult`, which has two fields:
- `Variation` (string): The variation that was assigned to the subject
- `Action` (string): The action that was assigned to the subject (empty string if no action was assigned)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `Action` (string): The action that was assigned to the subject (empty string if no action was assigned)
- `Action` (`*string`): The action that was assigned to the subject (`nil` if no action was assigned)


The variation returns the feature flag variation, this can be the bandit itself, or the "status quo" variation if the user is not assigned to the bandit.
If we are unable to generate a variation, for example when the flag is turned off, then the `default` variation is returned.
In both of those cases, the `Action` is an empty string, and you should use the status-quo algorithm to select an action.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In both of those cases, the `Action` is an empty string, and you should use the status-quo algorithm to select an action.
In both of those cases, the `Action` is nil, and you should use the status-quo algorithm to select an action.

Comment on lines +237 to +259
## Debugging

You may encounter a situation where a bandit assignment produces a value that you did not expect. The SDK provides detailed evaluation information through the `GetBanditActionDetails` method:

```go
evaluation, err := client.GetBanditActionDetails(
"shoe-bandit",
"test-subject",
attributes,
actions,
"control",
)
if err != nil {
log.Printf("Error getting bandit details: %v", err)
return
}

log.Printf("Assignment: %s", evaluation.Variation)
log.Printf("Action: %s", evaluation.Action)
log.Printf("Details: %+v", evaluation.EvaluationDetails)
```

For more information on debugging assignments, see [Debugging Flag Assignment](/sdks/sdk-features/debugging-flag-assignment/).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not supported

Suggested change
## Debugging
You may encounter a situation where a bandit assignment produces a value that you did not expect. The SDK provides detailed evaluation information through the `GetBanditActionDetails` method:
```go
evaluation, err := client.GetBanditActionDetails(
"shoe-bandit",
"test-subject",
attributes,
actions,
"control",
)
if err != nil {
log.Printf("Error getting bandit details: %v", err)
return
}
log.Printf("Assignment: %s", evaluation.Variation)
log.Printf("Action: %s", evaluation.Action)
log.Printf("Details: %+v", evaluation.EvaluationDetails)
```
For more information on debugging assignments, see [Debugging Flag Assignment](/sdks/sdk-features/debugging-flag-assignment/).

nikomancy and others added 3 commits December 19, 2024 08:28
Updating to most recent version for the install instructions.

Co-authored-by: Oleksii Shmalko <[email protected]>
Updating typed assignment list to correct names.

Co-authored-by: Oleksii Shmalko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants