Installing the Failure Flags SDK
This document will walk you through adding the Failure Flags SDK to your application. Failure Flags is currently available for Node.js, Python, Java, and Go.
Node.js
Find the SDK on NPM. You can find the source on GitHub.
You'll need to enable the SDK by setting the <span class="code-class-custom">FAILURE_FLAGS_ENABLED</span> environment variable when you run the application where you add the SDK.
For Node.js applications, start by adding <span class="code-class-custom">@gremlin/failure-flags</span> to your dependencies:
Next, instrument the part of your application where you want to perform experiments by adding <span class="code-class-custom">invokeFailureFlag()</span>. Give the flag a name using the <span class="code-class-custom">name: 'myfailureflag' </span>property. This method checks to see if there's an active experiment running that matches the name of the failure flag (and any additional labels you provide), and if so, runs the experiment. Otherwise, it remains inactive and your application code executes normally. We recommend adding a failure flag immediately before or after a call to one of your network dependencies, such as a database.
You can provide additional tags for matching a Failure Flag using the <span class="code-class-custom">labels</span> property. For example, this flag has the name <span class="code-class-custom">http-ingress</span>. It also includes the current HTTP request method and URL path in the <span class="code-class-custom">labels</span> property.
Python
Find the SDK on PyPI. You can find the source on GitHub.
You'll need to enable the SDK by setting the <span class="code-class-custom">FAILURE_FLAGS_ENABLED</span> environent variable when you run the application where you add the SDK.
You can get started by adding failureflags to your package dependencies:
Then instrument the part of your application where you want to inject faults.
Java
Find the Java Failure Flags SDK artifacts (jars, sources, and javadocs) through our Maven repository: https://maven.gremlin.com. You can find the source on GitHub.
You'll need to enable the SDK by setting the <span class="code-class-custom">FAILURE_FLAGS_ENABLED</span> environent variable when you run the application where you add the SDK.
You can get started by adding failureflags to your package dependencies. In your application's build.gradle, add the following implementation dependency:
Under repositories add this maven repository:
Then bring in the library and instrument the part of your application where you want to inject faults.
Go
You can find the source on GitHub.
You'll need to enable the SDK by setting the <span class="code-class-custom">FAILURE_FLAGS_ENABLED</span> environent variable when you run the application where you add the SDK.
For Go/Golang applications, start by adding the following to your package dependencies:
Next, instrument the part of your application where you want to perform experiments by adding <span class="code-class-custom">Invoke()</span>. Give the flag a name using the <span class="code-class-custom">Name</span> property. This method checks to see if there's an active experiment running that matches the name of the failure flag (and any additional labels you provide), and if so, runs the experiment. Otherwise, it remains inactive and your application code executes normally. We recommend adding a failure flag immediately before or after a call to one of your network dependencies, such as a database.
You can provide additional tags for matching a Failure Flag using the <span class="code-class-custom">Labels</span> property. For example, this flag has the name <span class="code-class-custom">http-ingress</span>. It also includes the current HTTP request method and URL path in the <span class="code-class-custom">Labels</span> property: