Performance Monitoring for Python apps

Application Performance Monitoring with Airbrake makes it easy to:

  • Understand high-level performance: Quickly see a broad performance overview for your whole application.
  • Monitor user satisfaction: Measure user satisfaction with your app performance using Apdex.
  • Catch problem routes: Identify routes with slow or error-prone performance.
  • Analyze granular performance metrics: Zoom into specific endpoints to see time spent in the DB, view, cache, external requests, and more.
  • Dive into database performance: Analyze SQL database queries being called and how long they take.
  • Track your background jobs: Monitor background job performance, track job failures and durations.

Python Support

Python support for Performance Monitoring is currently in early access

Airbrake Performance Monitoring for Python supports:

  • Django
  • Flask
  • Manual tracking via API (more info below)

Tracking Performance manually

Not using the Django or Flask frameworks? Track performance manually by using the following API:

Sending route stats

notifier.routes.notify allows sending route stats to Airbrake. The library provides integrations with Django and Flask. (your routes are tracked automatically). You can also use this API manually:

import pybrake.RouteMetric as RouteMetric

metric = RouteMetric(method=request.method, route=route)
metric.status_code = response.status_code
metric.content_type = response.headers.get("Content-Type")
metric.end_time = time.time()

notifier.routes.notify(metric)

Sending route breakdowns

notifier.routes.breakdowns.notify allows sending performance breakdown stats to Airbrake. You can use this API manually:

import pybrake.RouteBreakdowns as RouteBreakdowns

metric = RouteBreakdowns(method=request.method, route=route)
metric.response_type = response.headers.get("Content-Type")
metric.end_time = time.time()

notifier.routes.notify(metric)

Sending query stats

notifier.queries.notify allows sending SQL query stats to Airbrake. The library provides integration with Django (your queries are tracked automatically). You can also use this API manually:

import pybrake.QueryStat as QueryStat

metric = QueryStat(
  method=request.method,
  route=route,
  query="SELECT * FROM foos"
)
metric.end_time = time.time()

notifier.queries.notify(metric)

Sending queue stats

notifier.queues.notify allows sending queue (job) stats to Airbrake. The library provides integration with Celery (your queues are tracked automatically). You can also use this API manually:

import pybrake.QueueMetric as QueueMetric

metric = QueryMetric(queue="foo_queue")
notifier.queues.notify(metric)

Congratulations!

Great job! If you’ve used this example in your app, you can visit your Airbrake project’s Performance Dashboard to see your performance data! Soon enough you’ll have more insights into your application’s performance. In the meantime why not check out the Performance Dashboard features. Have questions about Performance Monitoring? Check out our Performance Monitoring FAQ for more information.

Want to learn more?

Want to learn more about pybrake? Check out our official GitHub repo.