raygun4py


Nameraygun4py JSON
Version 5.0.0 PyPI version JSON
download
home_pagehttps://raygun.com
SummaryOfficial Raygun provider for Python 2.7 and Python 3+
upload_time2024-02-28 00:20:24
maintainer
docs_urlNone
authorRaygun
requires_python
licenseLICENSE
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            raygun4py
=========

.. image:: https://travis-ci.org/MindscapeHQ/raygun4py.svg?branch=master
  :target: https://travis-ci.org/MindscapeHQ/raygun4py?branch=master

.. image:: https://coveralls.io/repos/MindscapeHQ/raygun4py/badge.svg?branch=master
  :target: https://coveralls.io/r/MindscapeHQ/raygun4py?branch=master


Official Raygun provider for **Python 2.7**, **Python 3.1+** and **PyPy**

**Python 2.7** is supported in versions <= 4.4.0

Please also refer to our `documentation site <https://raygun.com/documentation/language-guides/python/crash-reporting/installation/>`_, as this is maintained with higher priority.


Installation
============

The easiest way to install this is as a pip package, as it is available from PyPI. From your command line, run::

    $ pip install raygun4py

Test the installation
---------------------

From the command line, run::

  $ raygun4py test your_apikey

Replace :code:`your_apikey` with the one listed on your Raygun dashboard. This will cause a test exception to be generated and sent.

Usage
=====

Import and instantiate the module:

.. code:: python

    from raygun4py import raygunprovider

    sender = raygunprovider.RaygunSender("paste_your_api_key_here")

Automatically send the current exception like this:

.. code:: python

    try:
        raise Exception("foo")
    except:
        sender.send_exception()

See `sending functions`_ for more ways to send.

Uncaught exception handler
--------------------------

To automatically send unhandled exceptions, you can provide a callback function to :code:`sys.excepthook`:

.. code:: python

  def handle_exception(exc_type, exc_value, exc_traceback):
      sender = raygunprovider.RaygunSender("your_apikey")
      sender.send_exception(exc_info=(exc_type, exc_value, exc_traceback))
      sys.__excepthook__(exc_type, exc_value, exc_traceback)

  sys.excepthook = handle_exception

Note that after sending the exception, we invoke the default :code:`sys.__excepthook__` to maintain the expected behavior for unhandled exceptions. This ensures the program terminates as it would without the custom exception handler in place.

Logging
-------

You can send errors/exceptions via a logger by attaching a :code:`RaygunHandler`:

.. code:: python

  logger = logging.getLogger()
  raygun_handler = raygunprovider.RaygunHandler("paste_your_api_key_here")
  logger.addHandler(raygun_handler)

A :code:`RaygunHandler` can also be instantiated from an existing :code:`RaygunSender`:

.. code:: python

  raygun_handler = raygunprovider.RaygunHandler.from_sender(sender)

It is then recommended to use :code:`logger.exception()` or :code:`logger.error(exc_info=True)` in the scope of an :code:`except` block:

.. code:: python

  try:
      raise Exception("Example exception")
  except:
      logger.exception("Example logger.exception log")
      # Or
      logger.error("Example logger.error log", exc_info=True)

Note that using a :code:`RaygunHandler` outside the scope of an :code:`except` block will not allow it to populate a full stack trace.

Web frameworks
--------------

Raygun4py includes dedicated middleware implementations for Django and Flask, as well as generic WSGI frameworks (Tornado, Bottle, Ginkgo etc). These are available for both Python 2.7 and Python 3.1+.

Django
++++++

To configure Django to automatically send all exceptions that are raised in views to Raygun, add the following to :code:`settings.py`:

.. code:: python

  MIDDLEWARE_CLASSES = (
      'raygun4py.middleware.django.Provider'
  )

  RAYGUN4PY_CONFIG = {
      'api_key': 'paste_your_api_key_here'
  }


The above configuration is the minimal required setup. The full set of options supported by the provider can be declared in the same way:

