Python for Entrepreneurs Transcripts
Chapter: Monitoring and logging in production
Lecture: Introduction to logging and monitoring
0:03 The last thing you want to see in your web app is some kind of crash, a 500 error or maybe it's even a little more subtle than this falling octacad,
0:21 So, how do we know when this has happened? Right, our server is not going to tell us, it's just going to return 500 to the user and that's it.
0:29 Our users will tell us sometimes, if someone comes to buy something from you
0:34 and they see this page instead, they are going to lose a lot of faith in your app,
0:38 in your product, they are going to wonder - did you already charge their credit card or did it crash before? Should they try to buy it again,
0:45 will they be charged but not receive their product? Whatever it is. This is really bad when your app crashes or behaves badly.
0:55 So how do we know about it? Well, users will sometimes tell you, but for every user that tells you
1:01 something is wrong, there will be plenty of users that have come to your site and just got, "this thing is crap" and left.
1:08 So, relying on the users is not enough, and often they will say "well, it crashed and I tried this and it didn't work",
1:13 how do you know what crashed, how do you track that down? So, we want to first talk about how we can at least record this information locally,
1:20 some of it, so that we have it, and ideally, we would get notified, right away like possibly by the time the user was done typing up an email saying
1:30 look I went to this URL it crashed, you've already actually got it fixed, or you are already working on the fix and you can shoot them a quick note
1:38 "hey thanks, I already noticed here is the problem, come back in 15 minutes and everything will be working great",
1:44 that actually turns a bad experience into pretty good experience, if you hit a website and the owner already
1:52 like maybe proactively emails you saying "hey, I saw you run into this error, I am working on it, it will be fixed soon", before you even contact them,
1:58 that's ridiculously good customer service; so, how are we going to do that? Well, two main things- we are going to start with logging,
2:05 so having logging is important not just for the errors the users run into, but also for auditing who logged in from where, when,
2:12 people trying to hack your website, what other things are going on, are you running out of memory and so on, how many requests per second,
2:22 there is just lots of stuff that you want to do in logging that you are going to come back and look at.
2:28 But that's just what I would think of as level one, right, logging puts into a file what has happened, and if you bother to go sift through that file,
2:35 you might learn something about what's happening, that's great. But, like I said, ideally, you'd like to know straight away when that happened,
2:43 so we are going to talk about monitoring with the Rollbar, and how we can actually capture, not just some of what went wrong,
2:50 but possibly even the state of the variables in the call stack, the URL,
2:54 the platform version, the browser version, everything about the application state
3:02 from both the client side and the server-side and send those notifications to us right away. Slack, text message, whatever.
3:10 That's what this chapter is about, first we are going to focus on logging
3:13 and then we are going to sort of take it to level two the next level with monitoring.