Why Use Sentry with Odoo?
Odoo logs errors to files and the database, but tracking them at scale is difficult. When you run multiple Odoo instances, serve thousands of users, or have custom modules, errors get buried in log files. Sentry provides real-time error tracking with deduplication, stack traces, context, and alerting — making it dramatically easier to find and fix issues.
Sentry captures every Python exception and JavaScript error, groups them by root cause, shows you how many users are affected, and alerts your team when new issues appear. For Odoo deployments, this transforms error management from reactive (waiting for user complaints) to proactive (fixing issues before users notice).
Setting Up Sentry for Odoo Backend
Step 1: Install the Sentry SDK
# In your Odoo virtualenv
pip install sentry-sdkStep 2: Configure Sentry in Odoo
Add Sentry initialization to your Odoo startup. The cleanest approach is a custom module that initializes Sentry on load:
# __init__.py of your sentry module
import sentry_sdk
from sentry_sdk.integrations.wsgi import WsgiMiddleware
import odoo
sentry_sdk.init(
dsn='https://[email protected]/project-id',
traces_sample_rate=0.1, # 10% of requests for performance
environment='production',
release=odoo.release.version,
send_default_pii=False, # Do not send user emails/IPs
integrations=[],
)
# Wrap WSGI application
odoo.http.root = WsgiMiddleware(odoo.http.root)Step 3: Add Context to Errors
Enrich Sentry events with Odoo-specific context — the current user, database, and module:
from sentry_sdk import set_user, set_tag, set_context
def _add_sentry_context(request):
if hasattr(request, 'env') and request.env.user:
set_user({'id': request.env.user.id, 'username': request.env.user.login})
if hasattr(request, 'db'):
set_tag('odoo.database', request.db)
set_tag('odoo.version', odoo.release.version)Setting Up Sentry for Odoo Frontend
If you have a SvelteKit or other frontend app communicating with Odoo, add the Sentry JavaScript SDK:
// npm install @sentry/svelte
import * as Sentry from '@sentry/svelte';
Sentry.init({
dsn: 'https://[email protected]/frontend-project',
integrations: [Sentry.browserTracingIntegration()],
tracesSampleRate: 0.1,
environment: 'production',
});Creating Odoo Tickets from Sentry
Use Sentry's webhook integration to automatically create helpdesk or project tickets in Odoo when new errors occur:
class SentryWebhook(http.Controller):
@http.route('/sentry/webhook', type='json', auth='none', csrf=False)
def handle(self, **kwargs):
data = json.loads(http.request.httprequest.data)
action = data.get('action')
if action == 'created': # New issue
issue = data.get('data', {}).get('issue', {})
http.request.env['project.task'].sudo().create({
'name': f"[Sentry] {issue.get('title', 'Unknown Error')}",
'description': f"""Sentry Issue: {issue.get('shortId')}\n
Culprit: {issue.get('culprit')}\n
First seen: {issue.get('firstSeen')}\n
Events: {issue.get('count')}\n
Link: {issue.get('permalink')}""",
'project_id': bugs_project_id,
'priority': '1' if issue.get('level') == 'fatal' else '0',
})
return {'status': 'ok'}Alert Configuration
Set up meaningful Sentry alerts that do not spam your team:
- New issue: Alert immediately for first occurrence of any error
- Regression: Alert when a previously resolved issue reappears
- Volume spike: Alert when error count exceeds threshold (e.g., 100 events in 1 hour)
- Performance degradation: Alert when P95 response time exceeds 5 seconds
Sentry vs Odoo's Built-in Logging
| Feature | Odoo Logging | Sentry |
|---|---|---|
| Error capture | Log files, DB | Real-time, structured |
| Deduplication | None | Automatic grouping |
| Stack traces | In log files | Rich, with local variables |
| User context | Manual | Automatic |
| Alerting | None | Email, Slack, PagerDuty |
| Performance monitoring | None | Traces, spans, P95 |
| Release tracking | None | Per-release error trends |
Sentry Pricing
| Plan | Cost | Events |
|---|---|---|
| Developer | Free | 5K events/mo |
| Team | $26/mo | 50K events |
| Business | $80/mo | 100K events |
| Self-hosted | Free | Unlimited |
DeployMonkey + Sentry
DeployMonkey can configure Sentry for your Odoo instances. Our AI agent helps set up the DSN, configure sampling rates, and create alert rules tailored to your deployment.