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

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

    pip install drhttp
    
  2. You will need a dsn (Data source name) which can be found in your project.

Usage for Django

An integraion example is provided here

Inbound request recording

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="<insert_dsn_here")

User identification

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. drhttp will identify your user if you set the x-drhttp-user response header with the user's id as value. Fortunately, we provide you a django middleware that does it automaticaly.

MIDDLEWARE = [
    ...
    'drhttp.DjangoUserMiddleware',
]

Device identification

Device identification works as user identification, only the header name changes (x-drhttp-device). No django middleware is provided though, it's up to you to set this header depending your device identification strategy.

Outbound request recording

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

Usage for Flask

An integraion example is provided here

Inbound request recording

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="<insert_dsn_here>")
    run_simple('0.0.0.0', 80, app)

User identification

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. drhttp will identify your user if you set the x-drhttp-user response header with the user's id as value.

Here is an example if you use Flask-HTTPAuth :

from drhttp import DRHTTP_HEADER_USER
@app.after_request
def apply_caching(response):
    response.headers[DRHTTP_HEADER_USER] = auth.username()
    return response

Device identification

Device identification works as user identification, only the header name changes (x-drhttp-device). It's up to you to set this header depending your device identification strategy.

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.2.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drhttp-0.2.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file drhttp-0.2.0.tar.gz.

File metadata

  • Download URL: drhttp-0.2.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.9

File hashes

Hashes for drhttp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a3f3464931357768a978390a22751a5675f7d294593c3fe3eecdac8f17d9aea7
MD5 af35aa5ad7f9278cf69f52e691222d12
BLAKE2b-256 9f75529ab9b2db34e35c1d418da43bd90407625fcbb60a1c3a026a37966409e5

See more details on using hashes here.

File details

Details for the file drhttp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: drhttp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.9

File hashes

Hashes for drhttp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9dbb7d39d0b260c23f863a68a148fb5f6b3ee3c4ac4ebcb26a77154d047d76ff
MD5 a6038581a4cb9652a047c8ad6c16875e
BLAKE2b-256 b39d8d153b5c5d7064be346781e97fc3091ae93e061f175fe972adf88df9b2a7

See more details on using hashes here.

Supported by

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