Business Problem
Bad deployments cause outages. By the time someone notices the error spike, investigates, and rolls back, users have been impacted for 15-30 minutes or more.
Solution Overview
Connect Sentry MCP Server with GitHub Actions and Slack to monitor error rates post-deployment and auto-rollback if error thresholds are exceeded.
Implementation Steps
Monitor Post-Deploy
After each deployment, watch error rates in Sentry for a 10-minute window.
Detect Anomalies
Compare current error rate against the baseline from the previous version.
Auto-Rollback
If errors exceed 2x baseline, automatically trigger a rollback deployment.
async function monitorDeployment(deployId, baseline) {
for (let i = 0; i < 10; i++) {
await sleep(60000); // check every minute
const current = await sentry.getEventCount({ project: PROJECT, timeRange: '-1m' });
if (current > baseline * 2) {
await github.triggerWorkflow({ workflow: 'rollback.yml', ref: 'main', inputs: { deploy_id: deployId } });
await slack.sendMessage({ channel: '#deploys', text: `🚨 Auto-rollback triggered: error rate ${current}/min vs baseline ${baseline}/min` });
return;
}
}
await slack.sendMessage({ channel: '#deploys', text: `✅ Deployment ${deployId} stable after 10 min` });
}Post-Rollback Analysis
Generate a report of the errors that triggered the rollback for debugging.
Code Examples
async function getErrorBaseline() {
const events = await sentry.getEventCount({ project: PROJECT, timeRange: '-24h' });
return events / 1440; // average per minute over 24h
}