LaunchDarkly

了解如何在 LaunchDarkly 中使用 Sentry。

LaunchDarkly 集成会跟踪由 LaunchDarkly SDK 生成的功能标志评估。这些评估信息保存在内存中,并在发生错误时发送到 Sentry 进行审查和分析。目前,我们仅支持布尔标志评估。

从 PyPI 安装带有 launchdarkly 额外依赖的 sentry-sdk

Copied
pip install --upgrade 'sentry-sdk[launchdarkly]'

LaunchDarklyIntegration() 添加到您的 integrations 列表中:

Copied
import sentry_sdk
from sentry_sdk.integrations.launchdarkly import LaunchDarklyIntegration

sentry_sdk.init(
    dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
    integrations=[
        LaunchDarklyIntegration(),
    ],
)

通过在捕获异常之前使用您的 LaunchDarkly SDK 评估一个功能标志来测试集成。

Copied
import ldclient
import sentry_sdk

client = ldclient.get()
client.variation("hello", Context.create("test-context"), False)

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

访问 Sentry 网站并确认您的错误事件已记录功能标志 "hello" 及其值 "false"。

  • launchdarkly-server-sdk >= 9.8.0
  • sentry-sdk >= 2.19.2
  • python >= 3.8