Chapter 06

Triage and alerts

Every week at stand-up, Twig's engineers go through the new issues together. At first it takes 5 minutes. As Twig grows, it takes 10, then 20, and eventually the whole meeting. Most of that time goes to the same questions every week: who owns this issue, and does it need attention now?

So the engineers look for ways to send each issue to the people who own it, and to only interrupt someone when an issue needs them.

Route issues to their owners with assignment rules

Most issues belong to one team. The Trips team owns everything under src/trips/, including Trip details. Instead of assigning those issues by hand at stand-up, the engineers add an assignment rule that sends issues from src/trips/ to the Trips team Fig. 1.

New assignment rule

Matching exceptions will be automatically assigned to the chosen user or role.

FiltersMatchAllAny
Exception source
∋ contains
src/trips/
Add filter
Assignee
Trips

184 exceptions across 7 issues would have been assigned in the last 7 days

Test ruleCancelSave
Fig. 1 – This rule assigns issues from source files under src/trips/ to the Trips role. Before you save it, you can test how many exceptions it would have matched in the last 7 days.

Rules run at ingestion, after source maps are applied, so they match Twig's unminified stack trace. The first rule that matches assigns the issue, so specific rules go first.

Track fixes in GitHub

Twig's engineering teams plan their sprints in GitHub issues. They configure Error Tracking to create mirrored issues in GitHub issues directly, so they can groom it as a part of their sprint planning Fig. 2.

twig/webIssues

Trip details fail when the host record doesn't load #381

P1Trips
Openopened just now
PH
posthog-app opened this issue just now

Summary

Trip details fail to open for a booked stay. The guest sees an error instead of their host and trip information.

Impact

Sessions
47
Guests
31
Stays
3

Evidence

TypeError: Cannot read properties of undefined (reading 'name')

Top frame: src/trips/trip-details.ts:12:20

First seen four minutes after web@1.4.2. Affected recordings show repeated clicks on Try again.

Suggested fix

Pass Twig's loaded host records to readTripHost, and show a fallback when the host name is missing.

PostHog issue: app.posthog.com/error_tracking/...

Fig. 2 – A GitHub issue created from PostHog. PostHog fills in the link back to the issue, and you can edit the body to add the impact and a suggested fix before you create it.

If your team works out of GitLab, Linear, or Jira, you can do the same.

Get alerted when an issue spikes

Some issues can't wait for the next stand-up. When Trip details breaks for hundreds of guests, the Trips team wants to know right away, without a message for every new issue.

PostHog alerts on three triggers:

  • Issue created fires for every new issue, which can mean many messages a day.
  • Issue reopened fires when a resolved issue comes back, which catches regressions.
  • Issue spiking fires when an issue gets far more exceptions than usual. PostHog compares each 5-minute window with the issue's baseline from the past hour Fig. 3.

Trip details fail to load

Occurrences over the last hour

Spiking
Per 5 minutesBaseline: about 60
720
1 hour agoNow
Alert720 occurrences in 5 minutes, against a baseline of about 60
Fig. 3 – Twig's Trip details issue gets 720 occurrences in the latest 5-minute window, about 12 times its baseline from the past hour.

The engineers only alert on spiking issues. New issues already go to the team that owns them, which grooms them, so an alert for each one only adds noise. Spike alerts go to the Trips team's Slack channel.

When the spike alert fires, someone on the Trips team opens the issue and watches a recording of a guest who hit it. If it's a real bug, they fix it and link the GitHub issue. If it's noise, they suppress it.

Stand-up takes 5 minutes again.

To set up the same for your app, create a role for each team in your organization settings, then add assignment rules and alerts in Error Tracking settings. Alerts can go to Slack or a webhook. PostHog AI can suggest rules and alerts from your recent exceptions:

Prompt for PostHog AI
Group my $exception events from the last 30 days by the source files in $exception_sources and the path of $current_url, and leave out third-party code. Name each group by the part of my product it covers, like trips or bookings. Suggest one error tracking assignment rule per group, with the property, operator, and value it filters on. List the rules most specific first, because the first rule that matches assigns the issue. Then suggest which error tracking alerts each team needs, for reopened issues and spikes, and where to send them.
Set up triage with PostHog AIIt suggests assignment rules and alerts from your recent exceptions. You add them in Error Tracking settings.

Self-driving

As Twig grows with more users, checking alerts and dashboards and getting issues auto-assigned still leaves many exceptions unresolved. So Twig's engineers turn to self-driving to help resolve these issues.