Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andresmweber/request-metrics
The start of a library for testing out metrics for http requests. Will only have average response time for now.
https://github.com/andresmweber/request-metrics
Last synced: about 1 month ago
JSON representation
The start of a library for testing out metrics for http requests. Will only have average response time for now.
- Host: GitHub
- URL: https://github.com/andresmweber/request-metrics
- Owner: AndresMWeber
- License: mit
- Created: 2020-02-23T17:02:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T03:40:32.000Z (almost 2 years ago)
- Last Synced: 2023-03-03T09:49:32.172Z (over 1 year ago)
- Language: Python
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
request-metrics
The start of a library for testing out metrics for http requests. Will only have average response time for now.
## ๐ Table of Contents
- [About](#about)
- [Setup](#setup)
- [Usage](#usage)
- [Documentation](#documentation)
- [Testing](#testing)
- [Built Using](#built_using)
- [Authors](#authors)## ๐ About
The start of a library for testing out metrics for http requests. Will only have average response time for now.I added async capabilities as a flag, however the tests were reporting elapsed times of roughly 1.5x longer than normal, so there might be a bug.
`aiohttp` does not support returning elapsed time as well, so there could be other factors due to Python code.
## โ๏ธ Setup
#### Requirements:1. Must be using python3 and have python3 as an available shell command.
1. This install script uses `venv` as well.#### Installation:
(if you already have a virtual environment workflow, just activate your venv and run `python setup.py install`)`source bin/setup.sh` - Run this from the top directory: this creates the venv in the top directory and activates it after running `python3 setup.py install`
## ๐ก Usage
1. Make sure you have activated the `virtual environment` if you did the install steps but started a new terminal by running:``` bash
source bin/activate_venv.sh
```2. Designed as a CLI tool, you should navigate to the clone directory and run:
``` bash
python get_average_response_time.py
```3. It defaults to querying the PassNinja API, however you can input whatever API you want. You can also specify the REST verb via the -v, --verb flag, but it also defaults to POST. If you want to customize the POST request data, modify the `./payload.json` file as desired.
### Sample run command:
``` bash
python get_average_response_time.py -u 'https://api.passninja.com/lambda-2048/passes/'
```
### Sample Output:
``` bash
Running post request to https://api.passninja.com/lambda-2048/passes/ - 10 time(s):
Loading payload file: ./payload.json
Succesfully loaded payload file.| 200 | - 5.488187500013737
| 200 | - 5.700262800004566
| 200 | - 5.766223699989496
| 200 | - 5.923188999993727
| 200 | - 5.978442899999209
| 200 | - 6.658917599997949
| 200 | - 6.827372700005071
| 200 | - 7.669452500005718
| 200 | - 7.74673030001577
| 200 | - 7.802989500021795Average run time was 6.56s over 10 runs with 0 non-200 responses.
```
### Sample visual:
![image](https://user-images.githubusercontent.com/1587270/75119852-aabd5d80-5654-11ea-8bfe-893fe3284c48.png)## ๐ Documentation
Feel free to run the script with the --help command:
``` bash
โฐโ python get_average_response_time.py --help
Usage: get_average_response_time.py [OPTIONS]Options:
-r, --runs INTEGER Number of requests to run.
-u, --url TEXT API Endpoint to post to.
-d, --data TEXT JSON data (if using POST).
-v, --verb TEXT The type of request to perform
-a, --runasync TEXT Run the requests asynchronously or not.
--help Show this message and exit.
```Nothing yet.
## โ๏ธ Built Using
- [Python](https://python.org/) - Backend Code
- [CodeClimate](https://d341kum51qu34d.cloudfront.net/images/2019-04-redesign/code_climate_logo-a046042f.svg) - Code Health Metrics# โ๏ธ Authors
* [Andres Weber](https://github.com/AndresMWeber)