apitally 0.12.1__py3-none-any.whl → 0.13.0a1__py3-none-any.whl

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/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.12.1"
1
+ __version__ = "0.0.0"
apitally/client/base.py CHANGED
@@ -4,6 +4,7 @@ import asyncio
4
4
  import contextlib
5
5
  import os
6
6
  import re
7
+ import sys
7
8
  import threading
8
9
  import time
9
10
  import traceback
@@ -328,7 +329,11 @@ class ServerErrorCounter:
328
329
  cutoff = MAX_EXCEPTION_TRACEBACK_LENGTH - len(prefix)
329
330
  lines = []
330
331
  length = 0
331
- for line in traceback.format_exception(exception)[::-1]:
332
+ if sys.version_info >= (3, 10):
333
+ traceback_lines = traceback.format_exception(exception)
334
+ else:
335
+ traceback_lines = traceback.format_exception(type(exception), exception, exception.__traceback__)
336
+ for line in traceback_lines[::-1]:
332
337
  if length + len(line) > cutoff:
333
338
  lines.append(prefix)
334
339
  break
apitally/starlette.py CHANGED
@@ -59,11 +59,12 @@ class ApitallyMiddleware:
59
59
  if scope["type"] == "http" and scope["method"] != "OPTIONS":
60
60
  request = Request(scope)
61
61
  response_status = 0
62
- response_time = 0.0
62
+ response_time: Optional[float] = None
63
63
  response_headers = Headers()
64
64
  response_body = b""
65
65
  response_size = 0
66
66
  response_chunked = False
67
+ exception: Optional[BaseException] = None
67
68
  start_time = time.perf_counter()
68
69
 
69
70
  async def send_wrapper(message: Message) -> None:
@@ -92,17 +93,11 @@ class ApitallyMiddleware:
92
93
  try:
93
94
  await self.app(scope, receive, send_wrapper)
94
95
  except BaseException as e:
95
- self.add_request(
96
- request=request,
97
- response_status=500,
98
- response_time=time.perf_counter() - start_time,
99
- response_headers=response_headers,
100
- response_body=response_body,
101
- response_size=response_size,
102
- exception=e,
103
- )
96
+ exception = e
104
97
  raise e from None
105
- else:
98
+ finally:
99
+ if response_time is None:
100
+ response_time = time.perf_counter() - start_time
106
101
  self.add_request(
107
102
  request=request,
108
103
  response_status=response_status,
@@ -110,6 +105,7 @@ class ApitallyMiddleware:
110
105
  response_headers=response_headers,
111
106
  response_body=response_body,
112
107
  response_size=response_size,
108
+ exception=exception,
113
109
  )
114
110
  else:
115
111
  await self.app(scope, receive, send) # pragma: no cover
@@ -129,6 +125,8 @@ class ApitallyMiddleware:
129
125
  consumer = self.get_consumer(request)
130
126
  consumer_identifier = consumer.identifier if consumer else None
131
127
  self.client.consumer_registry.add_or_update_consumer(consumer)
