apitally-serverless 0.2.1__tar.gz → 0.2.1.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/.github/workflows/publish.yaml +3 -3
- apitally_serverless-0.2.1.dev0/.github/workflows/summary.yaml +16 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/.github/workflows/tests.yaml +16 -27
- apitally_serverless-0.2.1.dev0/.pre-commit-config.yaml +19 -0
- apitally_serverless-0.2.1.dev0/.tool-versions +1 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/Makefile +1 -2
- apitally_serverless-0.2.1.dev0/PKG-INFO +129 -0
- apitally_serverless-0.2.1.dev0/README.md +90 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/apitally_serverless/starlette.py +10 -2
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/pyproject.toml +8 -6
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/tests/test_common_masking.py +12 -16
- apitally_serverless-0.2.1.dev0/uv.lock +812 -0
- apitally_serverless-0.2.1/.editorconfig +0 -22
- apitally_serverless-0.2.1/.tool-versions +0 -1
- apitally_serverless-0.2.1/PKG-INFO +0 -180
- apitally_serverless-0.2.1/README.md +0 -141
- apitally_serverless-0.2.1/uv.lock +0 -657
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/.gitignore +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/LICENSE +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/apitally_serverless/__init__.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/apitally_serverless/common/__init__.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/apitally_serverless/common/config.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/apitally_serverless/common/consumers.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/apitally_serverless/common/exceptions.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/apitally_serverless/common/headers.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/apitally_serverless/common/masking.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/apitally_serverless/common/output.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/apitally_serverless/fastapi.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/apitally_serverless/py.typed +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/renovate.json +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/tests/__init__.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/tests/conftest.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/tests/test_common_consumers.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/tests/test_common_exceptions.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/tests/test_common_headers.py +0 -0
- {apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/tests/test_fastapi.py +0 -0
|
@@ -10,13 +10,13 @@ jobs:
|
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
11
|
environment: release
|
|
12
12
|
steps:
|
|
13
|
-
- uses: actions/checkout@
|
|
13
|
+
- uses: actions/checkout@v6
|
|
14
14
|
with:
|
|
15
15
|
fetch-depth: 0
|
|
16
16
|
- name: Install uv
|
|
17
|
-
uses: astral-sh/setup-uv@
|
|
17
|
+
uses: astral-sh/setup-uv@v7
|
|
18
18
|
with:
|
|
19
|
-
version: "0.
|
|
19
|
+
version: "0.9.21"
|
|
20
20
|
enable-cache: true
|
|
21
21
|
- name: Build package
|
|
22
22
|
run: uv build
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: Summary
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches-ignore:
|
|
5
|
+
- main
|
|
6
|
+
jobs:
|
|
7
|
+
wait-for-triggered-checks:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
permissions:
|
|
10
|
+
checks: read
|
|
11
|
+
steps:
|
|
12
|
+
- name: Wait for all triggered status checks
|
|
13
|
+
uses: poseidon/wait-for-status-checks@v0.6.0
|
|
14
|
+
with:
|
|
15
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
16
|
+
ignore_pattern: ^codecov/.+
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
name: Tests
|
|
2
2
|
on:
|
|
3
3
|
push:
|
|
4
|
-
branches:
|
|
5
|
-
- main
|
|
6
|
-
paths-ignore:
|
|
7
|
-
- .gitignore
|
|
8
|
-
- LICENSE
|
|
9
|
-
- README.md
|
|
10
|
-
pull_request:
|
|
11
4
|
paths-ignore:
|
|
12
5
|
- .gitignore
|
|
13
6
|
- LICENSE
|
|
@@ -17,14 +10,23 @@ concurrency:
|
|
|
17
10
|
cancel-in-progress: true
|
|
18
11
|
|
|
19
12
|
jobs:
|
|
13
|
+
check-pre-commit:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v6
|
|
17
|
+
- uses: actions/setup-python@v6
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.14"
|
|
20
|
+
- uses: pre-commit/action@v3.0.1
|
|
21
|
+
|
|
20
22
|
test-coverage:
|
|
21
23
|
runs-on: ubuntu-latest
|
|
22
24
|
steps:
|
|
23
|
-
- uses: actions/checkout@
|
|
25
|
+
- uses: actions/checkout@v6
|
|
24
26
|
- name: Install uv
|
|
25
|
-
uses: astral-sh/setup-uv@
|
|
27
|
+
uses: astral-sh/setup-uv@v7
|
|
26
28
|
with:
|
|
27
|
-
version: "0.
|
|
29
|
+
version: "0.9.21"
|
|
28
30
|
enable-cache: true
|
|
29
31
|
- name: Install Python
|
|
30
32
|
run: uv python install 3.14
|
|
@@ -37,7 +39,7 @@ jobs:
|
|
|
37
39
|
- name: Run tests and create coverage report
|
|
38
40
|
run: uv run make test-coverage
|
|
39
41
|
- name: Upload coverage report to Codecov
|
|
40
|
-
uses: codecov/codecov-action@
|
|
42
|
+
uses: codecov/codecov-action@v5
|
|
41
43
|
with:
|
|
42
44
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
43
45
|
|
|
@@ -51,11 +53,11 @@ jobs:
|
|
|
51
53
|
- fastapi starlette
|
|
52
54
|
- fastapi==0.116.1 starlette
|
|
53
55
|
steps:
|
|
54
|
-
- uses: actions/checkout@
|
|
56
|
+
- uses: actions/checkout@v6
|
|
55
57
|
- name: Install uv
|
|
56
|
-
uses: astral-sh/setup-uv@
|
|
58
|
+
uses: astral-sh/setup-uv@v7
|
|
57
59
|
with:
|
|
58
|
-
version: "0.
|
|
60
|
+
version: "0.9.21"
|
|
59
61
|
enable-cache: true
|
|
60
62
|
- name: Install Python
|
|
61
63
|
run: uv python install ${{ matrix.python }}
|
|
@@ -67,16 +69,3 @@ jobs:
|
|
|
67
69
|
run: uv pip install ${{ matrix.deps }} ./dist/apitally_serverless-*.whl
|
|
68
70
|
- name: Run tests
|
|
69
71
|
run: uv run make test
|
|
70
|
-
|
|
71
|
-
ci-gate:
|
|
72
|
-
needs:
|
|
73
|
-
- test-coverage
|
|
74
|
-
- test-matrix
|
|
75
|
-
if: always()
|
|
76
|
-
runs-on: ubuntu-latest
|
|
77
|
-
steps:
|
|
78
|
-
- name: All checks passed or skipped
|
|
79
|
-
run: |
|
|
80
|
-
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
|
|
81
|
-
exit 1
|
|
82
|
-
fi
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
default_language_version:
|
|
2
|
+
python: "3.14"
|
|
3
|
+
repos:
|
|
4
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
+
rev: v6.0.0
|
|
6
|
+
hooks:
|
|
7
|
+
- id: end-of-file-fixer
|
|
8
|
+
- id: trailing-whitespace
|
|
9
|
+
- id: mixed-line-ending
|
|
10
|
+
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
|
11
|
+
rev: v0.14.10
|
|
12
|
+
hooks:
|
|
13
|
+
- id: ruff
|
|
14
|
+
args: ["--fix", "--exit-non-zero-on-fix"]
|
|
15
|
+
- id: ruff-format
|
|
16
|
+
- repo: https://github.com/astral-sh/uv-pre-commit
|
|
17
|
+
rev: 0.9.21
|
|
18
|
+
hooks:
|
|
19
|
+
- id: uv-lock
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uv 0.9.21
|
|
@@ -7,8 +7,7 @@ format:
|
|
|
7
7
|
check:
|
|
8
8
|
uv run ruff check apitally_serverless tests
|
|
9
9
|
uv run ruff format --diff apitally_serverless tests
|
|
10
|
-
uv run
|
|
11
|
-
uv lock --locked
|
|
10
|
+
uv run mypy --install-types --non-interactive apitally_serverless tests
|
|
12
11
|
|
|
13
12
|
test:
|
|
14
13
|
uv run pytest -v --tb=short
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: apitally-serverless
|
|
3
|
+
Version: 0.2.1.dev0
|
|
4
|
+
Summary: Simple API monitoring & analytics for REST APIs running on serverless platforms (e.g. Cloudflare Workers).
|
|
5
|
+
Project-URL: Homepage, https://apitally.io
|
|
6
|
+
Project-URL: Documentation, https://docs.apitally.io
|
|
7
|
+
Project-URL: Repository, https://github.com/apitally/apitally-py-serverless
|
|
8
|
+
Author-email: Apitally <hello@apitally.io>
|
|
9
|
+
License: MIT License
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Environment :: Web Environment
|
|
13
|
+
Classifier: Framework :: FastAPI
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Information Technology
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
25
|
+
Classifier: Topic :: Internet
|
|
26
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
27
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware
|
|
28
|
+
Classifier: Topic :: Software Development
|
|
29
|
+
Classifier: Topic :: System :: Monitoring
|
|
30
|
+
Classifier: Typing :: Typed
|
|
31
|
+
Requires-Python: <4.0,>=3.10
|
|
32
|
+
Requires-Dist: typing-extensions>=4.0.0; python_version < '3.11'
|
|
33
|
+
Provides-Extra: fastapi
|
|
34
|
+
Requires-Dist: fastapi>=0.116.1; extra == 'fastapi'
|
|
35
|
+
Requires-Dist: starlette<1.0.0,>=0.47.2; extra == 'fastapi'
|
|
36
|
+
Provides-Extra: starlette
|
|
37
|
+
Requires-Dist: starlette<1.0.0,>=0.47.2; extra == 'starlette'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
<p align="center">
|
|
41
|
+
<a href="https://apitally.io" target="_blank">
|
|
42
|
+
<picture>
|
|
43
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://assets.apitally.io/logos/logo-horizontal-new-dark.png">
|
|
44
|
+
<source media="(prefers-color-scheme: light)" srcset="https://assets.apitally.io/logos/logo-horizontal-new-light.png">
|
|
45
|
+
<img alt="Apitally logo" src="https://assets.apitally.io/logos/logo-horizontal-new-light.png" width="220">
|
|
46
|
+
</picture>
|
|
47
|
+
</a>
|
|
48
|
+
</p>
|
|
49
|
+
<p align="center"><b>API monitoring & analytics made simple</b></p>
|
|
50
|
+
<p align="center" style="color: #ccc;">Real-time metrics, request logs, and alerts for your APIs — with just a few lines of code.</p>
|
|
51
|
+
<br>
|
|
52
|
+
<img alt="Apitally screenshots" src="https://assets.apitally.io/screenshots/overview.png">
|
|
53
|
+
<br>
|
|
54
|
+
|
|
55
|
+
# Apitally SDK for serverless Python runtimes
|
|
56
|
+
|
|
57
|
+
[](https://github.com/apitally/apitally-py-serverless/actions)
|
|
58
|
+
[](https://codecov.io/gh/apitally/apitally-py-serverless)
|
|
59
|
+
[](https://pypi.org/project/apitally-serverless/)
|
|
60
|
+
|
|
61
|
+
This SDK for Apitally currently supports the following web frameworks:
|
|
62
|
+
|
|
63
|
+
- [FastAPI](https://docs.apitally.io/setup-guides/fastapi-serverless)
|
|
64
|
+
|
|
65
|
+
The following serverless platforms are supported:
|
|
66
|
+
|
|
67
|
+
- [Cloudflare Workers](https://docs.apitally.io/setup-guides/cloudflare-workers) (via Logpush)
|
|
68
|
+
|
|
69
|
+
Learn more about Apitally on our 🌎 [website](https://apitally.io) or check out
|
|
70
|
+
the 📚 [documentation](https://docs.apitally.io).
|
|
71
|
+
|
|
72
|
+
## Key features
|
|
73
|
+
|
|
74
|
+
### API analytics
|
|
75
|
+
|
|
76
|
+
Track traffic, error and performance metrics for your API, each endpoint and individual API consumers, allowing you to make informed, data-driven engineering and product decisions.
|
|
77
|
+
|
|
78
|
+
### Error tracking
|
|
79
|
+
|
|
80
|
+
Understand which validation rules in your endpoints cause client errors. Capture error details and stack traces for 500 error responses, and have them linked to Sentry issues automatically.
|
|
81
|
+
|
|
82
|
+
### Request logging
|
|
83
|
+
|
|
84
|
+
Drill down from insights to individual requests or use powerful filtering to understand how consumers have interacted with your API. Configure exactly what is included in the logs to meet your requirements.
|
|
85
|
+
|
|
86
|
+
### API monitoring & alerting
|
|
87
|
+
|
|
88
|
+
Get notified immediately if something isn't right using custom alerts, synthetic uptime checks and heartbeat monitoring. Notifications can be delivered via email, Slack or Microsoft Teams.
|
|
89
|
+
|
|
90
|
+
## Installation
|
|
91
|
+
|
|
92
|
+
Use `uv` to add this SDK to your project's dependencies:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
uv add apitally-serverless
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Usage
|
|
99
|
+
|
|
100
|
+
Our comprehensive [setup guides](https://docs.apitally.io/setup-guides) include
|
|
101
|
+
all the details you need to get started.
|
|
102
|
+
|
|
103
|
+
### FastAPI
|
|
104
|
+
|
|
105
|
+
This is an example of how to add the Apitally middleware to a FastAPI
|
|
106
|
+
application running on a supported serverless platform. For further instructions, see our
|
|
107
|
+
[setup guide for FastAPI](https://docs.apitally.io/frameworks/fastapi-serverless).
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from fastapi import FastAPI
|
|
111
|
+
from apitally_serverless.fastapi import ApitallyMiddleware
|
|
112
|
+
|
|
113
|
+
app = FastAPI()
|
|
114
|
+
app.add_middleware(
|
|
115
|
+
ApitallyMiddleware,
|
|
116
|
+
log_request_headers=True,
|
|
117
|
+
log_request_body=True,
|
|
118
|
+
log_response_body=True,
|
|
119
|
+
)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Getting help
|
|
123
|
+
|
|
124
|
+
If you need help please [create a new discussion](https://github.com/orgs/apitally/discussions/categories/q-a) on GitHub
|
|
125
|
+
or [join our Slack workspace](https://join.slack.com/t/apitally-community/shared_invite/zt-2b3xxqhdu-9RMq2HyZbR79wtzNLoGHrg).
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
This library is licensed under the terms of the MIT license.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://apitally.io" target="_blank">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://assets.apitally.io/logos/logo-horizontal-new-dark.png">
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset="https://assets.apitally.io/logos/logo-horizontal-new-light.png">
|
|
6
|
+
<img alt="Apitally logo" src="https://assets.apitally.io/logos/logo-horizontal-new-light.png" width="220">
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
</p>
|
|
10
|
+
<p align="center"><b>API monitoring & analytics made simple</b></p>
|
|
11
|
+
<p align="center" style="color: #ccc;">Real-time metrics, request logs, and alerts for your APIs — with just a few lines of code.</p>
|
|
12
|
+
<br>
|
|
13
|
+
<img alt="Apitally screenshots" src="https://assets.apitally.io/screenshots/overview.png">
|
|
14
|
+
<br>
|
|
15
|
+
|
|
16
|
+
# Apitally SDK for serverless Python runtimes
|
|
17
|
+
|
|
18
|
+
[](https://github.com/apitally/apitally-py-serverless/actions)
|
|
19
|
+
[](https://codecov.io/gh/apitally/apitally-py-serverless)
|
|
20
|
+
[](https://pypi.org/project/apitally-serverless/)
|
|
21
|
+
|
|
22
|
+
This SDK for Apitally currently supports the following web frameworks:
|
|
23
|
+
|
|
24
|
+
- [FastAPI](https://docs.apitally.io/setup-guides/fastapi-serverless)
|
|
25
|
+
|
|
26
|
+
The following serverless platforms are supported:
|
|
27
|
+
|
|
28
|
+
- [Cloudflare Workers](https://docs.apitally.io/setup-guides/cloudflare-workers) (via Logpush)
|
|
29
|
+
|
|
30
|
+
Learn more about Apitally on our 🌎 [website](https://apitally.io) or check out
|
|
31
|
+
the 📚 [documentation](https://docs.apitally.io).
|
|
32
|
+
|
|
33
|
+
## Key features
|
|
34
|
+
|
|
35
|
+
### API analytics
|
|
36
|
+
|
|
37
|
+
Track traffic, error and performance metrics for your API, each endpoint and individual API consumers, allowing you to make informed, data-driven engineering and product decisions.
|
|
38
|
+
|
|
39
|
+
### Error tracking
|
|
40
|
+
|
|
41
|
+
Understand which validation rules in your endpoints cause client errors. Capture error details and stack traces for 500 error responses, and have them linked to Sentry issues automatically.
|
|
42
|
+
|
|
43
|
+
### Request logging
|
|
44
|
+
|
|
45
|
+
Drill down from insights to individual requests or use powerful filtering to understand how consumers have interacted with your API. Configure exactly what is included in the logs to meet your requirements.
|
|
46
|
+
|
|
47
|
+
### API monitoring & alerting
|
|
48
|
+
|
|
49
|
+
Get notified immediately if something isn't right using custom alerts, synthetic uptime checks and heartbeat monitoring. Notifications can be delivered via email, Slack or Microsoft Teams.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
Use `uv` to add this SDK to your project's dependencies:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
uv add apitally-serverless
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
Our comprehensive [setup guides](https://docs.apitally.io/setup-guides) include
|
|
62
|
+
all the details you need to get started.
|
|
63
|
+
|
|
64
|
+
### FastAPI
|
|
65
|
+
|
|
66
|
+
This is an example of how to add the Apitally middleware to a FastAPI
|
|
67
|
+
application running on a supported serverless platform. For further instructions, see our
|
|
68
|
+
[setup guide for FastAPI](https://docs.apitally.io/frameworks/fastapi-serverless).
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from fastapi import FastAPI
|
|
72
|
+
from apitally_serverless.fastapi import ApitallyMiddleware
|
|
73
|
+
|
|
74
|
+
app = FastAPI()
|
|
75
|
+
app.add_middleware(
|
|
76
|
+
ApitallyMiddleware,
|
|
77
|
+
log_request_headers=True,
|
|
78
|
+
log_request_body=True,
|
|
79
|
+
log_response_body=True,
|
|
80
|
+
)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Getting help
|
|
84
|
+
|
|
85
|
+
If you need help please [create a new discussion](https://github.com/orgs/apitally/discussions/categories/q-a) on GitHub
|
|
86
|
+
or [join our Slack workspace](https://join.slack.com/t/apitally-community/shared_invite/zt-2b3xxqhdu-9RMq2HyZbR79wtzNLoGHrg).
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
This library is licensed under the terms of the MIT license.
|
{apitally_serverless-0.2.1 → apitally_serverless-0.2.1.dev0}/apitally_serverless/starlette.py
RENAMED
|
@@ -77,10 +77,14 @@ class ApitallyMiddleware:
|
|
|
77
77
|
response_content_type: str | None = None
|
|
78
78
|
exception: BaseException | None = None
|
|
79
79
|
|
|
80
|
+
print("before")
|
|
81
|
+
|
|
80
82
|
async def receive_wrapper() -> Message:
|
|
81
83
|
nonlocal request_body, request_body_too_large
|
|
82
84
|
|
|
83
85
|
message = await receive()
|
|
86
|
+
print("receive", message)
|
|
87
|
+
|
|
84
88
|
if message["type"] == "http.request":
|
|
85
89
|
if (
|
|
86
90
|
self.config.log_request_body
|
|
@@ -97,6 +101,8 @@ class ApitallyMiddleware:
|
|
|
97
101
|
nonlocal response_time, response_status, response_headers, response_body
|
|
98
102
|
nonlocal response_body_too_large, response_chunked, response_content_type, response_size
|
|
99
103
|
|
|
104
|
+
print("send", message)
|
|
105
|
+
|
|
100
106
|
if message["type"] == "http.response.start":
|
|
101
107
|
response_time = time.perf_counter() - start_time
|
|
102
108
|
response_status = message["status"]
|
|
@@ -131,8 +137,10 @@ class ApitallyMiddleware:
|
|
|
131
137
|
await self.app(scope, receive_wrapper, send_wrapper)
|
|
132
138
|
except BaseException as e:
|
|
133
139
|
exception = e
|
|
140
|
+
print("exception", exception)
|
|
134
141
|
raise
|
|
135
142
|
finally:
|
|
143
|
+
print("finally", exception)
|
|
136
144
|
if response_time is None:
|
|
137
145
|
response_time = time.perf_counter() - start_time
|
|
138
146
|
|
|
@@ -211,7 +219,7 @@ def _get_path(request: Request, routes: list[BaseRoute] | None = None) -> str |
|
|
|
211
219
|
routes = request.app.routes
|
|
212
220
|
for route in routes:
|
|
213
221
|
if hasattr(route, "routes"):
|
|
214
|
-
path = _get_path(request, routes=
|
|
222
|
+
path = _get_path(request, routes=route.routes)
|
|
215
223
|
if path is not None:
|
|
216
224
|
return path
|
|
217
225
|
elif hasattr(route, "path"):
|
|
@@ -232,7 +240,7 @@ def _get_routes(app: ASGIApp | Router) -> list[BaseRoute]:
|
|
|
232
240
|
if isinstance(app, Router):
|
|
233
241
|
return app.routes
|
|
234
242
|
elif hasattr(app, "app"):
|
|
235
|
-
return _get_routes(
|
|
243
|
+
return _get_routes(app.app)
|
|
236
244
|
return [] # pragma: no cover
|
|
237
245
|
|
|
238
246
|
|
|
@@ -40,14 +40,15 @@ Documentation = "https://docs.apitally.io"
|
|
|
40
40
|
Repository = "https://github.com/apitally/apitally-py-serverless"
|
|
41
41
|
|
|
42
42
|
[dependency-groups]
|
|
43
|
-
dev = ["
|
|
43
|
+
dev = ["mypy~=1.19.0", "ruff~=0.14.0"]
|
|
44
44
|
test = [
|
|
45
45
|
"httpx~=0.28.0",
|
|
46
|
-
"pytest~=9.
|
|
47
|
-
"pytest-asyncio~=1.
|
|
48
|
-
"pytest-cov~=7.
|
|
46
|
+
"pytest~=9.0.0",
|
|
47
|
+
"pytest-asyncio~=1.3.0",
|
|
48
|
+
"pytest-cov~=7.0.0",
|
|
49
49
|
"pytest-mock~=3.15.0",
|
|
50
50
|
]
|
|
51
|
+
types = ["types-pexpect", "types-pygments", "types-pyyaml"]
|
|
51
52
|
|
|
52
53
|
[build-system]
|
|
53
54
|
requires = ["hatchling", "hatch-vcs"]
|
|
@@ -70,8 +71,9 @@ select = ["E", "F", "W", "I"]
|
|
|
70
71
|
[tool.ruff.lint.isort]
|
|
71
72
|
lines-after-imports = 2
|
|
72
73
|
|
|
73
|
-
[tool.
|
|
74
|
-
|
|
74
|
+
[tool.mypy]
|
|
75
|
+
python_version = "3.13"
|
|
76
|
+
check_untyped_defs = true
|
|
75
77
|
|
|
76
78
|
[tool.pytest.ini_options]
|
|
77
79
|
asyncio_mode = "auto"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from typing import Any
|
|
2
|
+
from typing import Any
|
|
3
3
|
|
|
4
4
|
from apitally_serverless.common.config import ApitallyConfig
|
|
5
5
|
from apitally_serverless.common.masking import MASKED, DataMasker
|
|
@@ -7,7 +7,7 @@ from apitally_serverless.common.output import OutputDataDict
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def create_config(**kwargs: Any) -> ApitallyConfig:
|
|
10
|
-
defaults
|
|
10
|
+
defaults = {
|
|
11
11
|
"enabled": True,
|
|
12
12
|
"log_request_headers": True,
|
|
13
13
|
"log_request_body": True,
|
|
@@ -39,20 +39,16 @@ def create_output_data(
|
|
|
39
39
|
}
|
|
40
40
|
if response:
|
|
41
41
|
response_dict.update(response)
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"exception": None,
|
|
53
|
-
"exclude": False,
|
|
54
|
-
},
|
|
55
|
-
)
|
|
42
|
+
return {
|
|
43
|
+
"instance_uuid": "00000000-0000-0000-0000-000000000000",
|
|
44
|
+
"request_uuid": "00000000-0000-0000-0000-000000000000",
|
|
45
|
+
"request": request_dict, # type: ignore[typeddict-item]
|
|
46
|
+
"response": response_dict, # type: ignore[typeddict-item]
|
|
47
|
+
"startup": None,
|
|
48
|
+
"consumer": None,
|
|
49
|
+
"validation_errors": None,
|
|
50
|
+
"exclude": False,
|
|
51
|
+
}
|
|
56
52
|
|
|
57
53
|
|
|
58
54
|
def test_exclude_paths():
|