apitally-serverless 0.2.1.dev0__tar.gz → 0.2.2__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.2/.editorconfig +22 -0
- apitally_serverless-0.2.2/.github/workflows/pi-comment.yaml +59 -0
- apitally_serverless-0.2.2/.github/workflows/pi-fix-ci.yaml +73 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/.github/workflows/publish.yaml +3 -3
- apitally_serverless-0.2.2/.github/workflows/tests.yaml +121 -0
- apitally_serverless-0.2.2/.tool-versions +1 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/Makefile +2 -1
- apitally_serverless-0.2.2/PKG-INFO +180 -0
- apitally_serverless-0.2.2/README.md +141 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/apitally_serverless/starlette.py +3 -11
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/pyproject.toml +9 -11
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/tests/test_common_masking.py +16 -12
- apitally_serverless-0.2.2/uv.lock +912 -0
- apitally_serverless-0.2.1.dev0/.github/workflows/summary.yaml +0 -16
- apitally_serverless-0.2.1.dev0/.github/workflows/tests.yaml +0 -71
- apitally_serverless-0.2.1.dev0/.pre-commit-config.yaml +0 -19
- apitally_serverless-0.2.1.dev0/.tool-versions +0 -1
- apitally_serverless-0.2.1.dev0/PKG-INFO +0 -129
- apitally_serverless-0.2.1.dev0/README.md +0 -90
- apitally_serverless-0.2.1.dev0/uv.lock +0 -812
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/.gitignore +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/LICENSE +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/apitally_serverless/__init__.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/apitally_serverless/common/__init__.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/apitally_serverless/common/config.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/apitally_serverless/common/consumers.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/apitally_serverless/common/exceptions.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/apitally_serverless/common/headers.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/apitally_serverless/common/masking.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/apitally_serverless/common/output.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/apitally_serverless/fastapi.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/apitally_serverless/py.typed +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/renovate.json +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/tests/__init__.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/tests/conftest.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/tests/test_common_consumers.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/tests/test_common_exceptions.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/tests/test_common_headers.py +0 -0
- {apitally_serverless-0.2.1.dev0 → apitally_serverless-0.2.2}/tests/test_fastapi.py +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
end_of_line = lf
|
|
5
|
+
insert_final_newline = true
|
|
6
|
+
trim_trailing_whitespace = true
|
|
7
|
+
|
|
8
|
+
[*.py]
|
|
9
|
+
indent_style = space
|
|
10
|
+
indent_size = 4
|
|
11
|
+
max_line_length = 120
|
|
12
|
+
|
|
13
|
+
[*.toml]
|
|
14
|
+
indent_style = space
|
|
15
|
+
indent_size = 4
|
|
16
|
+
|
|
17
|
+
[*.{yaml,json}]
|
|
18
|
+
indent_style = space
|
|
19
|
+
indent_size = 2
|
|
20
|
+
|
|
21
|
+
[Makefile]
|
|
22
|
+
indent_style = tab
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: Pi Comment
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
issue_comment:
|
|
5
|
+
types: [created]
|
|
6
|
+
pull_request_review:
|
|
7
|
+
types: [submitted]
|
|
8
|
+
pull_request_review_comment:
|
|
9
|
+
types: [created]
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
actions: read
|
|
13
|
+
contents: read
|
|
14
|
+
issues: write
|
|
15
|
+
pull-requests: write
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
pi:
|
|
19
|
+
if: |
|
|
20
|
+
github.actor == 'itssimon' &&
|
|
21
|
+
github.triggering_actor == 'itssimon' &&
|
|
22
|
+
(startsWith(github.event.comment.body, '/pi ') || startsWith(github.event.review.body, '/pi ')) &&
|
|
23
|
+
(github.event_name == 'issue_comment' || github.event.pull_request.head.repo.full_name == github.repository)
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- name: Resolve checkout ref
|
|
27
|
+
id: context
|
|
28
|
+
env:
|
|
29
|
+
GH_TOKEN: ${{ github.token }}
|
|
30
|
+
EVENT_NAME: ${{ github.event_name }}
|
|
31
|
+
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
|
32
|
+
ISSUE_PULL_REQUEST_URL: ${{ github.event.issue.pull_request.url }}
|
|
33
|
+
REVIEW_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
34
|
+
run: |
|
|
35
|
+
if [[ "$EVENT_NAME" == "issue_comment" && -n "$ISSUE_PULL_REQUEST_URL" ]]; then
|
|
36
|
+
read -r CHECKOUT_REF HEAD_REPOSITORY <<< "$(gh api "repos/$GITHUB_REPOSITORY/pulls/$ISSUE_NUMBER" --jq '[.head.sha, .head.repo.full_name] | @tsv')"
|
|
37
|
+
if [[ "$HEAD_REPOSITORY" != "$GITHUB_REPOSITORY" ]]; then
|
|
38
|
+
echo "::error::Cannot run Pi on a fork pull request"
|
|
39
|
+
exit 1
|
|
40
|
+
fi
|
|
41
|
+
elif [[ "$EVENT_NAME" != "issue_comment" ]]; then
|
|
42
|
+
CHECKOUT_REF="$REVIEW_HEAD_SHA"
|
|
43
|
+
fi
|
|
44
|
+
echo "checkout_ref=${CHECKOUT_REF:-}" >> "$GITHUB_OUTPUT"
|
|
45
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
46
|
+
with:
|
|
47
|
+
ref: ${{ steps.context.outputs.checkout_ref }}
|
|
48
|
+
fetch-depth: 0
|
|
49
|
+
token: ${{ secrets.PI_GITHUB_TOKEN }}
|
|
50
|
+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
|
|
51
|
+
with:
|
|
52
|
+
node-version: "26"
|
|
53
|
+
- uses: shaftoe/pi-coding-agent-action@c9c89dcabbf612ab2a528acfad8785a8075e22f3 # v2.30.2
|
|
54
|
+
with:
|
|
55
|
+
github_token: ${{ github.token }}
|
|
56
|
+
provider: openrouter
|
|
57
|
+
model: anthropic/claude-sonnet-5.5
|
|
58
|
+
token: ${{ secrets.PI_OPENROUTER_API_KEY }}
|
|
59
|
+
thinking_level: high
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
name: Pi Fix CI
|
|
2
|
+
run-name: Pi Fix CI for run ${{ inputs.run_id }}
|
|
3
|
+
|
|
4
|
+
# Dispatched by the pi-fix-ci job in tests.yaml when CI fails on a Renovate PR
|
|
5
|
+
on:
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
run_id:
|
|
9
|
+
description: ID of the failed Tests workflow run
|
|
10
|
+
required: true
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
actions: read
|
|
14
|
+
contents: read
|
|
15
|
+
issues: write
|
|
16
|
+
pull-requests: write
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
fix-ci:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- name: Look up pull request
|
|
23
|
+
id: pr
|
|
24
|
+
env:
|
|
25
|
+
GH_TOKEN: ${{ github.token }}
|
|
26
|
+
GH_REPO: ${{ github.repository }}
|
|
27
|
+
RUN_ID: ${{ inputs.run_id }}
|
|
28
|
+
run: |
|
|
29
|
+
branch=$(gh run view "$RUN_ID" --json headBranch --jq .headBranch)
|
|
30
|
+
echo "branch=$branch" >> "$GITHUB_OUTPUT"
|
|
31
|
+
echo "number=$(gh pr view "$branch" --json number --jq .number)" >> "$GITHUB_OUTPUT"
|
|
32
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
33
|
+
with:
|
|
34
|
+
ref: ${{ steps.pr.outputs.branch }}
|
|
35
|
+
fetch-depth: 0
|
|
36
|
+
token: ${{ secrets.PI_GITHUB_TOKEN }}
|
|
37
|
+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
|
|
38
|
+
with:
|
|
39
|
+
node-version: "26"
|
|
40
|
+
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
|
|
41
|
+
with:
|
|
42
|
+
version: "0.13.7"
|
|
43
|
+
enable-cache: true
|
|
44
|
+
- name: Install Python
|
|
45
|
+
run: uv python install 3.14
|
|
46
|
+
- name: Install dependencies
|
|
47
|
+
run: uv sync --all-extras --frozen
|
|
48
|
+
# Logs are only available once the Tests run, which dispatched this workflow, has completed
|
|
49
|
+
- name: Capture failed CI logs
|
|
50
|
+
env:
|
|
51
|
+
GH_TOKEN: ${{ github.token }}
|
|
52
|
+
RUN_ID: ${{ inputs.run_id }}
|
|
53
|
+
run: |
|
|
54
|
+
gh run watch "$RUN_ID" > /dev/null
|
|
55
|
+
gh run view "$RUN_ID" --log-failed > "$RUNNER_TEMP/failed-ci.log"
|
|
56
|
+
- name: Investigate and fix CI failure
|
|
57
|
+
uses: shaftoe/pi-coding-agent-action@c9c89dcabbf612ab2a528acfad8785a8075e22f3 # v2.30.2
|
|
58
|
+
with:
|
|
59
|
+
github_token: ${{ github.token }}
|
|
60
|
+
provider: openrouter
|
|
61
|
+
model: anthropic/claude-sonnet-5.5
|
|
62
|
+
token: ${{ secrets.PI_OPENROUTER_API_KEY }}
|
|
63
|
+
thinking_level: high
|
|
64
|
+
update_comment: true
|
|
65
|
+
pr_number: ${{ steps.pr.outputs.number }}
|
|
66
|
+
prompt: |
|
|
67
|
+
Investigate failed CI run ${{ inputs.run_id }} for Renovate PR #${{ steps.pr.outputs.number }}. Inspect the PR diff and confirm the dependency update caused the failure. Read `${{ runner.temp }}/failed-ci.log`. Do not call `get_workflow_run_logs`.
|
|
68
|
+
|
|
69
|
+
Only make an obvious, minimal, mechanical change that preserves behavior, such as formatting, removing an obsolete suppression, correcting an import or annotation, or applying an unambiguous API signature change. Never change logic, test assertions, dependencies, lockfiles, configuration, generated files, schemas, migrations, workflows, or unrelated code.
|
|
70
|
+
|
|
71
|
+
Reproduce the failure and run the relevant failed CI command after editing. If it does not pass or cannot run reliably, restore your changes and do not push.
|
|
72
|
+
|
|
73
|
+
If the validated fix meets every condition, call update_pull_request once with commit message "Fix CI after dependency update". Otherwise, leave the working tree unchanged and concisely report the failed job, likely cause, reason automation was unsafe, and suggested manual action.
|
|
@@ -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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
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@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
|
|
18
18
|
with:
|
|
19
|
-
version: "0.
|
|
19
|
+
version: "0.13.7"
|
|
20
20
|
enable-cache: true
|
|
21
21
|
- name: Build package
|
|
22
22
|
run: uv build
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
concurrency:
|
|
9
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
10
|
+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
pull-requests: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
changes:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
outputs:
|
|
20
|
+
python: ${{ steps.filter.outputs.python }}
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
23
|
+
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
|
|
24
|
+
id: filter
|
|
25
|
+
with:
|
|
26
|
+
filters: |
|
|
27
|
+
python:
|
|
28
|
+
- ".github/workflows/tests.yaml"
|
|
29
|
+
- "Makefile"
|
|
30
|
+
- "apitally_serverless/**"
|
|
31
|
+
- "pyproject.toml"
|
|
32
|
+
- "tests/**"
|
|
33
|
+
- "uv.lock"
|
|
34
|
+
|
|
35
|
+
test-coverage:
|
|
36
|
+
needs: changes
|
|
37
|
+
if: needs.changes.outputs.python == 'true' || github.event_name == 'workflow_dispatch'
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
41
|
+
- name: Install uv
|
|
42
|
+
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
|
|
43
|
+
with:
|
|
44
|
+
version: "0.13.7"
|
|
45
|
+
enable-cache: true
|
|
46
|
+
- name: Install Python
|
|
47
|
+
run: uv python install 3.14
|
|
48
|
+
- name: Install dependencies
|
|
49
|
+
run: uv sync --all-extras --frozen
|
|
50
|
+
- name: Run checks
|
|
51
|
+
run: uv run make check
|
|
52
|
+
- name: Run tests and create coverage report
|
|
53
|
+
run: uv run make test-coverage
|
|
54
|
+
- name: Upload coverage report to Codecov
|
|
55
|
+
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7
|
|
56
|
+
with:
|
|
57
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
58
|
+
|
|
59
|
+
test-matrix:
|
|
60
|
+
needs: changes
|
|
61
|
+
if: needs.changes.outputs.python == 'true' || github.event_name == 'workflow_dispatch'
|
|
62
|
+
runs-on: ubuntu-latest
|
|
63
|
+
strategy:
|
|
64
|
+
fail-fast: false
|
|
65
|
+
matrix:
|
|
66
|
+
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
67
|
+
deps:
|
|
68
|
+
- fastapi starlette
|
|
69
|
+
- fastapi==0.116.1 starlette
|
|
70
|
+
steps:
|
|
71
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
72
|
+
- name: Install uv
|
|
73
|
+
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
|
|
74
|
+
with:
|
|
75
|
+
version: "0.13.7"
|
|
76
|
+
enable-cache: true
|
|
77
|
+
- name: Install Python
|
|
78
|
+
run: uv python install ${{ matrix.python }}
|
|
79
|
+
- name: Build Python package wheel
|
|
80
|
+
run: uv build --wheel
|
|
81
|
+
- name: Install test dependencies
|
|
82
|
+
run: uv sync --no-install-project --only-group test --frozen
|
|
83
|
+
- name: Install app dependencies
|
|
84
|
+
run: uv pip install ${{ matrix.deps }} ./dist/apitally_serverless-*.whl
|
|
85
|
+
- name: Run tests
|
|
86
|
+
run: uv run make test
|
|
87
|
+
|
|
88
|
+
ci-gate:
|
|
89
|
+
needs:
|
|
90
|
+
- changes
|
|
91
|
+
- test-coverage
|
|
92
|
+
- test-matrix
|
|
93
|
+
if: always()
|
|
94
|
+
runs-on: ubuntu-latest
|
|
95
|
+
steps:
|
|
96
|
+
- name: All checks passed or skipped
|
|
97
|
+
run: |
|
|
98
|
+
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
|
|
99
|
+
exit 1
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
pi-fix-ci:
|
|
103
|
+
needs: ci-gate
|
|
104
|
+
if: |
|
|
105
|
+
!cancelled() &&
|
|
106
|
+
github.event_name == 'pull_request' &&
|
|
107
|
+
needs.ci-gate.result == 'failure' &&
|
|
108
|
+
github.run_attempt == 1 &&
|
|
109
|
+
github.actor == 'renovate[bot]' &&
|
|
110
|
+
github.event.pull_request.user.login == 'renovate[bot]' &&
|
|
111
|
+
startsWith(github.event.pull_request.head.ref, 'renovate/') &&
|
|
112
|
+
github.event.pull_request.head.repo.full_name == github.repository
|
|
113
|
+
runs-on: ubuntu-latest
|
|
114
|
+
permissions:
|
|
115
|
+
actions: write
|
|
116
|
+
steps:
|
|
117
|
+
- name: Dispatch Pi Fix CI workflow
|
|
118
|
+
env:
|
|
119
|
+
GH_TOKEN: ${{ github.token }}
|
|
120
|
+
GH_REPO: ${{ github.repository }}
|
|
121
|
+
run: gh workflow run pi-fix-ci.yaml --ref main -f run_id="$GITHUB_RUN_ID"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uv 0.13.7
|
|
@@ -7,7 +7,8 @@ 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
|
|
10
|
+
uv run ty check apitally_serverless tests
|
|
11
|
+
uv lock --locked
|
|
11
12
|
|
|
12
13
|
test:
|
|
13
14
|
uv run pytest -v --tb=short
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: apitally-serverless
|
|
3
|
+
Version: 0.2.2
|
|
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<2.0.0,>=0.47.2; extra == 'fastapi'
|
|
36
|
+
Provides-Extra: starlette
|
|
37
|
+
Requires-Dist: starlette<2.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;">Metrics, logs, and alerts for your serverless APIs — with just a few lines of code.</p>
|
|
51
|
+
<br>
|
|
52
|
+
<p>
|
|
53
|
+
<picture>
|
|
54
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://assets.apitally.io/screenshots/overview-dark.png">
|
|
55
|
+
<source media="(prefers-color-scheme: light)" srcset="https://assets.apitally.io/screenshots/overview-light.png">
|
|
56
|
+
<img alt="Apitally dashboard" src="https://assets.apitally.io/screenshots/overview-light.png">
|
|
57
|
+
</picture>
|
|
58
|
+
</p>
|
|
59
|
+
<br>
|
|
60
|
+
|
|
61
|
+
# Apitally SDK for Cloudflare Python Workers
|
|
62
|
+
|
|
63
|
+
[](https://github.com/apitally/apitally-py-serverless/actions)
|
|
64
|
+
[](https://codecov.io/gh/apitally/apitally-py-serverless)
|
|
65
|
+
[](https://pypi.org/project/apitally-serverless/)
|
|
66
|
+
|
|
67
|
+
Apitally is a simple API monitoring and analytics tool that makes it easy to understand API usage, monitor performance, and troubleshoot issues.
|
|
68
|
+
Get started in minutes by just adding a few lines of code and a Logpush job.
|
|
69
|
+
|
|
70
|
+
Learn more about Apitally on our 🌎 [website](https://apitally.io) or check out
|
|
71
|
+
the 📚 [documentation](https://docs.apitally.io).
|
|
72
|
+
|
|
73
|
+
This SDK is for APIs running on [Cloudflare Python Workers](https://developers.cloudflare.com/workers/languages/python/) and relies on [Logpush](https://developers.cloudflare.com/workers/observability/logs/logpush/) to send data to Apitally.
|
|
74
|
+
|
|
75
|
+
## Key features
|
|
76
|
+
|
|
77
|
+
### API analytics
|
|
78
|
+
|
|
79
|
+
Track traffic, error and performance metrics for your API, each endpoint and
|
|
80
|
+
individual API consumers, allowing you to make informed, data-driven engineering
|
|
81
|
+
and product decisions.
|
|
82
|
+
|
|
83
|
+
### Request logs
|
|
84
|
+
|
|
85
|
+
Drill down from insights to individual API requests or use powerful search and filters to
|
|
86
|
+
find specific requests. View correlated application logs for a complete picture
|
|
87
|
+
of each request, making troubleshooting faster and easier.
|
|
88
|
+
|
|
89
|
+
### Error tracking
|
|
90
|
+
|
|
91
|
+
Understand which validation rules in your endpoints cause client errors. Capture
|
|
92
|
+
error details and stack traces for 500 error responses.
|
|
93
|
+
|
|
94
|
+
### API monitoring & alerts
|
|
95
|
+
|
|
96
|
+
Get notified immediately if something isn't right using custom alerts and synthetic
|
|
97
|
+
uptime checks. Alert notifications can be delivered via email, Slack and Microsoft Teams.
|
|
98
|
+
|
|
99
|
+
## Supported frameworks
|
|
100
|
+
|
|
101
|
+
| Framework | Supported versions | Setup guide |
|
|
102
|
+
| ------------------------------------------------- | ------------------ | ------------------------------------------------------------------------ |
|
|
103
|
+
| [**FastAPI**](https://github.com/fastapi/fastapi) | `>=0.116.1` | [Link](https://docs.apitally.io/setup-guides/fastapi-cloudflare-workers) |
|
|
104
|
+
|
|
105
|
+
Apitally also supports many other web frameworks in [Python](https://github.com/apitally/apitally-py), [JavaScript](https://github.com/apitally/apitally-js), [Go](https://github.com/apitally/apitally-go) and [.NET](https://github.com/apitally/apitally-dotnet) via our other SDKs.
|
|
106
|
+
|
|
107
|
+
## Getting started
|
|
108
|
+
|
|
109
|
+
If you don't have an Apitally account yet, first [sign up here](https://app.apitally.io/?signup).
|
|
110
|
+
|
|
111
|
+
### 1. Create app in Apitally
|
|
112
|
+
|
|
113
|
+
Create an app in the Apitally dashboard and select **FastAPI (Cloudflare Workers)** as your framework. You'll see detailed setup instructions, which also include your client ID.
|
|
114
|
+
|
|
115
|
+
### 2. Create Logpush job
|
|
116
|
+
|
|
117
|
+
Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/) and navigate to _Analytics & Logs > Logpush_. Create a [Logpush](https://developers.cloudflare.com/workers/observability/logs/logpush/) job with the following settings:
|
|
118
|
+
|
|
119
|
+
| Setting | Value |
|
|
120
|
+
| ---------------------------- | ---------------------------------------------------------------------------------- |
|
|
121
|
+
| Destination | HTTP destination |
|
|
122
|
+
| HTTP endpoint | `https://hub.apitally.io/v2/{client-id}/{env}/logpush` |
|
|
123
|
+
| Dataset | Workers trace events |
|
|
124
|
+
| If logs match... | Filtered logs: EventType equals `fetch` and ScriptName equals `{your-worker-name}` |
|
|
125
|
+
| Send the following fields... | General: Event, EventTimestampMs, Logs |
|
|
126
|
+
|
|
127
|
+
In the HTTP endpoint, replace `{client-id}` with your app's client ID and `{env}` with the environment (e.g. `prod` or `dev`). In the filter criteria, replace `{your-worker-name}` with the name of your Worker, as specified in your Wrangler config.
|
|
128
|
+
|
|
129
|
+
### 3. Configure Worker
|
|
130
|
+
|
|
131
|
+
Enable [Workers Logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/) and [Logpush](https://developers.cloudflare.com/workers/observability/logs/logpush/) in your `wrangler.toml` configuration file:
|
|
132
|
+
|
|
133
|
+
```toml
|
|
134
|
+
logpush = true
|
|
135
|
+
|
|
136
|
+
[observability]
|
|
137
|
+
enabled = true
|
|
138
|
+
head_sampling_rate = 1
|
|
139
|
+
|
|
140
|
+
[observability.logs]
|
|
141
|
+
invocation_logs = true
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 4. Add middleware
|
|
145
|
+
|
|
146
|
+
Install the SDK:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
uv add apitally-serverless
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Then add the Apitally middleware to your FastAPI application:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
from fastapi import FastAPI
|
|
156
|
+
from apitally_serverless.fastapi import ApitallyMiddleware
|
|
157
|
+
|
|
158
|
+
app = FastAPI()
|
|
159
|
+
app.add_middleware(
|
|
160
|
+
ApitallyMiddleware,
|
|
161
|
+
log_request_headers=True,
|
|
162
|
+
log_request_body=True,
|
|
163
|
+
log_response_body=True,
|
|
164
|
+
)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
For further instructions, see our
|
|
168
|
+
[setup guide for FastAPI on Cloudflare Workers](https://docs.apitally.io/setup-guides/fastapi-cloudflare-workers).
|
|
169
|
+
|
|
170
|
+
See the [SDK reference](https://docs.apitally.io/sdk-reference/python-serverless) for all available configuration options, including how to mask sensitive data, customize request logging, and more.
|
|
171
|
+
|
|
172
|
+
## Getting help
|
|
173
|
+
|
|
174
|
+
If you need help please
|
|
175
|
+
[create a new discussion](https://github.com/orgs/apitally/discussions/categories/q-a)
|
|
176
|
+
on GitHub or email us at [support@apitally.io](mailto:support@apitally.io). We'll get back to you as soon as possible.
|
|
177
|
+
|
|
178
|
+
## License
|
|
179
|
+
|
|
180
|
+
This library is licensed under the terms of the [MIT license](LICENSE).
|
|
@@ -0,0 +1,141 @@
|
|
|
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;">Metrics, logs, and alerts for your serverless APIs — with just a few lines of code.</p>
|
|
12
|
+
<br>
|
|
13
|
+
<p>
|
|
14
|
+
<picture>
|
|
15
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://assets.apitally.io/screenshots/overview-dark.png">
|
|
16
|
+
<source media="(prefers-color-scheme: light)" srcset="https://assets.apitally.io/screenshots/overview-light.png">
|
|
17
|
+
<img alt="Apitally dashboard" src="https://assets.apitally.io/screenshots/overview-light.png">
|
|
18
|
+
</picture>
|
|
19
|
+
</p>
|
|
20
|
+
<br>
|
|
21
|
+
|
|
22
|
+
# Apitally SDK for Cloudflare Python Workers
|
|
23
|
+
|
|
24
|
+
[](https://github.com/apitally/apitally-py-serverless/actions)
|
|
25
|
+
[](https://codecov.io/gh/apitally/apitally-py-serverless)
|
|
26
|
+
[](https://pypi.org/project/apitally-serverless/)
|
|
27
|
+
|
|
28
|
+
Apitally is a simple API monitoring and analytics tool that makes it easy to understand API usage, monitor performance, and troubleshoot issues.
|
|
29
|
+
Get started in minutes by just adding a few lines of code and a Logpush job.
|
|
30
|
+
|
|
31
|
+
Learn more about Apitally on our 🌎 [website](https://apitally.io) or check out
|
|
32
|
+
the 📚 [documentation](https://docs.apitally.io).
|
|
33
|
+
|
|
34
|
+
This SDK is for APIs running on [Cloudflare Python Workers](https://developers.cloudflare.com/workers/languages/python/) and relies on [Logpush](https://developers.cloudflare.com/workers/observability/logs/logpush/) to send data to Apitally.
|
|
35
|
+
|
|
36
|
+
## Key features
|
|
37
|
+
|
|
38
|
+
### API analytics
|
|
39
|
+
|
|
40
|
+
Track traffic, error and performance metrics for your API, each endpoint and
|
|
41
|
+
individual API consumers, allowing you to make informed, data-driven engineering
|
|
42
|
+
and product decisions.
|
|
43
|
+
|
|
44
|
+
### Request logs
|
|
45
|
+
|
|
46
|
+
Drill down from insights to individual API requests or use powerful search and filters to
|
|
47
|
+
find specific requests. View correlated application logs for a complete picture
|
|
48
|
+
of each request, making troubleshooting faster and easier.
|
|
49
|
+
|
|
50
|
+
### Error tracking
|
|
51
|
+
|
|
52
|
+
Understand which validation rules in your endpoints cause client errors. Capture
|
|
53
|
+
error details and stack traces for 500 error responses.
|
|
54
|
+
|
|
55
|
+
### API monitoring & alerts
|
|
56
|
+
|
|
57
|
+
Get notified immediately if something isn't right using custom alerts and synthetic
|
|
58
|
+
uptime checks. Alert notifications can be delivered via email, Slack and Microsoft Teams.
|
|
59
|
+
|
|
60
|
+
## Supported frameworks
|
|
61
|
+
|
|
62
|
+
| Framework | Supported versions | Setup guide |
|
|
63
|
+
| ------------------------------------------------- | ------------------ | ------------------------------------------------------------------------ |
|
|
64
|
+
| [**FastAPI**](https://github.com/fastapi/fastapi) | `>=0.116.1` | [Link](https://docs.apitally.io/setup-guides/fastapi-cloudflare-workers) |
|
|
65
|
+
|
|
66
|
+
Apitally also supports many other web frameworks in [Python](https://github.com/apitally/apitally-py), [JavaScript](https://github.com/apitally/apitally-js), [Go](https://github.com/apitally/apitally-go) and [.NET](https://github.com/apitally/apitally-dotnet) via our other SDKs.
|
|
67
|
+
|
|
68
|
+
## Getting started
|
|
69
|
+
|
|
70
|
+
If you don't have an Apitally account yet, first [sign up here](https://app.apitally.io/?signup).
|
|
71
|
+
|
|
72
|
+
### 1. Create app in Apitally
|
|
73
|
+
|
|
74
|
+
Create an app in the Apitally dashboard and select **FastAPI (Cloudflare Workers)** as your framework. You'll see detailed setup instructions, which also include your client ID.
|
|
75
|
+
|
|
76
|
+
### 2. Create Logpush job
|
|
77
|
+
|
|
78
|
+
Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/) and navigate to _Analytics & Logs > Logpush_. Create a [Logpush](https://developers.cloudflare.com/workers/observability/logs/logpush/) job with the following settings:
|
|
79
|
+
|
|
80
|
+
| Setting | Value |
|
|
81
|
+
| ---------------------------- | ---------------------------------------------------------------------------------- |
|
|
82
|
+
| Destination | HTTP destination |
|
|
83
|
+
| HTTP endpoint | `https://hub.apitally.io/v2/{client-id}/{env}/logpush` |
|
|
84
|
+
| Dataset | Workers trace events |
|
|
85
|
+
| If logs match... | Filtered logs: EventType equals `fetch` and ScriptName equals `{your-worker-name}` |
|
|
86
|
+
| Send the following fields... | General: Event, EventTimestampMs, Logs |
|
|
87
|
+
|
|
88
|
+
In the HTTP endpoint, replace `{client-id}` with your app's client ID and `{env}` with the environment (e.g. `prod` or `dev`). In the filter criteria, replace `{your-worker-name}` with the name of your Worker, as specified in your Wrangler config.
|
|
89
|
+
|
|
90
|
+
### 3. Configure Worker
|
|
91
|
+
|
|
92
|
+
Enable [Workers Logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/) and [Logpush](https://developers.cloudflare.com/workers/observability/logs/logpush/) in your `wrangler.toml` configuration file:
|
|
93
|
+
|
|
94
|
+
```toml
|
|
95
|
+
logpush = true
|
|
96
|
+
|
|
97
|
+
[observability]
|
|
98
|
+
enabled = true
|
|
99
|
+
head_sampling_rate = 1
|
|
100
|
+
|
|
101
|
+
[observability.logs]
|
|
102
|
+
invocation_logs = true
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 4. Add middleware
|
|
106
|
+
|
|
107
|
+
Install the SDK:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
uv add apitally-serverless
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Then add the Apitally middleware to your FastAPI application:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from fastapi import FastAPI
|
|
117
|
+
from apitally_serverless.fastapi import ApitallyMiddleware
|
|
118
|
+
|
|
119
|
+
app = FastAPI()
|
|
120
|
+
app.add_middleware(
|
|
121
|
+
ApitallyMiddleware,
|
|
122
|
+
log_request_headers=True,
|
|
123
|
+
log_request_body=True,
|
|
124
|
+
log_response_body=True,
|
|
125
|
+
)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
For further instructions, see our
|
|
129
|
+
[setup guide for FastAPI on Cloudflare Workers](https://docs.apitally.io/setup-guides/fastapi-cloudflare-workers).
|
|
130
|
+
|
|
131
|
+
See the [SDK reference](https://docs.apitally.io/sdk-reference/python-serverless) for all available configuration options, including how to mask sensitive data, customize request logging, and more.
|
|
132
|
+
|
|
133
|
+
## Getting help
|
|
134
|
+
|
|
135
|
+
If you need help please
|
|
136
|
+
[create a new discussion](https://github.com/orgs/apitally/discussions/categories/q-a)
|
|
137
|
+
on GitHub or email us at [support@apitally.io](mailto:support@apitally.io). We'll get back to you as soon as possible.
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
This library is licensed under the terms of the [MIT license](LICENSE).
|