LaunchDarkly

Learn how to use Sentry with LaunchDarkly in your Java app.

The LaunchDarkly integration tracks feature flag evaluations produced by the LaunchDarkly SDK. These evaluations are held in memory and are sent to Sentry on error and transaction events. At the moment, we only support boolean flag evaluations.

To install use:

Copied
implementation 'io.sentry:sentry-launchdarkly-server:8.27.0'

For other dependency managers, check out the central Maven repository.

Before using this integration, you need to install and instrument the LaunchDarkly Java SDK in your app.

Add SentryLaunchDarklyServerHook to your LaunchDarkly setup:

Copied
import com.launchdarkly.sdk.LDContext;
import com.launchdarkly.sdk.server.Components;
import com.launchdarkly.sdk.server.LDClient;
import com.launchdarkly.sdk.server.LDConfig;
import io.sentry.launchdarkly.server.SentryLaunchDarklyServerHook;
LDConfig config = new LDConfig.Builder() .hooks(Components.hooks()
.setHooks(Arrays.asList(new SentryLaunchDarklyServerHook())))
.build(); LDClient launchDarklyClient = new LDClient("sdk-key", config);

The integration is tested by evaluating a feature flag using your LaunchDarkly SDK before capturing an exception.

Copied
import io.sentry.Sentry;


boolean flagValue = launchDarklyClient.boolVariation("test-flag", context, false);

Sentry.captureException(new Exception("Something went wrong!"));

Visit the Sentry website and confirm that your error event has recorded the feature flag "test-flag" and its value "false".

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").