128
+ if response_status == 0 and exception is not None:
129
+ response_status = 500
132
130
  self.client.request_counter.add_request(
133
131
  consumer=consumer_identifier,
134
132
  method=request.method,
@@ -1,49 +1,64 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: apitally
3
- Version: 0.12.1
3
+ Version: 0.13.0a1
4
4
  Summary: Simple API monitoring & analytics for REST APIs built with FastAPI, Flask, Django, Starlette and Litestar.
5
- Home-page: https://apitally.io
6
- License: MIT
7
- Author: Apitally
8
- Author-email: hello@apitally.io
9
- Requires-Python: >=3.8,<4.0
10
- Classifier: Development Status :: 5 - Production/Stable
5
+ Project-URL: homepage, https://apitally.io
6
+ Project-URL: documentation, https://docs.apitally.io
7
+ Project-URL: source, https://github.com/apitally/apitally-py
8
+ Author-email: Apitally <hello@apitally.io>
9
+ License: MIT License
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Web Environment
11
13
  Classifier: Framework :: Django
12
14
  Classifier: Framework :: FastAPI
13
15
  Classifier: Framework :: Flask
14
16
  Classifier: Intended Audience :: Developers
15
17
  Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python
16
19
  Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Programming Language :: Python :: 3.7
17
22
  Classifier: Programming Language :: Python :: 3.8
18
23
  Classifier: Programming Language :: Python :: 3.9
19
24
  Classifier: Programming Language :: Python :: 3.10
20
25
  Classifier: Programming Language :: Python :: 3.11
26
+ Classifier: Topic :: Internet
21
27
  Classifier: Topic :: Internet :: WWW/HTTP
22
28
  Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware
29
+ Classifier: Topic :: Software Development
30
+ Classifier: Topic :: Software Development :: Libraries
31
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
32
  Classifier: Typing :: Typed
33
+ Requires-Python: <4.0,>=3.8
34
+ Requires-Dist: backoff>=2.0.0
24
35
  Provides-Extra: django-ninja
36
+ Requires-Dist: django-ninja>=0.18.0; extra == 'django-ninja'
37
+ Requires-Dist: django<5,>=2.2; (python_version < '3.10') and extra == 'django-ninja'
38
+ Requires-Dist: django>=2.2; (python_version >= '3.10') and extra == 'django-ninja'
39
+ Requires-Dist: requests>=2.26.0; extra == 'django-ninja'
25
40
  Provides-Extra: django-rest-framework
41
+ Requires-Dist: django<5,>=2.2; (python_version < '3.10') and extra == 'django-rest-framework'
42
+ Requires-Dist: django>=2.2; (python_version >= '3.10') and extra == 'django-rest-framework'
43
+ Requires-Dist: djangorestframework>=3.10.0; extra == 'django-rest-framework'
44
+ Requires-Dist: inflection>=0.5.1; extra == 'django-rest-framework'
45
+ Requires-Dist: requests>=2.26.0; extra == 'django-rest-framework'
46
+ Requires-Dist: uritemplate>=3.0.0; extra == 'django-rest-framework'
26
47
  Provides-Extra: fastapi
48
+ Requires-Dist: fastapi>=0.88.0; extra == 'fastapi'
49
+ Requires-Dist: httpx>=0.22.0; extra == 'fastapi'
50
+ Requires-Dist: starlette<1.0.0,>=0.22.0; extra == 'fastapi'
27
51
  Provides-Extra: flask
52
+ Requires-Dist: flask>=2.0.0; extra == 'flask'
53
+ Requires-Dist: requests>=2.26.0; extra == 'flask'
28
54
  Provides-Extra: litestar
55
+ Requires-Dist: httpx>=0.22.0; extra == 'litestar'
56
+ Requires-Dist: litestar>=2.0.0; extra == 'litestar'
29
57
  Provides-Extra: sentry
58
+ Requires-Dist: sentry-sdk>=2.2.0; extra == 'sentry'
30
59
  Provides-Extra: starlette
31
- Requires-Dist: backoff (>=2.0.0)
32
- Requires-Dist: django (>=2.2) ; (python_version >= "3.10") and (extra == "django-ninja" or extra == "django-rest-framework")
33
- Requires-Dist: django (>=2.2,<5) ; (python_version < "3.10") and (extra == "django-ninja" or extra == "django-rest-framework")
34
- Requires-Dist: django-ninja (>=0.18.0) ; extra == "django-ninja"
35
- Requires-Dist: djangorestframework (>=3.10.0) ; extra == "django-rest-framework"
36
- Requires-Dist: fastapi (>=0.87.0) ; extra == "fastapi"
37
- Requires-Dist: flask (>=2.0.0) ; extra == "flask"
38
- Requires-Dist: httpx (>=0.22.0) ; extra == "fastapi" or extra == "litestar" or extra == "starlette"
39
- Requires-Dist: inflection (>=0.5.1) ; extra == "django-rest-framework"
40
- Requires-Dist: litestar (>=2.0.0) ; extra == "litestar"
41
- Requires-Dist: requests (>=2.26.0) ; extra == "django-ninja" or extra == "django-rest-framework" or extra == "flask"
42
- Requires-Dist: sentry-sdk (>=2.2.0) ; extra == "sentry"
43
- Requires-Dist: starlette (>=0.21.0,<1.0.0) ; extra == "fastapi" or extra == "starlette"
44
- Requires-Dist: uritemplate (>=3.0.0) ; extra == "django-rest-framework"
45
- Project-URL: Documentation, https://docs.apitally.io
46
- Project-URL: Repository, https://github.com/apitally/apitally-py
60
+ Requires-Dist: httpx>=0.22.0; extra == 'starlette'
61
+ Requires-Dist: starlette<1.0.0,>=0.21.0; extra == 'starlette'
47
62
  Description-Content-Type: text/markdown
48
63
 
49
64
  <p align="center">
@@ -193,4 +208,3 @@ on GitHub or
193
208
  ## License
194
209
 
195
210
  This library is licensed under the terms of the MIT license.
196
-
@@ -1,9 +1,4 @@
1
- apitally/__init__.py,sha256=PAuBI8I6F9Yu_86XjI2yaWn8QmCd9ZvK7tkZLWvEg-Q,23
2
- apitally/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- apitally/client/asyncio.py,sha256=Y5sbRLRnJCIJx9VQ2DGgQsYNKGvURV2U1y3VxHuPhgQ,4874
4
- apitally/client/base.py,sha256=v4LSOYNIOoeL3KTVyBlXBY5LCXc79Lvu9yK5Y_KILSQ,15442
5
- apitally/client/logging.py,sha256=QMsKIIAFo92PNBUleeTgsrsQa7SEal-oJa1oOHUr1wI,507
6
- apitally/client/threading.py,sha256=cASa0C9nyRp5gf5IzCDj6TE-v8t8SW4zJ38W6NdJ3Q8,5204
1
+ apitally/__init__.py,sha256=ShXQBVjyiSOHxoQJS2BvNG395W4KZfqMxZWBAR0MZrE,22
7
2
  apitally/common.py,sha256=GbVmnXxhRvV30d7CfCQ9r0AeXj14Mv9Jm_Yd1bRWP28,1088
8
3
  apitally/django.py,sha256=Zw8a971UwGKaEMPUtmlBbjufAYwMkSjRSQlss8FDY-E,13795
9
4
  apitally/django_ninja.py,sha256=dqQtnz2s8YWYHCwvkK5BjokjvpZJpPNhP0vng4kFtrQ,120
@@ -12,8 +7,13 @@ apitally/fastapi.py,sha256=hEyYZsvIaA3OXZSSFdey5iqeEjfBPHgfNbyX8pLm7GI,123
12
7
  apitally/flask.py,sha256=7TJIoAT91-bR_7gZkL0clDk-Whl-V21hbo4nASaDmB4,6447
13
8
  apitally/litestar.py,sha256=O9bSzwJC-dN6ukRqyVNYBhUqxEpzie-bR2bFojcvvMI,9547
14
9
  apitally/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- apitally/starlette.py,sha256=qmdcAlypqACd4yL_B_5W0ykpkWJaf1YcCAW1yDxaS0c,9615
16
- apitally-0.12.1.dist-info/LICENSE,sha256=vbLzC-4TddtXX-_AFEBKMYWRlxC_MN0g66QhPxo8PgY,1065
17
- apitally-0.12.1.dist-info/METADATA,sha256=Fibm2KONAkF7Omu-bpxBWvzvhRbjYdtcN9I7h1oVMbg,6994
18
- apitally-0.12.1.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
19
- apitally-0.12.1.dist-info/RECORD,,
10
+ apitally/starlette.py,sha256=B1QTvw5nf9pdnuQda5XsCfConMN81ze8WQ0ldmiTdkc,9589
11
+ apitally/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ apitally/client/asyncio.py,sha256=Y5sbRLRnJCIJx9VQ2DGgQsYNKGvURV2U1y3VxHuPhgQ,4874
13
+ apitally/client/base.py,sha256=BC_KNDuhDQcjTasvztPey9879ITcuARhgCm6HSYbGTI,15663
14
+ apitally/client/logging.py,sha256=QMsKIIAFo92PNBUleeTgsrsQa7SEal-oJa1oOHUr1wI,507
15
+ apitally/client/threading.py,sha256=cASa0C9nyRp5gf5IzCDj6TE-v8t8SW4zJ38W6NdJ3Q8,5204
16
+ apitally-0.13.0a1.dist-info/METADATA,sha256=vTzZMzziddl1DodwJaOh5acpkEqUys5tu7N6diwfKSM,7613
17
+ apitally-0.13.0a1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
18
+ apitally-0.13.0a1.dist-info/licenses/LICENSE,sha256=vbLzC-4TddtXX-_AFEBKMYWRlxC_MN0g66QhPxo8PgY,1065
19
+ apitally-0.13.0a1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.7.0
2
+ Generator: hatchling 1.25.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any