Skip to main content

Module for timing http queries inside a python program.

Project description

HTTP Transaction Profile

Series of tools to profile HTTP interactions in Python scripts. It can be used for understanding impact of slow web API's on an application.

How It Works

The httptime.enable_logging function redirects the debug output of the http.client module (common module responsible for all HTTP communication in python) to the Python logging framework. The output is then saved to a file.

Tools are provided for parsing and visualizing the output.

Usage (Save Data)

Insert the following block of code at the beginning of your script. That's it.

import httptime
httptime.enable_logging()

The enable_logging function does the following:

  • Redirects http.client debug output into the logging module.
  • Save all debug output to a file. Note that currently all logging.DEBUG output is saved to this file, including from other modules.

The output file path can be specified via the outfile parameter to the enable_logging function. If not specified, then the output is saved to ~/.httptime/{prog}-{date}.txt, where {prog} is the name of script being executed and {date} is the current date/time in the format %Y-%m-%d %H:%M:%SZ%z.

Usage (View Data)

The data can be visualized using the Dash-based app app.py. The following command opens a server at localhost:5000. You can client on invidiual blocks in the graph to get more details.

python app.py path/to/example/outfile.txt

httptime example

TODO

  • Options to enable_logging to better steer saved data.
  • Module that saves data to a dataframe for custom analysis code.

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

httptime-0.2.0.tar.gz (17.6 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: httptime-0.2.0.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for httptime-0.2.0.tar.gz
Algorithm Hash digest
SHA256 db58a9b5d03efdfa82c4425a1e1b9ff531c9f6feb9738a2034d430476ffe38d0
MD5 2f818280e258f2c3551886d267b5ca39
BLAKE2b-256 3be5a7fd265562706e79c007fae47dd37a4c12a52d78c70825b66d6f310e861c

See more details on using hashes here.

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