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