From the course: Faster Python Code

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Monitoring and alerting

Monitoring and alerting - Python Tutorial

From the course: Faster Python Code

Start my 1-month free trial

Monitoring and alerting

- [Instructor] It's always good to do design and code reviews and to benchmark your code. However the real money is in production. Even with the best process in place, bugs and performance issues will slip into production from time to time. And, you should be prepared. The practice of keeping an eye on production is called monitoring and alerting. A lot of companies have monitoring and alerting in place, but only for bugs or the check that services are up. There are many systems from the new and shiny Prometheus, InfluxDB, and Elastic Stack to the good old Nagios inference. Whatever system you use, make sure to add performance metrics to it. It's very easy to add a decorator to some functions that record how much time they take. Here's an example. In line six, we have a time decorator. At line nine, we record the start of the time. And then, at line 11, we call the function. In line 13, we calculate the duration. In line 15, we print out how much time this function took. In real life,…

Contents