Add set_customdata to RaygunSender, apply process level custom data w… #106
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds the concept of custom data which can be set once against a RaygunSender instance and then applied to each exception which is raised through that sender. This avoids the requirement to specify custom data with each invocation of send_exception.
A new method set_customdata has been added to RaygunSender to allow this to be specified.
Examples
Setup
client = raygunprovider.RaygunSender('YOUR_API_KEY')
Initialize a client instance
client.set_customdata({'key':'value','foo':'bar'})
Use the new set_customdata method to apply the custom data Dict at a sender level
Example 1
client.send_exception(exc_info=(exc_type, exc_value, exc_traceback))
Raising an exception with no custom data specified
The resulting error has the sender level custom data applied
Example 2
client.send_exception(exc_info=(exc_type, exc_value, exc_traceback), userCustomData={'baz':'value','elden':'ring'})
Raising an exception with custom data specified
The resulting error has both the sender level custom data and the instance level custom data
Example 3
client.send_exception(exc_info=(exc_type, exc_value, exc_traceback), userCustomData={'key':'elden','foo2':'ring'})
Raising an exception with custom data specified where some keys are the same as the sender level
The resulting error has both the sender level custom data and the instance level custom data but where keys are the same the instance level is used in preference