.. code:: python

  RAYGUN4PY_CONFIG = {
      'api_key': 'paste_your_api_key_here',
      'http_timeout': 10.0,
      'proxy': None,
      'before_send_callback': None,
      'grouping_key_callback': None,
      'filtered_keys': [],
      'ignored_exceptions': [],
      'transmit_global_variables': True,
      'transmit_local_variables': True,
      'enforce_payload_size_limit': True, 
      'log_payload_size_limit_breaches': True,
      'transmit_environment_variables:': True,
      'userversion': "Not defined",
      'user': None
  }

'enforce_payload_size_limit' when enabled (default behavior) will iteratively remove the largest global or local variable from the error message until the payload is below 128kb as payloads over 128kb will not be accepted by Raygun
'log_payload_size_limit_breaches' when enabled (default behavior) will log breaches and specify which variables are being removed

Flask
+++++

To attach a request exception handler that enhances reports with Flask-specific environment data, use our middleware :code:`flask.Provider`:

.. code:: python

  from flask import Flask, current_app
  from raygun4py.middleware import flask

  app = Flask(__name__)

  flask.Provider(app, 'your_apikey').attach()

The :code:`flask.Provider` constructor can also take an optional :code:`config` argument. This should be a standard :code:`Dict` of supported options, as shown in advanced configuration below. It also returns the underlying :code:`RaygunSender`, which you may decide to use elsewhere.

WSGI
++++

An example using **Tornado**, which will pick up exceptions that occur in the WSGI pipeline:

.. code:: python

  from raygun4py.middleware import wsgi

  class MainHandler(tornado.web.RequestHandler):

    def initialize(self):
        raise Exception('init')

  def main():
    settings = {
        'default_handler_class': MainHandler
    }

    application = tornado.web.Application([
        (r"/", MainHandler),
    ], **settings)

    wsgiapp = tornado.wsgi.WSGIAdapter(application)
    raygun_wrapped_app = wsgi.Provider(wsgiapp, 'your_apikey')
    server = wsgiref.simple_server.make_server('', 8888, raygun_wrapped_app)
    server.serve_forever()

The :code:`wsgi.Provider` constructor can also take an optional :code:`config` argument. This should be a standard :code:`Dict` of supported options, as shown in advanced configuration below.

Note that many frameworks (tornado, pryramid, gevent et al) will swallow exceptions that occur within their domain.

Let us know if we're missing middleware for your framework, or feel free to submit a pull request.

Attaching raw HTTP request data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you are in a web server environment and have HTTP request details available, you can pass these and the headers through in a dictionary (see :code:`sample.py`).

Code running on Google App Engine should now be supported - you can test this locally, and has been reported working once deployed (the latter currently requires a paid account due to needed SSL support).

Documentation
=============

Initialization options
----------------------

:code:`RaygunSender` accepts a :code:`config` dict which is used to set options for the provider (the defaults are shown below):

.. code:: python

  from raygun4py import raygunprovider

  client = raygunprovider.RaygunSender('your_apikey', config={
      'http_timeout': 10.0,
      'proxy': None,
      'before_send_callback': None,
      'grouping_key_callback': None,
      'filtered_keys': [],
      'ignored_exceptions': [],
      'transmit_global_variables': True,
      'transmit_local_variables': True,
      'transmit_environment_variables:': True,
      'userversion': "Not defined",
      'user': None
  })

For the local/global/environment variables, if their options are set to False the corresponding variables will not be sent with exception payloads.

httpTimeout controls the maximum time the HTTP request can take when POSTing to the Raygun API, and is of type 'float'.

Sending functions
-----------------

+----------------+---------------+--------------------+
| Function       | Arguments     | Type               |
+================+===============+====================+
| send_exception | exception     | Exception          |
+                +---------------+--------------------+
|                | exc_info      | 3-tuple            |
+                +---------------+--------------------+
|                | tags          | List               |
+                +---------------+--------------------+
|                | userCustomData| Dict               |
+                +---------------+--------------------+
|                | httpRequest   | Dict               |
+----------------+---------------+--------------------+

