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

feat(flags): Document self-serve feature flags integrations #12203

Merged
merged 22 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/organization/integrations/feature-flag/index.mdx
cmanallen marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ sidebar_order: 90
description: "Learn more about Sentry's feature flag integrations."
---

- [Split](/organization/integrations/feature-flag/split/)
- [LaunchDarkly](/organization/integrations/feature-flag/launchdarkly/)
- [Self-Serve](/organization/integrations/feature-flag/self-serve/)
- [Split](/organization/integrations/feature-flag/split/)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Sentry can track flag evaluations as they happen within your application. Flag

To set up evaluation tracking visit one of our supported languages pages:
* [JavaScript](/platforms/javascript/configuration/integrations/launchdarkly/)
* [Python](/platforms/python/integrations/launchdarkly/)
* [Python](/platforms/python/integrations/feature-flags/launchdarkly/)

## Change Tracking

Expand Down
57 changes: 57 additions & 0 deletions docs/organization/integrations/feature-flag/self-serve/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: Self-Serve
sidebar_order: 1
description: Learn about Sentry's self-serve feature-flag integrations.
---

## Evaluation Tracking

Sentry can track flag evaluations as they happen within your application. Flag evaluations will appear in the "Feature Flag" section of the Issue Details page as a table, with "suspect" flag predictions highlighted in yellow. Learn more about how to interact with feature flag insights within the Sentry UI by reading the [Issue Details page documentation](/product/issues/issue-details/#feature-flags).

### Set Up Evaluation Tracking

To set up evaluation tracking visit the [explore page](/product/explore/feature-flags/) and select the language and SDK of your choice. Not using a supported SDK? That's okay. We support self-serve integrations with your existing system.

To set up self-serve evaluation tracking visit one of our supported languages pages:
* [JavaScript](/platforms/javascript/configuration/integrations/self-serve/)
aliu39 marked this conversation as resolved.
Show resolved Hide resolved
* [Python](/platforms/python/integrations/feature-flags/self-serve/)

## Change Tracking

Sentry can track changes to feature flag definitions and report suspicious feature flag edits.

Sentry offers a change tracking feature which functions as an audit-log of feature flag changes. When a feature flag definition changes in your back-end you can emit a web hook to Sentry.

### API Documentation

If you're using a self-serve integration it means you will likely need to write code to support this endpoint. This section documents our authentication procedures as well as the resource's fields and structure.

#### Authentication

Authentication is performed using a "signing secret". The "signing secret" must be used to sign the web hook payload in your feature flagging system. Signing the payload with your secret produces a "signature". Sentry needs this signature so it can compare the results of our signing function to yours. Both sides must use the same signing function. Sentry uses a HMAC SHA256 hex-digest of the web hook payload. In Python this function looks like:

```python
def hmac_sha256_hex_digest(secret: str, message: bytes):
return hmac.new(secret.encode(), message, hashlib.sha256).hexdigest()
```

The result of this function must be sent as a header to Sentry: `X-Sentry-Signature signature_result`.

#### API Blueprint

[An API blueprint is available at this permalink](https://github.com/getsentry/sentry/blob/ed324708947ca26392d6579ed76b93fc94a61ab6/src/sentry/flags/docs/api.md#create-generic-flag-log-post). We strive to keep this page updated. Be sure to check the latest master branch for new protocol versions. We will always maintain backwards compatibility so there is no harm in implementing an old version. However, new versions might introduce new features.

### Set Up Change Tracking

Enabling Change Tracking is a three step process. To get started visit the [feature-flags settings page](https://sentry.io/orgredirect/organizations/:orgslug/settings/feature-flags) in a new tab. Then follow the steps listed below.

1. **Click the "Add New Provider" button.**
- One webhook secret can be registered per provider type.
2. **Register the webhook URL**.
- Copy the provided Sentry webhook URL and configure your feature flagging system to emit web hooks to this URL.
3. **Set the Signing Secret**.
- In your feature flagging system's UI find the "Signing Secret".
- Copy the signing secret and paste it into the input box labeled "Secret" in Sentry.
- In Sentry, save the secret by clicking "Save Secret".

Once saved Sentry will now accept and authenticate all inbound hooks to your organization's feature flag webhook endpoint.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: FeatureFlags
title: Self-Serve Feature Flags Integration
description: "Learn how to attach custom feature flag data to Sentry error events."
notSupported:
- javascript.aws-lambda
Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/javascript/common/feature-flags/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ description: With Feature Flags, Sentry tracks feature flag evaluations in your
Evaluation tracking requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below.
- [OpenFeature](/platforms/javascript/configuration/integrations/openfeature/)
- [LaunchDarkly](/platforms/javascript/configuration/integrations/launchdarkly/)
- [Manual Tracking](/platforms/javascript/configuration/integrations/featureflags/) - if you use an unsupported or in-house provider, you may track evaluations through an API.
- [Self-Serve](/platforms/javascript/configuration/integrations/self-serve/)

<PlatformContent includePath="feature-flags/enable-change-tracking" />
5 changes: 3 additions & 2 deletions docs/platforms/python/feature-flags/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ description: With Feature Flags, Sentry tracks feature flag evaluations in your

Evaluation tracking requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below.

- [OpenFeature](/platforms/python/integrations/openfeature/)
- [LaunchDarkly](/platforms/python/integrations/launchdarkly/)
- [OpenFeature](/platforms/python/integrations/feature-flags/openfeature/)
- [LaunchDarkly](/platforms/python/integrations/feature-flags/launchdarkly/)
- [Self-Serve](/platforms/python/integrations/feature-flags/generic/)
cmanallen marked this conversation as resolved.
Show resolved Hide resolved

<PlatformContent includePath="feature-flags/enable-change-tracking" />
6 changes: 6 additions & 0 deletions docs/platforms/python/integrations/feature-flags/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Test nested
description: "Learn about using Feature Flags with Sentry."
---

Sentry offers a variety of SDK implementations. See the sidebar for more options.
cmanallen marked this conversation as resolved.
Show resolved Hide resolved
50 changes: 50 additions & 0 deletions docs/platforms/python/integrations/feature-flags/self-serve.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: Self-Serve Feature Flags
description: "Learn how to attach custom feature flag data to Sentry error events."
---

<PlatformContent includePath="feature-flags/prerelease-alert" />

The Feature Flags integration allows you to manually track feature flag evaluations through an API. These evaluations are held in memory, and in the event an error occurs, sent to Sentry for review and analysis.
**At the moment, we only support boolean flag evaluations.**

## Install

Install `sentry-sdk` from PyPI.

```bash
pip install --upgrade 'sentry-sdk'
```

## Configure

Add `FeatureFlagsIntegration()` to your `integrations` list:

```python
import sentry_sdk
from sentry_sdk.integrations.feature_flags import FeatureFlagsIntegration

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[
FeatureFlagsIntegration(),
],
)
```

## Verify

The integration is tested by calling the `add_feature_flag` API before capturing an exception.

```python
import sentry_sdk
from sentry_sdk.integrations.feature_flags import add_feature_flag

add_feature_flag('test-flag', False)

sentry_sdk.capture_exception(Exception("Something went wrong!"))
```

Go to your Sentry project and confirm that your error event has recorded the feature flag "test-flag" and its value "false".

<PlatformContent includePath="feature-flags/next-steps" />
4 changes: 2 additions & 2 deletions docs/platforms/python/integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra

| | **Auto-enabled** |
| ----------------------------------------------------------------------------------------------------------------------- | :--------------: |
| <LinkWithPlatformIcon platform="python" label="LaunchDarkly" url="/platforms/python/integrations/launchdarkly" /> | |
| <LinkWithPlatformIcon platform="python" label="OpenFeature" url="/platforms/python/integrations/openfeature" /> | |
| <LinkWithPlatformIcon platform="python" label="LaunchDarkly" url="/platforms/python/integrations/feature-flags/launchdarkly" /> | |
| <LinkWithPlatformIcon platform="python" label="OpenFeature" url="/platforms/python/integrations/feature-flags/openfeature" /> | |

### Cloud Computing

Expand Down
1 change: 1 addition & 0 deletions docs/product/explore/feature-flags/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ Change tracking enables Sentry to listen for additions, removals, and modificati

To set up change tracking, visit the webhook integration documentation for your provider:
* [LaunchDarkly](/organization/integrations/feature-flag/launchdarkly/#change-tracking)
* [Self-Serve](/organization/integrations/feature-flag/self-serve/#change-tracking)
Loading