Perl support for Raygun

Nick HarleyProvider UpdatesLeave a Comment

This is a guest post by Travis Holton from iwantmyname who has been kind enough to write about his work creating a Perl tool to interface with the Raygun API….

During my career as a Perl developer, I’ve had the opportunity to develop in a number of frameworks including Catalyst, Mojolicious and Mason. As is often the case when juggling projects for work or fun, I frequently found myself working in at least two of these at any given point in time.

Therefore, when I set out to implement some code so that our company website could interact with the Raygun API, it was important to me to make it easy to use with different Perl frameworks. With that in mind, I wrote WebService::Raygun, a Perl tool for interfacing with the Raygun.io API.

perl 2

In order to generate snazzy graphs, the Raygun API can collect a range of information about the nature of an error, the time it occurred, the HTTP request that caused it, the host machine it occurred on, CPU information, etc. While there are a number of tricks and libraries available in Perl for getting at this information, some of it can be a real pain to track down and may vary depending on the web framework being used.

Where it can, WebService::Raygun takes care of much of this work by loading information about the environment and the host machine on its own. Although the caller must still provide the “request” and “error” components of the message details, WebService::Raygun does accept several data types including HashRef, as well as some that are usually available in web frameworks like HTTP::Request, Catalyst::Request, and Mojo::Message::Request for the “request” field.

The error field also accepts a number of object types including Devel::StackTrace, Mojo::Exception, Moose::Exception, Moose::Object (thrown by HTTP::Throwable) as well as a string containing stack traces generated by using “die” or Carp “confess”.

Here’s an example of me using it in a Catalyst MVC app:

The message field does take a number of other optional arguments.
* occurred_on: yyyy-mm-ddTHH:MM:SS+ZZzz defaults to current time GMT
* tags: ARRAYREF
* user_custom_data: HASHREF
* environment: HASHREF defaults to some system values

To conclude, I hope that this little module proves helpful for integrating your system with Raygun.io.

You can find documentation for WebService::Raygun on CPAN: 

https://metacpan.org/pod/WebService::Raygun

Feel free to fork my project on GitHub: https://github.com/heytrav/raygun4perl.git

We would absolutely recommend Raygun to any business which relies on healthy software to serve there customers. Andrew Schofield, Chief technology officer at Timely. Take a free 14 day trial. Request a short demo of Raygun.

Leave a Reply

Your email address will not be published. Required fields are marked *