Configuring Sentry Release Health to monitor deploy impact
TypeScriptTo configure Sentry Release Health to monitor the impact of your deployments, you’ll first need to create a Sentry project. The project is the central unit of work in Sentry, each of your applications or services will have its own project. This project will collect and aggregate the error data and release health metrics you send to Sentry.
Here is a step-by-step guide on how to create a Sentry project with Pulumi using TypeScript, including the necessary Sentry resources such as SentryProject and SentryRule for alerting.
Step 1: Set up Pulumi and Sentry Provider
Make sure you have Pulumi installed and set up. Install the Sentry provider using npm, and configure environmental variables for Sentry authentication:
npm install @pulumi/sentry
For authentication, Sentry expects
SENTRY_AUTH_TOKEN
to be set in your environment variables.Step 2: Create a New Pulumi Project
Create your new Pulumi project by running
pulumi new
and selecting TypeScript as the language.Step 3: Write the TypeScript Program
Now, write the TypeScript Pulumi program to set up a Sentry project. Below is your Pulumi program for this purpose:
import * as pulumi from "@pulumi/pulumi"; import * as sentry from "@pulumi/sentry"; // Replace these values with the ones for your Sentry organization const sentryOrganizationSlug = "your-sentry-organization-slug"; // Your Sentry organization slug // Create a new Sentry project for your application const project = new sentry.SentryProject("my-project", { organization: sentryOrganizationSlug, team: "your-team-slug", // Sentry team slug in your organization to associate with the project name: "My Application", // The name of your project slug: "my-application", // URL-friendly version of your project name, must be unique within the organization platform: "javascript", // or other relevant platform for your application }); // Optionally, configure Sentry rules for alerting const rule = new sentry.SentryRule("my-rule", { organization: sentryOrganizationSlug, project: project.slug, actionMatch: "all", // Type of matching for the actions section ('all' or 'any') filterMatch: "all", // Type of matching for the filter section ('all', 'any' or 'none') frequency: 5, // Frequency of this rule in minutes name: "Alert Rule", // A descriptive name for this rule conditions: [{ id: "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition", }], actions: [{ id: "sentry.rules.actions.notify_event.NotifyEventAction", targetIdentifier: "email", // an email or other valid target for notifications targetType: "User", // who or what to send notifications to (User, Team, etc.) }], }); // Export the project slug as an output export const sentryProjectSlug = project.slug;
In this program:
- A Sentry project is created that associates with your Sentry organization and team. Make sure to replace placeholders with actual values from your Sentry setup.
- An optional alerting rule is created that triggers a notification when a new event is seen for the first time.
- The
sentryProjectSlug
is exported as an output so you can easily reference it elsewhere.
To learn more about Sentry's Pulumi resources and their properties, you can use these links:
Step 4: Deploy Your Infrastructure
Run the following Pulumi command to preview and deploy your stack:
pulumi up
Pulumi will show you a preview of the resources to be created and ask for confirmation before proceeding. After confirmation, it will set up the Sentry project and rule.
This gives you a basis for integrating Sentry Release Health with your deployment process. To complete the integration, make sure that your CI/CD process includes calls to Sentry APIs to create releases and associate commits, which help Sentry track new releases and their impact on error rates.
For the next steps, follow Sentry's documentation on configuring your applications to report to Sentry and set up release tracking. This typically involves adding a Sentry SDK to your application and configuring it with your project's DSN (Data Source Name).
Remember, the Pulumi program is the first step for infrastructure and setup needed at the Sentry side. The application code must also be instrumented using Sentry's SDKs to report errors and release information.