Label your exceptions and stay organized with Raygun’s tagging featurePosted Sep 7, 2016 | 4 min. (797 words)
Tags have been a part of Raygun Crash Reporting for a some time now and are an important part of helping developers track and filter their exceptions. Tags may seem simple at first glance but the power they give developers to stay organized and save time in tracking down the source of an exception makes them an integral part of maintaining applications.
It only takes a few minutes to get tags set up in your code but they can save you hours of developer time down the road when your application grows larger and the exception causes become more complex.
So what are tags?
Tags are labels that can be given to exceptions inside your code. These labels are then passed onto Raygun when exceptions are tracked. Having tags on your exceptions gives you several powerful abilities when it comes to better organizing your inbound exceptions. Raygun allows you to filter your exceptions in three ways:
- Inbound filters: You can filter out inbound exceptions by tag.
- Searching: You can search for specific tags to see associated exceptions.
- Filtering: You can filter for or against specific tags.
These three abilities are great in themselves, but where they really shine is when used in unique ways. For example:
Do you have a custom checkout path through your application for certain VIP users?
You can use the tag feature to quickly differentiate the exceptions thrown along these custom paths from normal user paths even if the stack traces are nearly identical.
Do you have pages that contain several different resources or scripts being loaded from different sources?
You can use tags to logically separate out those pages into distinct sections to narrow down the source of an exception when one is thrown. So when an exception gets thrown due to a small section of a loaded page you can quickly drill down on know which section without having to sift through error details.
Here at Raygun, we use tags when building Visual Studio extensions to capture a snapshot of the currently running/installed extensions when an exception is thrown. At a deeper level, when an exception occurs we do a quick query of currently active extensions and add them as tags to the exception before sending it to Raygun. This allows us to track which extensions might be causing a conflict and to quickly search/filter through those exceptions. Additionally it enables us to see if there are any patterns between the exceptions and extensions that were active at the time.
Do you use different environments for testing, dev and/or production?
You can use tags to differentiate between environments. This is especially important for incident triage – if you see a critical error instance with a ‘production’ tag, you can then prioritize your workload to fix the production bug. If, on the other hand, the error instance was tagged as being in a test environment, you would may choose to give that error instance less priority on your backlog.
Now that we know why tags are important, let’s take a look at how to effectively tag exceptions in detail:
1. Inbound Filters
Tags can be used with Inbound Filters to prevent certain exceptions from being tracked by Raygun.
Here’s how to set it up:
Click on Filtering in the left sidebar navigation menu under Crash Reporting:
Click on ‘Tag’ in the ‘Create a filter’ menu, and enter in the tag. Click ‘Add Filter’ to apply:
Being able to quickly search for a specific tag saves a developer from having to look through an error group in order to find a specific occurrence or application state. This, in turn, gets a developer closer to resolving the exceptions that come in from their application in a much shorter amount of time.
Here’s how to get started searching exceptions for a specific tag:
Enter the tag into the search bar located in the left sidebar and hit your ‘Enter/Return’ key:
Much like searching, being able to filter tags (either to include them or exclude them) can be a massive time saver when your application grows larger and more complex .
To setup a quick filter for tags:
Click on ‘Add filter’ on the Raygun Crash Reporting dashboard:
In the ‘Add Filter’ window, select ‘Tag’ from the ‘Tag’ dropdown menu. Then choose an ‘Operator’ (equal or not equal) from the next dropdown, and then finally enter in the tag under the ‘Label’ text field. Then click ‘Apply filter’:
We offer the tag feature on the following supported languages:
We are continuously working adding tag support to other languages but if you have a specific language request please let us know!