**All parameters are optional.**

Call this function from within a catch block to send the current exception to Raygun:

.. code:: python

  # Automatically gets the current exception
  httpResult = client.send_exception()

  # Uses the supplied sys.exc_info() tuple
  httpResult = client.send_exception(exc_info=sys.exc_info())

  # Uses a supplied Exception object
  httpResult = client.send_exception(exception=exception)

  # Send tags, custom data and an HTTP request object
  httpResult = client.send_exception(tags=[], userCustomData={}, request={})

You can pass in **either** of these two exception params:

* :code:`exception` should be a subclass of type Exception. Pass this in if you want to manually transmit an exception object to Raygun.
* :code:`exc_info` should be the 3-tuple returned from :code:`sys.exc_info()`. Pass this tuple in if you wish to use it in other code aside from send_exception().

send_exception also supports the following extra data parameters:

* :code:`tags` is a list of tags relating to the current context which you can define.
* :code:`userCustomData` is a dict containing custom key-values also of your choosing.
* :code:`httpRequest` is HTTP Request data - see `sample.py` for the expected format of the object.

Config and data functions
-------------------------

+--------------------+---------------+--------------------+
| Function           | Arguments     | Type               |
+====================+===============+====================+
| filter_keys        | keys          | List               |
+--------------------+---------------+--------------------+

If you want to filter sensitive data out of the payload that is sent to Raygun, pass in a list of keys here. Any matching keys on the top level Raygun message object, or within dictionaries on the top level Raygun message object (including dictionaries nested within dictionaries) will have their value replaced with :code:`<filtered>` - useful for passwords, credit card data etc. Supports * at the end of a key to indicate you want to filter any key that contains that key, ie foo_* will filter foo_bar, foo_qux, foo_baz etc

+------------------+---------------+--------------------+
| Function         | Arguments     | Type               |
+==================+===============+====================+
| ignore_exceptions| exceptions    | List               |
+------------------+---------------+--------------------+

Provide a list of exception types to ignore here. Any exceptions that are passed to send_exception that match a type in this list won't be sent.

+------------------+---------------+--------------------+
| Function         | Arguments     | Type               |
+==================+===============+====================+
| on_before_send   | callback      | Function           |
+------------------+---------------+--------------------+

You can mutate the candidate payload by passing in a function that accepts one parameter using this function. This allows you to completely customize what data is sent, immediately before it happens.

+------------------+---------------+--------------------+
| Function         | Arguments     | Type               |
+==================+===============+====================+
| on_grouping_key  | callback      | Function           |
+------------------+---------------+--------------------+

Pass a callback function to this method to configure custom grouping logic. The callback should take one parameter, an instance of RaygunMessage, and return a string between 1 and 100 characters in length (see 'Custom Grouping Logic' below for more details).

+----------------+---------------+--------------------+
| Function       | Arguments     | Type               |
+================+===============+====================+
| set_proxy      | host          | String             |
+                +---------------+--------------------+
|                | port          | Integer            |
+----------------+---------------+--------------------+

Call this function if your code is behind a proxy and want Raygun4py to make the HTTP request to the Raygun endpoint through it.

+----------------+---------------+--------------------+
| Function       | Arguments     | Type               |
+================+===============+====================+
| set_version    | version       | String             |
+----------------+---------------+--------------------+

Call this to attach a SemVer version to each message that is sent. This will be visible on the dashboard and can be used to filter exceptions to a particular version, deployment tracking etc.

+----------------+---------------+--------------------+
| Function       | Arguments     | Type               |
+================+===============+====================+
| set_user       | user_info     | Dict               |
+----------------+---------------+--------------------+

Customer data can be passed in which will be displayed in the Raygun web app. The dict you pass in should look this this:

.. code:: python

  client.set_user({
      'firstName': 'Foo',
      'fullName': 'Foo Bar',
      'email': 'foo@bar.com',
      'isAnonymous': False,
      'identifier': 'foo@bar.com'
    })

