Skip to main content

Sentry Error Monitoring

This document explains how Eli Health's Sentry error monitoring is configured and managed. All configuration is done via code in the eli-devops repository, enabling version control and reproducible setups.

Overview

ItemValue
Organizationeli-health
Dashboardsentry.io/eli-health
Configurationeli-devops/sentry/sentry_config.yaml
Management Scripteli-devops/sentry/sentry_manager.py

Environments and Projects

EnvironmentSentry ProjectSlack Channel
Developmenteli-react-native-dev#alerts-dev
Stagingeli-react-native-staging#alerts-staging
Productioneli-react-native#alerts-production

Architecture

All Sentry configuration is managed at the server level, not in the mobile app code:

Benefits of Server-Side Configuration

  1. Instant updates - No app deployment required
  2. Version controlled - All changes tracked in Git
  3. Consistent - Same filters across all environments
  4. Auditable - Clear history of configuration changes

Member Management

Current Members

Members are defined in sentry_config.yaml:

members:
- email: chip@eli.health
role: owner
name: Ciprian (Chip) Rarau
- email: thomas@eli.health
role: owner
name: Thomas Cortina
- email: daniel@eli.health
role: member
name: Daniel Shaban
# ... more members

Available Roles

RoleAccess Level
ownerFull organization access including billing
adminAdmin access (cannot change billing)
managerCan manage teams and projects
memberStandard member access to view and resolve issues

Adding a New Member

  1. Edit the configuration file:
cd eli-devops/sentry
nano sentry_config.yaml
  1. Add the new member to the members section:
members:
# ... existing members ...
- email: newuser@eli.health
role: member
name: New User Name
  1. Apply the changes:
# Dry run first to see what will happen
python3 sentry_manager.py members --dry-run

# Apply the changes
python3 sentry_manager.py members
  1. The new member will receive an email invitation to join Sentry

How Member Sync Works

The sync is idempotent:

  • New members in config → Invited to Sentry
  • Role changed in config → Updated in Sentry
  • Member removed from config → NOT removed from Sentry (manual removal required)

Alert Configuration

Alert Types

AlertConditionDefault Threshold
New Error DetectionFirst time an error is seenN/A
High User ImpactMultiple users experience same error10 users/hour
Error Rate SpikeError count exceeds threshold50 errors/hour
Repeated ErrorSame error occurs multiple times3 occurrences/hour

Environment-Specific Thresholds

Updating Alert Thresholds

  1. Edit the alert_types section in sentry_config.yaml:
alert_types:
error_spike:
environments:
production:
threshold: 20 # Change from 15 to 20
window: 60
  1. Apply the changes:
# Preview changes
python3 sentry_manager.py setup --env production --dry-run

# Apply (this deletes ALL existing alerts and recreates them)
python3 sentry_manager.py setup --env production

Important: The setup command always performs a complete cleanup before creating alerts. This ensures no duplicate or orphaned alerts.

Error Filtering

How Filters Work

Inbound filters drop errors before they appear in Sentry. This reduces noise and keeps your dashboard focused on real issues.

Currently Active Filters

The following error patterns are automatically filtered out:

CategoryPatterns
Network Errorsno-internet, network-request-failed, Network request failed, fetch error, The network connection was lost, The request timed out
Auth Errorsauth/invalid-credential, The supplied auth credential is malformed or has expired
Development NoiseMetro is running, Connection to http://localhost:8081, Eli test
Browser IssuesResizeObserver loop limit exceeded, Non-Error promise rejection captured
Camera/HardwareThe camera is too close, QR detected in preview but finder patterns not found

Adding a New Filter

  1. Edit sentry_config.yaml:
inbound_filters:
ignored_errors:
# Add your new filter
- message: "your error text here"
partial_match: true # ALWAYS use true
enabled: true
description: "Brief description of what this filters"
  1. Apply the filter:
# Preview
python3 sentry_manager.py filters --dry-run

# Apply to all environments
python3 sentry_manager.py filters

# Or apply to specific environment
python3 sentry_manager.py filters --env production

Filter Rules

RuleExplanation
Always use partial_match: trueAdds wildcards (*) automatically so "network error" matches "A network error occurred"
Be specific"network-request-failed" is better than "failed"
Case sensitiveAdd multiple patterns if needed for different cases

Data Scrubbing

Sentry automatically scrubs sensitive data before storing errors:

What Gets Scrubbed

Data TypePatternReplacement
Hormone Values12.5 ng/mL[HORMONE_VALUE]
Test Results45.2 nmol/L[TEST_RESULT]
Classificationsabove range, optimal[CLASSIFICATION]
IP AddressesAutomaticRemoved

Configuring Data Scrubbing

# Apply data scrubbing rules
python3 sentry_manager.py scrub --env production

Note: Advanced pattern-based scrubbing rules must also be configured in Sentry UI: Project Settings > Security & Privacy > Data Scrubbing

Commands Reference

Quick Reference

cd eli-devops/sentry

# Member management
python3 sentry_manager.py members # Sync members
python3 sentry_manager.py members --dry-run # Preview changes

# Alert management
python3 sentry_manager.py setup # Set up all alerts
python3 sentry_manager.py setup --env staging # Set up staging only
python3 sentry_manager.py setup --dry-run # Preview changes

# Filter management
python3 sentry_manager.py filters # Apply all filters
python3 sentry_manager.py filters --env prod # Apply to production

# Data scrubbing
python3 sentry_manager.py scrub # Configure scrubbing

# View configuration
python3 sentry_manager.py config # Show all config
python3 sentry_manager.py config --env prod # Show production config

Command Details

CommandDescription
membersSync organization members from config. Invites new, updates roles, never removes.
setupDelete all existing alerts and recreate from config. Use --no-clean to skip deletion.
filtersApply inbound error filters to drop unwanted errors.
scrubConfigure data scrubbing rules for PII/PHI protection.
configDisplay current configuration without making changes.

Slack Integration

Alerts are sent to environment-specific Slack channels:

GCP Cloud Logging Integration

All Sentry errors are also synchronized to Google Cloud Logging for:

  • Long-term retention (beyond Sentry's 90-day limit)
  • Correlation with other system logs using trace IDs
  • BigQuery analysis for complex error pattern queries
  • Compliance - centralized audit trail

Troubleshooting

Filter Not Working?

  1. Check the exact error message in Sentry - Copy the EXACT text
  2. Verify wildcards are applied:
    curl -H "Authorization: Bearer YOUR_TOKEN" \
    https://sentry.io/api/0/projects/eli-health/eli-react-native/ | \
    python3 -m json.tool | grep -A2 "filters:error_messages"
  3. Wait 1-2 minutes - Filters take time to propagate
  4. Note: Filters only affect NEW errors, existing ones remain

Permission Errors (403)?

The auth token needs these scopes:

  • alerts:read, alerts:write
  • project:read, project:write
  • org:read, org:write
  • member:read, member:write, member:admin

To create a new token:

  1. Go to sentry.io/settings/account/api/auth-tokens/
  2. Create token with required scopes
  3. Update auth_token in sentry_config.yaml

Alert Not Firing?

  1. Check alert is enabled for the environment in config
  2. Verify threshold - May be set too high
  3. Check Slack integration - Workspace ID must be correct
  4. Review check frequency - Some alerts only check every 30-60 minutes

File Locations

FilePurpose
eli-devops/sentry/sentry_config.yamlAll configuration (members, alerts, filters)
eli-devops/sentry/sentry_manager.pyPython script to apply configuration
eli-devops/sentry/CLAUDE.mdDetailed operational guide
eli-devops/sentry/README.mdQuick start guide