Python for Entrepreneurs Transcripts
Chapter: Monitoring and logging in production
Lecture: Concepts: Monitoring with Rollbar

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Let's review the core concepts of integrating Rollbar into a Pyramid web application like the Blue / Yellow Rockets App.
0:09 So, most of this is going to happen in the configuration.ini file. We replaced our app:main with pipeline:main and the pipeline
0:18 basically lets Rollbar get a look at all the requests and then it feeds it on to our app,
0:25 and then it rolls it back and so if there is kind of errors or anything like that, Rollar will get to catch them before they flow back to the user.
0:33 We added our Rollbar ids here, we have our JavaScript one, if we want to use that injected in code, we also have the ones
0:41 that we got directly from Rollbar that they pull in themselves, so rollbar.access_token, rollbar.environment, be sure to set the environment correctly,
0:49 remember that really helps knowing whether you should freak out if you see an error or "oh no, that's just test, don't worry about it",
0:55 we can say which branch back in GitHub we want to go from, we also need to add this filter:rollbar
1:01 and set our environment and access token there as well. it looks like in the slides I have dev in production, don't make those different, whatever,
1:09 those should make them the same. OK, so you put that in here, make sure you set, you install Rollbar the package
1:17 and you set it as a requirement in your setup, and once you've done that, then you can just config.include('rollbar.contrib.pyramid'),
1:26 in your main setup somehow and that is all you have to do, all the errors that are uncaught will be reported to Rollbar, how lovely is that?
1:34 Now, there is one more step, because sometimes you actually handle errors there is a crash and you don't want to let your app crash,
1:41 you never want to let your app crash, so ideally you handle these errors and Rollbar will say "you didn't handle this one,
1:48 you should have a try / except or more error handling" or something,
1:51 but if you do handle it, it won't show up in Rollbar unless you take some special steps. So if we are going to report handled errors,
1:59 we are going to need to import Rollbar initialize it with our access token
2:04 and the mode production dev, whatever, probably pull that out of a configuration file, and then we are going to do a try / except block,
2:13 so we'll try something risky and if we just want to report a message not a full on error, we can say "we got an IO Error for the risky operation
2:19 and this is just a warning, we handled it, it's cool". If it's entirely uncaught, maybe we want to actually submit it as a full-on error
2:28 as if it were uncaught, so we can report exception info and that will just create more or less what you saw when we didn't handle it at all.
2:35 But this way we can catch the error, still report it, but not have our users see an entirely terrible crashed server right,
2:44 that definitely shakes people's confidence in your product. Alright, that's Rollbar, super easy to integrate, they've got a free plan
2:53 and it is super valuable, I really appreciate it having it around, so if you depend on your site being up for your business,
2:59 something like Rollbar is definitely recommended.


Talk Python's Mastodon Michael Kennedy's Mastodon