Skip to content
This repository was archived by the owner on Sep 2, 2022. It is now read-only.

Commit 8e41a61

Browse files
authored
Merge pull request #3 from apilytics/readme-changes
README changes
2 parents c36696b + 9d239d2 commit 8e41a61

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
[![python versions](https://img.shields.io/pypi/pyversions/apilytics)](#what-python-versions-does-the-package-work-with)
99
[![license](https://img.shields.io/pypi/l/apilytics.svg)](https://github.com/apilytics/apilytics-python/blob/master/LICENSE)
1010

11+
Apilytics is a service that lets you analyze operational, performance and security metrics from your APIs without infrastructure-level logging.
12+
13+
<img src="https://www.apilytics.io/mock-ups/time-frame.gif" alt="Apilytics dashboard animation" width="600" height="300" />
14+
1115
## Installation
1216

1317
1. Sign up and get your API key from https://apilytics.io - we offer a completely free trial with no credit card required!
@@ -22,7 +26,7 @@ pip install apilytics
2226
You can leave the env variable unset in e.g. development and test environments,
2327
the middleware will be automatically disabled if the key is `None`.*
2428

25-
### Django:
29+
### Django
2630

2731
`settings.py`:
2832
```python
@@ -35,7 +39,7 @@ MIDDLEWARE = [
3539
]
3640
```
3741

38-
### FastAPI:
42+
### FastAPI
3943

4044
`main.py`:
4145

@@ -50,7 +54,7 @@ app = FastAPI()
5054
app.add_middleware(ApilyticsMiddleware, api_key=os.getenv("APILYTICS_API_KEY"))
5155
```
5256

53-
### Other Python Frameworks:
57+
### Other Python Frameworks
5458

5559
You can easily build your own middleware which measures the execution time and sends the metrics:
5660

@@ -62,14 +66,18 @@ from apilytics.core import ApilyticsSender
6266

6367

6468
def my_apilytics_middleware(request, get_response):
65-
with ApilyticsSender(
66-
api_key=os.getenv("APILYTICS_API_KEY"),
67-
path=request.path,
68-
method=request.method,
69-
) as sender:
70-
response = get_response(request)
71-
sender.set_response_info(status_code=response.status_code)
72-
return response
69+
api_key = os.getenv("APILYTICS_API_KEY")
70+
if not api_key:
71+
return get_response(request)
72+
73+
with ApilyticsSender(
74+
api_key=api_key,
75+
path=request.path,
76+
method=request.method,
77+
) as sender:
78+
response = get_response(request)
79+
sender.set_response_info(status_code=response.status_code)
80+
return response
7381
```
7482

7583
## Frequently Asked Questions

pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ classifiers = [
2020
"Environment :: Plugins",
2121
"Environment :: Web Environment",
2222
"Framework :: Django",
23-
"Framework :: Django :: 2.2",
24-
"Framework :: Django :: 3.2",
25-
"Framework :: Django :: 4.0",
2623
"Framework :: FastAPI",
2724
"Intended Audience :: Developers",
2825
"Intended Audience :: Information Technology",

0 commit comments

Comments
 (0)