`identifier` should be whatever unique key you use to identify customers, for instance an email address. This will be used to create the count of affected customers. If you wish to anonymize it, you can generate and store a UUID or hash one or more of their unique login data fields, if available.

Custom grouping logic
---------------------

You can create custom exception grouping logic that overrides the automatic Raygun grouping by passing in a function that accepts one parameter using this function. The callback's one parameter is an instance of RaygunMessage (python[2/3]/raygunmsgs.py), and the callback should return a string.

The RaygunMessage instance contains all the error and state data that is about to be sent to the Raygun API. In your callback you can inspect this RaygunMessage, hash together the fields you want to group by, then return a string which is the grouping key.

This string needs to be between 1 and 100 characters long. If the callback is not set or the string isn't valid, the default automatic grouping will be used.

By example:

.. code:: python

    class MyClass(object):

        def my_callback(self, raygun_message):
            return raygun_message.get_error().message[:100] # Use naive message-based grouping only

        def create_raygun_and_bind_callback(self):
            sender = raygunprovider.RaygunSender('api_key')
            sender.on_grouping_key(self.my_callback)

The RaygunSender above will use the my_callback to execute custom grouping logic when an exception is raised. The above logic will use the exception message only - you'll want to use a more sophisticated approach, usually involving sanitizing or ignoring data.

Chained exceptions
------------------

For Python 3, chained exceptions are supported and automatically sent along with their traceback.

This occurs when an exception is raised while handling another exception - see tests_functional.py for an example.

Changelog
=========

`View the release history here <CHANGELOG.md>`_

            

