Skip to main content

Dr. Ashtetepe (drhttp) agent for python application servers

Project description

This is the official python client for Dr. Ashtetepe service.

DrHTTP let's you record two types of requests :

  • Inbound : requests that are performed by clients of your server (eg. API calls from a mobile app)
  • Outbound (optional) : requests that are performed by your server (eg. API call to third parties)

Note: You need to configure inbound request recording to have outbound request recording working.

Installation

Install package with pip (or any compatible package manager) :

pip install drhttp

Usage for Django

An integraion example is provided here

Request recording

Inbound request recording

You will need an api_key that can be generated here.

This recording is done via a wsgi middleware. You can configure it in wsgi.py:

application = ... # get your application from existing code

import drhttp
application = drhttp.WSGIMiddleware(app=application,
                                    dsn="https://<api_key>@api.drhttp.com",
                                    identify=lambda headers: headers.get('User'))

identify function in drhttp.WSGIMiddleware() is optional. It allows the identification of the user issuing the inbound request. You'll be able to filter requests based on this field in the web interface.

Note: Device identification is not available yet in the python library

Outbound request recording

Note: Outbound request recording is not available yet in the python library

Usage for Flask

An integraion example is provided here

Request recording

Inbound request recording

You will need an api_key that can be generated here.

This recording is done via a wsgi middleware. You may need to change some code in your flask app file. The goal is to encapsulate the wsgi app in the drhttp middleware. As drhttp.WSGIMiddleware() returns a wsgi application (not a full flask application) it can't be run by flask cli, you need a wsgi application server like werkzeug/gunicorn/uwsgi.

...
app = Flask(__name__)
...

if __name__ == '__main__':
    import drhttp
    from werkzeug.serving import run_simple
    app = drhttp.WSGIMiddleware(app=app,
                                dsn="https://<api_key>@api.drhttp.com",
                                identify=lambda headers: headers.get('User'))

    run_simple('0.0.0.0', 80, app)

identify function in drhttp.WSGIMiddleware() is optional. It allows the identification of the user issuing the inbound request. You'll be able to filter requests based on this field in the web interface.

Note: Device identification is not available yet in the python library

Outbound request recording

Note: Outbound request recording is not available yet in the python library

Troubleshooting

Please report any issue you encounter concerning documentation or implementation. This is very much appreciated.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drhttp-0.1.3.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

drhttp-0.1.3-py3-none-any.whl (18.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page