Python for Entrepreneurs Transcripts
Chapter: Monitoring and logging in production
Lecture: A peek inside Michael's Rollbar account

Login or purchase this course to watch this video and the rest of the course contents.
0:02 Let's look inside my Rollbar account.
0:05 I have got a couple of web applications registered. Here is Talk Python Training,
0:09 I also have Python Bytes registered there,
0:12 I have got Talk Python The Podcast site, which handles a huge amount of traffic,
0:16 that site is registered here and so on. Right now,
0:19 I am on the Talk Python Training dashboard, and you can see
0:22 there is a couple of errors that have occurred, now it might look like this is a problem,
0:25 but in fact these are not coming from production,
0:29 they are coming from somewhere else and so we don't need to worry about them too much,
0:32 we can go and resolve them and they will just go away from our dashboard,
0:36 but nothing major is going on right now, there will be some items that have occurred,
0:40 some errors that have occurred that I have archived away,
0:44 so let’s look over here, this is the items section,
0:47 and we can see here is all the errors and other activity on my site that has occurred
0:55 over as long as the data is stored,
0:58 OK, so you can see all activity, all dates and so on,
1:01 and if we are only looking for errors, we could come over here and say
1:05 "just show me the errors" and it also makes the deployment story here,
1:10 so for example here is some errors that have occurred
1:13 and then these are the deploys that have happened,
1:15 and if I click this, here it will actually take me
1:19 to view the files that were deployed, you can see the changes in GitHub
1:21 and all the commits and all then link over to GitHub from there and so on.
1:25 And, these are actually the ones that have been resolved, that have been fixed,
1:29 so here is an error that I ran into, you can see it occurred in production,
1:34 and then once I realized what was happening, I replicated it in dev
1:40 and then I pushed a new release out and it was fixed.
1:45 So, this I got a notice, basically a little pop up saying hey,
1:49 something is wrong with your app here, so that was really nice
1:53 that it told me this error and you can see I've checked little box
1:57 to say this is solved, so if I see the open items, it will be gone now.
2:01 So let me give you a concrete story where this has really helped me
2:04 and then we'll look and see how that happened.
2:06 So over here I've got this section "what users think".
2:10 And this is just like reviews that I got off of iTunes and other people
2:16 sent me on public places like Twitter or something,
2:19 so when people say cool things about the show,
2:22 I put it here so people who are new to the show they come and look
2:24 "oh, maybe this is worth subscribing to", right,
2:27 so thanks Nigel, who says: "Michael finds great guests for the show,
2:30 and really motivates me to become a better Python programmer, thanks for all the effort,"
2:34 really cool, and this is like randomly selected, so as I refresh this,
2:37 you'll see different quotes coming up here, that leads us to error number 49,
2:42 what has happened here?
2:44 So it turned out I entered these quotes into a database locally,
2:47 I developed this UI locally and I tested it, it worked great
2:52 and then I pushed everything to production;
2:54 SQLAlchemy recreated the database structure just fine on the server
2:58 but, this set was empty because I hadn't yet gone to the admin section
3:03 and entered all of the pieces, I hadn't entered any quotes basically
3:07 and somewhere we were doing doing random.choice and it turns out
3:13 you cannot choose from an empty sequence, which took down the homepage of my website.
3:17 So that freaked me out a little bit, I got a quick notification
3:21 and I went over to Rollbar and said "oh my gosh, what is going on here?"
3:25 and actually I didn't even know that this was the error
3:30 I just saw cannot "load page, 500", something like that.
3:33 So I drop in here it says... OK, let's see, here is the problem,
3:37 we've got in the home controller, and the home view model
3:43 which is calling this function get random views and we are specifying the count,
3:47 notice how it defaults to 3 but that is the value we are passing,
3:51 and then we are calling choice.append and we are doing a random.choice
3:56 So basically, we did a query to the database, get all the reviews back
4:01 and then we are going to do random.choice for as many times as this count is passed in.
4:05 And, what is the conclusion?
4:08 Well, the conclusion is that "reviews" was empty.
4:12 So this is a pretty simple error to solve, but if it was more complex
4:15 we can do a couple of cool things like look, I can click here and I can see the arguments,
4:21 these are the arguments that were passed to random, notice the sequence is empty.
4:27 And I can open up the arguments here and say "OK, self was passed to this function,
4:32 get_random_reviews, and count was apparently took on the default and just did 3".
4:38 But if this was a different number, it would have captured the
4:41 actual arguments passed here, how cool is that?
4:44 So you also see the locals like we are creating the chosen things
4:48 and so you can see all the data that was present when there was an error
4:52 and that is super helpful.
4:54 So, we can also see how many times this has occurred,
4:57 this happened at this time, on this machine, on this address this looks like
5:01 it was me reproducing it in the dev mode but it did happen unfortunately in production.
5:05 You can integrate with this people API or you can say
5:08 if ever there was an error, here is the active user,
5:12 so you could actually contact the user and say "hey Joe,
5:16 I see you bought my class and you came to this page and it crashed,
5:19 here was the problem, we got that fixed, thanks for reporting it" or whatever.
5:23 So browser OS, information about IP addresses and it says
5:30 "they were not able to find a deploy that caused it"
5:34 because it wasn't actually caused by a deploy,
5:37 it was just- I guess it was caused by a deploy, but sometimes they can go back
5:40 and look at the GitHub this in integrated with GitHub they can find
5:43 actually a deployment that caused it, OK,
5:46 here is the first deployment that it saw the error in.
5:48 And similar items, nobody's run into this problem,
5:51 you can go to community solutions and see if anybody has a fix for,
5:54 you cannot select from an empty sequence.
5:57 Alright, so this is really nice information to have, and the fact that it appears instantly,
6:04 in all the places that you are going to set up an integration with,
6:07 is really like the half the value, just right there,
6:11 just getting notified immediately when there is an error,
6:13 and then that notification coming with all this great information
6:16 so you don't really need to debug it, you just got to go fix the code.
6:20 Well, that's really great too.
6:22 So, in the subsequent videos I am going to show you
6:24 how to integrate Rollbar into the Blue / Yellow Rockets application
6:28 and that should be really easy to do.