Raw data

            {
    "_id": null,
    "home_page": "https://raygun.com",
    "name": "raygun4py",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Raygun",
    "author_email": "hello@raygun.io",
    "download_url": "https://files.pythonhosted.org/packages/91/ba/c774248af4729debc3f43f9b7e865c1dc8ee9af30aa874b4d25accf65458/raygun4py-5.0.0.tar.gz",
    "platform": null,
    "description": "raygun4py\r\n=========\r\n\r\n.. image:: https://travis-ci.org/MindscapeHQ/raygun4py.svg?branch=master\r\n  :target: https://travis-ci.org/MindscapeHQ/raygun4py?branch=master\r\n\r\n.. image:: https://coveralls.io/repos/MindscapeHQ/raygun4py/badge.svg?branch=master\r\n  :target: https://coveralls.io/r/MindscapeHQ/raygun4py?branch=master\r\n\r\n\r\nOfficial Raygun provider for **Python 2.7**, **Python 3.1+** and **PyPy**\r\n\r\n**Python 2.7** is supported in versions <= 4.4.0\r\n\r\nPlease also refer to our `documentation site <https://raygun.com/documentation/language-guides/python/crash-reporting/installation/>`_, as this is maintained with higher priority.\r\n\r\n\r\nInstallation\r\n============\r\n\r\nThe easiest way to install this is as a pip package, as it is available from PyPI. From your command line, run::\r\n\r\n    $ pip install raygun4py\r\n\r\nTest the installation\r\n---------------------\r\n\r\nFrom the command line, run::\r\n\r\n  $ raygun4py test your_apikey\r\n\r\nReplace :code:`your_apikey` with the one listed on your Raygun dashboard. This will cause a test exception to be generated and sent.\r\n\r\nUsage\r\n=====\r\n\r\nImport and instantiate the module:\r\n\r\n.. code:: python\r\n\r\n    from raygun4py import raygunprovider\r\n\r\n    sender = raygunprovider.RaygunSender(\"paste_your_api_key_here\")\r\n\r\nAutomatically send the current exception like this:\r\n\r\n.. code:: python\r\n\r\n    try:\r\n        raise Exception(\"foo\")\r\n    except:\r\n        sender.send_exception()\r\n\r\nSee `sending functions`_ for more ways to send.\r\n\r\nUncaught exception handler\r\n--------------------------\r\n\r\nTo automatically send unhandled exceptions, you can provide a callback function to :code:`sys.excepthook`:\r\n\r\n.. code:: python\r\n\r\n  def handle_exception(exc_type, exc_value, exc_traceback):\r\n      sender = raygunprovider.RaygunSender(\"your_apikey\")\r\n      sender.send_exception(exc_info=(exc_type, exc_value, exc_traceback))\r\n      sys.__excepthook__(exc_type, exc_value, exc_traceback)\r\n\r\n  sys.excepthook = handle_exception\r\n\r\nNote that after sending the exception, we invoke the default :code:`sys.__excepthook__` to maintain the expected behavior for unhandled exceptions. This ensures the program terminates as it would without the custom exception handler in place.\r\n\r\nLogging\r\n-------\r\n\r\nYou can send errors/exceptions via a logger by attaching a :code:`RaygunHandler`:\r\n\r\n.. code:: python\r\n\r\n  logger = logging.getLogger()\r\n  raygun_handler = raygunprovider.RaygunHandler(\"paste_your_api_key_here\")\r\n  logger.addHandler(raygun_handler)\r\n\r\nA :code:`RaygunHandler` can also be instantiated from an existing :code:`RaygunSender`:\r\n\r\n.. code:: python\r\n\r\n  raygun_handler = raygunprovider.RaygunHandler.from_sender(sender)\r\n\r\nIt is then recommended to use :code:`logger.exception()` or :code:`logger.error(exc_info=True)` in the scope of an :code:`except` block:\r\n\r\n.. code:: python\r\n\r\n  try:\r\n      raise Exception(\"Example exception\")\r\n  except:\r\n      logger.exception(\"Example logger.exception log\")\r\n      # Or\r\n      logger.error(\"Example logger.error log\", exc_info=True)\r\n\r\nNote that using a :code:`RaygunHandler` outside the scope of an :code:`except` block will not allow it to populate a full stack trace.\r\n\r\nWeb frameworks\r\n--------------\r\n\r\nRaygun4py includes dedicated middleware implementations for Django and Flask, as well as generic WSGI frameworks (Tornado, Bottle, Ginkgo etc). These are available for both Python 2.7 and Python 3.1+.\r\n\r\nDjango\r\n++++++\r\n\r\nTo configure Django to automatically send all exceptions that are raised in views to Raygun, add the following to :code:`settings.py`:\r\n\r\n.. code:: python\r\n\r\n  MIDDLEWARE_CLASSES = (\r\n      'raygun4py.middleware.django.Provider'\r\n  )\r\n\r\n  RAYGUN4PY_CONFIG = {\r\n      'api_key': 'paste_your_api_key_here'\r\n  }\r\n\r\n\r\nThe above configuration is the minimal required setup. The full set of options supported by the provider can be declared in the same way:\r\n\r\n.. code:: python\r\n\r\n  RAYGUN4PY_CONFIG = {\r\n      'api_key': 'paste_your_api_key_here',\r\n      'http_timeout': 10.0,\r\n      'proxy': None,\r\n      'before_send_callback': None,\r\n      'grouping_key_callback': None,\r\n      'filtered_keys': [],\r\n      'ignored_exceptions': [],\r\n      'transmit_global_variables': True,\r\n      'transmit_local_variables': True,\r\n      'enforce_payload_size_limit': True, \r\n      'log_payload_size_limit_breaches': True,\r\n      'transmit_environment_variables:': True,\r\n      'userversion': \"Not defined\",\r\n      'user': None\r\n  }\r\n\r\n'enforce_payload_size_limit' when enabled (default behavior) will iteratively remove the largest global or local variable from the error message until the payload is below 128kb as payloads over 128kb will not be accepted by Raygun\r\n'log_payload_size_limit_breaches' when enabled (default behavior) will log breaches and specify which variables are being removed\r\n\r\nFlask\r\n+++++\r\n\r\nTo attach a request exception handler that enhances reports with Flask-specific environment data, use our middleware :code:`flask.Provider`:\r\n\r\n.. code:: python\r\n\r\n  from flask import Flask, current_app\r\n  from raygun4py.middleware import flask\r\n\r\n  app = Flask(__name__)\r\n\r\n  flask.Provider(app, 'your_apikey').attach()\r\n\r\nThe :code:`flask.Provider` constructor can also take an optional :code:`config` argument. This should be a standard :code:`Dict` of supported options, as shown in advanced configuration below. It also returns the underlying :code:`RaygunSender`, which you may decide to use elsewhere.\r\n\r\nWSGI\r\n++++\r\n\r\nAn example using **Tornado**, which will pick up exceptions that occur in the WSGI pipeline:\r\n\r\n.. code:: python\r\n\r\n  from raygun4py.middleware import wsgi\r\n\r\n  class MainHandler(tornado.web.RequestHandler):\r\n\r\n    def initialize(self):\r\n        raise Exception('init')\r\n\r\n  def main():\r\n    settings = {\r\n        'default_handler_class': MainHandler\r\n    }\r\n\r\n    application = tornado.web.Application([\r\n        (r\"/\", MainHandler),\r\n    ], **settings)\r\n\r\n    wsgiapp = tornado.wsgi.WSGIAdapter(application)\r\n    raygun_wrapped_app = wsgi.Provider(wsgiapp, 'your_apikey')\r\n    server = wsgiref.simple_server.make_server('', 8888, raygun_wrapped_app)\r\n    server.serve_forever()\r\n\r\nThe :code:`wsgi.Provider` constructor can also take an optional :code:`config` argument. This should be a standard :code:`Dict` of supported options, as shown in advanced configuration below.\r\n\r\nNote that many frameworks (tornado, pryramid, gevent et al) will swallow exceptions that occur within their domain.\r\n\r\nLet us know if we're missing middleware for your framework, or feel free to submit a pull request.\r\n\r\nAttaching raw HTTP request data\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\nIf you are in a web server environment and have HTTP request details available, you can pass these and the headers through in a dictionary (see :code:`sample.py`).\r\n\r\nCode running on Google App Engine should now be supported - you can test this locally, and has been reported working once deployed (the latter currently requires a paid account due to needed SSL support).\r\n\r\nDocumentation\r\n=============\r\n\r\nInitialization options\r\n----------------------\r\n\r\n:code:`RaygunSender` accepts a :code:`config` dict which is used to set options for the provider (the defaults are shown below):\r\n\r\n.. code:: python\r\n\r\n  from raygun4py import raygunprovider\r\n\r\n  client = raygunprovider.RaygunSender('your_apikey', config={\r\n      'http_timeout': 10.0,\r\n      'proxy': None,\r\n      'before_send_callback': None,\r\n      'grouping_key_callback': None,\r\n      'filtered_keys': [],\r\n      'ignored_exceptions': [],\r\n      'transmit_global_variables': True,\r\n      'transmit_local_variables': True,\r\n      'transmit_environment_variables:': True,\r\n      'userversion': \"Not defined\",\r\n      'user': None\r\n  })\r\n\r\nFor the local/global/environment variables, if their options are set to False the corresponding variables will not be sent with exception payloads.\r\n\r\nhttpTimeout controls the maximum time the HTTP request can take when POSTing to the Raygun API, and is of type 'float'.\r\n\r\nSending functions\r\n-----------------\r\n\r\n+----------------+---------------+--------------------+\r\n| Function       | Arguments     | Type               |\r\n+================+===============+====================+\r\n| send_exception | exception     | Exception          |\r\n+                +---------------+--------------------+\r\n|                | exc_info      | 3-tuple            |\r\n+                +---------------+--------------------+\r\n|                | tags          | List               |\r\n+                +---------------+--------------------+\r\n|                | userCustomData| Dict               |\r\n+                +---------------+--------------------+\r\n|                | httpRequest   | Dict               |\r\n+----------------+---------------+--------------------+\r\n\r\n**All parameters are optional.**\r\n\r\nCall this function from within a catch block to send the current exception to Raygun:\r\n\r\n.. code:: python\r\n\r\n  # Automatically gets the current exception\r\n  httpResult = client.send_exception()\r\n\r\n  # Uses the supplied sys.exc_info() tuple\r\n  httpResult = client.send_exception(exc_info=sys.exc_info())\r\n\r\n  # Uses a supplied Exception object\r\n  httpResult = client.send_exception(exception=exception)\r\n\r\n  # Send tags, custom data and an HTTP request object\r\n  httpResult = client.send_exception(tags=[], userCustomData={}, request={})\r\n\r\nYou can pass in **either** of these two exception params:\r\n\r\n* :code:`exception` should be a subclass of type Exception. Pass this in if you want to manually transmit an exception object to Raygun.\r\n* :code:`exc_info` should be the 3-tuple returned from :code:`sys.exc_info()`. Pass this tuple in if you wish to use it in other code aside from send_exception().\r\n\r\nsend_exception also supports the following extra data parameters:\r\n\r\n* :code:`tags` is a list of tags relating to the current context which you can define.\r\n* :code:`userCustomData` is a dict containing custom key-values also of your choosing.\r\n* :code:`httpRequest` is HTTP Request data - see `sample.py` for the expected format of the object.\r\n\r\nConfig and data functions\r\n-------------------------\r\n\r\n+--------------------+---------------+--------------------+\r\n| Function           | Arguments     | Type               |\r\n+====================+===============+====================+\r\n| filter_keys        | keys          | List               |\r\n+--------------------+---------------+--------------------+\r\n\r\nIf you want to filter sensitive data out of the payload that is sent to Raygun, pass in a list of keys here. Any matching keys on the top level Raygun message object, or within dictionaries on the top level Raygun message object (including dictionaries nested within dictionaries) will have their value replaced with :code:`<filtered>` - useful for passwords, credit card data etc. Supports * at the end of a key to indicate you want to filter any key that contains that key, ie foo_* will filter foo_bar, foo_qux, foo_baz etc\r\n\r\n+------------------+---------------+--------------------+\r\n| Function         | Arguments     | Type               |\r\n+==================+===============+====================+\r\n| ignore_exceptions| exceptions    | List               |\r\n+------------------+---------------+--------------------+\r\n\r\nProvide a list of exception types to ignore here. Any exceptions that are passed to send_exception that match a type in this list won't be sent.\r\n\r\n+------------------+---------------+--------------------+\r\n| Function         | Arguments     | Type               |\r\n+==================+===============+====================+\r\n| on_before_send   | callback      | Function           |\r\n+------------------+---------------+--------------------+\r\n\r\nYou can mutate the candidate payload by passing in a function that accepts one parameter using this function. This allows you to completely customize what data is sent, immediately before it happens.\r\n\r\n+------------------+---------------+--------------------+\r\n| Function         | Arguments     | Type               |\r\n+==================+===============+====================+\r\n| on_grouping_key  | callback      | Function           |\r\n+------------------+---------------+--------------------+\r\n\r\nPass a callback function to this method to configure custom grouping logic. The callback should take one parameter, an instance of RaygunMessage, and return a string between 1 and 100 characters in length (see 'Custom Grouping Logic' below for more details).\r\n\r\n+----------------+---------------+--------------------+\r\n| Function       | Arguments     | Type               |\r\n+================+===============+====================+\r\n| set_proxy      | host          | String             |\r\n+                +---------------+--------------------+\r\n|                | port          | Integer            |\r\n+----------------+---------------+--------------------+\r\n\r\nCall this function if your code is behind a proxy and want Raygun4py to make the HTTP request to the Raygun endpoint through it.\r\n\r\n+----------------+---------------+--------------------+\r\n| Function       | Arguments     | Type               |\r\n+================+===============+====================+\r\n| set_version    | version       | String             |\r\n+----------------+---------------+--------------------+\r\n\r\nCall this to attach a SemVer version to each message that is sent. This will be visible on the dashboard and can be used to filter exceptions to a particular version, deployment tracking etc.\r\n\r\n+----------------+---------------+--------------------+\r\n| Function       | Arguments     | Type               |\r\n+================+===============+====================+\r\n| set_user       | user_info     | Dict               |\r\n+----------------+---------------+--------------------+\r\n\r\nCustomer data can be passed in which will be displayed in the Raygun web app. The dict you pass in should look this this:\r\n\r\n.. code:: python\r\n\r\n  client.set_user({\r\n      'firstName': 'Foo',\r\n      'fullName': 'Foo Bar',\r\n      'email': 'foo@bar.com',\r\n      'isAnonymous': False,\r\n      'identifier': 'foo@bar.com'\r\n    })\r\n\r\n`identifier` should be whatever unique key you use to identify customers, for instance an email address. This will be used to create the count of affected customers. If you wish to anonymize it, you can generate and store a UUID or hash one or more of their unique login data fields, if available.\r\n\r\nCustom grouping logic\r\n---------------------\r\n\r\nYou can create custom exception grouping logic that overrides the automatic Raygun grouping by passing in a function that accepts one parameter using this function. The callback's one parameter is an instance of RaygunMessage (python[2/3]/raygunmsgs.py), and the callback should return a string.\r\n\r\nThe RaygunMessage instance contains all the error and state data that is about to be sent to the Raygun API. In your callback you can inspect this RaygunMessage, hash together the fields you want to group by, then return a string which is the grouping key.\r\n\r\nThis string needs to be between 1 and 100 characters long. If the callback is not set or the string isn't valid, the default automatic grouping will be used.\r\n\r\nBy example:\r\n\r\n.. code:: python\r\n\r\n    class MyClass(object):\r\n\r\n        def my_callback(self, raygun_message):\r\n            return raygun_message.get_error().message[:100] # Use naive message-based grouping only\r\n\r\n        def create_raygun_and_bind_callback(self):\r\n            sender = raygunprovider.RaygunSender('api_key')\r\n            sender.on_grouping_key(self.my_callback)\r\n\r\nThe RaygunSender above will use the my_callback to execute custom grouping logic when an exception is raised. The above logic will use the exception message only - you'll want to use a more sophisticated approach, usually involving sanitizing or ignoring data.\r\n\r\nChained exceptions\r\n------------------\r\n\r\nFor Python 3, chained exceptions are supported and automatically sent along with their traceback.\r\n\r\nThis occurs when an exception is raised while handling another exception - see tests_functional.py for an example.\r\n\r\nChangelog\r\n=========\r\n\r\n`View the release history here <CHANGELOG.md>`_\r\n",
    "bugtrack_url": null,
    "license": "LICENSE",
    "summary": "Official Raygun provider for Python 2.7 and Python 3+",
    "version": "5.0.0",
    "project_urls": {
        "Homepage": "https://raygun.com"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "91bac774248af4729debc3f43f9b7e865c1dc8ee9af30aa874b4d25accf65458",
                "md5": "b9d02310530b1834836ed9ff9b7c9600",
                "sha256": "edc156703e95d5035d7c7ea40e86f8122a93db80ee57ee277c493f1fdf2de42f"
            },
            "downloads": -1,
            "filename": "raygun4py-5.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b9d02310530b1834836ed9ff9b7c9600",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15151685,
            "upload_time": "2024-02-28T00:20:24",
            "upload_time_iso_8601": "2024-02-28T00:20:24.267469Z",
            "url": "https://files.pythonhosted.org/packages/91/ba/c774248af4729debc3f43f9b7e865c1dc8ee9af30aa874b4d25accf65458/raygun4py-5.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-28 00:20:24",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "raygun4py"
}
        
Elapsed time: 0.22369s