apitally 0.11.2__py3-none-any.whl → 0.11.3__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 +1 -1
- apitally/client/asyncio.py +9 -5
- apitally/client/threading.py +9 -5
- apitally/django.py +1 -1
- apitally/flask.py +1 -1
- apitally/starlette.py +1 -1
- {apitally-0.11.2.dist-info → apitally-0.11.3.dist-info}/METADATA +1 -1
- {apitally-0.11.2.dist-info → apitally-0.11.3.dist-info}/RECORD +10 -10
- {apitally-0.11.2.dist-info → apitally-0.11.3.dist-info}/LICENSE +0 -0
- {apitally-0.11.2.dist-info → apitally-0.11.3.dist-info}/WHEEL +0 -0
apitally/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.11.
|
1
|
+
__version__ = "0.11.3"
|
apitally/client/asyncio.py
CHANGED
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
2
2
|
|
3
3
|
import asyncio
|
4
4
|
import logging
|
5
|
+
import random
|
5
6
|
import time
|
6
7
|
from functools import partial
|
7
8
|
from typing import Any, Dict, Optional, Tuple
|
@@ -82,18 +83,21 @@ class ApitallyClient(ApitallyClientBase):
|
|
82
83
|
data = self.get_sync_data()
|
83
84
|
self._sync_data_queue.put_nowait((time.time(), data))
|
84
85
|
|
85
|
-
|
86
|
+
i = 0
|
86
87
|
while not self._sync_data_queue.empty():
|
87
88
|
timestamp, data = self._sync_data_queue.get_nowait()
|
88
89
|
try:
|
89
90
|
if (time_offset := time.time() - timestamp) <= MAX_QUEUE_TIME:
|
91
|
+
if i > 0:
|
92
|
+
await asyncio.sleep(random.uniform(0.1, 0.3))
|
90
93
|
data["time_offset"] = time_offset
|
91
94
|
await self._send_sync_data(client, data)
|
92
|
-
|
95
|
+
i += 1
|
93
96
|
except httpx.HTTPError:
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
+
self._sync_data_queue.put_nowait((timestamp, data))
|
98
|
+
break
|
99
|
+
finally:
|
100
|
+
self._sync_data_queue.task_done()
|
97
101
|
|
98
102
|
@retry(raise_on_giveup=False)
|
99
103
|
async def _send_startup_data(self, client: httpx.AsyncClient, data: Dict[str, Any]) -> None:
|
apitally/client/threading.py
CHANGED
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
2
2
|
|
3
3
|
import logging
|
4
4
|
import queue
|
5
|
+
import random
|
5
6
|
import time
|
6
7
|
from functools import partial
|
7
8
|
from threading import Event, Thread
|
@@ -95,18 +96,21 @@ class ApitallyClient(ApitallyClientBase):
|
|
95
96
|
data = self.get_sync_data()
|
96
97
|
self._sync_data_queue.put_nowait((time.time(), data))
|
97
98
|
|
98
|
-
|
99
|
+
i = 0
|
99
100
|
while not self._sync_data_queue.empty():
|
100
101
|
timestamp, data = self._sync_data_queue.get_nowait()
|
101
102
|
try:
|
102
103
|
if (time_offset := time.time() - timestamp) <= MAX_QUEUE_TIME:
|
104
|
+
if i > 0:
|
105
|
+
time.sleep(random.uniform(0.1, 0.3))
|
103
106
|
data["time_offset"] = time_offset
|
104
107
|
self._send_sync_data(session, data)
|
105
|
-
|
108
|
+
i += 1
|
106
109
|
except requests.RequestException:
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
+
self._sync_data_queue.put_nowait((timestamp, data))
|
111
|
+
break
|
112
|
+
finally:
|
113
|
+
self._sync_data_queue.task_done()
|
110
114
|
|
111
115
|
@retry(raise_on_giveup=False)
|
112
116
|
def _send_startup_data(self, session: requests.Session, data: Dict[str, Any]) -> None:
|
apitally/django.py
CHANGED
@@ -94,7 +94,7 @@ class ApitallyMiddleware:
|
|
94
94
|
response = self.get_response(request)
|
95
95
|
response_time = time.perf_counter() - start_time
|
96
96
|
path = self.get_path(request)
|
97
|
-
if request.method is not None and path is not None:
|
97
|
+
if request.method is not None and request.method != "OPTIONS" and path is not None:
|
98
98
|
try:
|
99
99
|
consumer = self.get_consumer(request)
|
100
100
|
consumer_identifier = consumer.identifier if consumer else None
|
apitally/flask.py
CHANGED
@@ -93,7 +93,7 @@ class ApitallyMiddleware:
|
|
93
93
|
response_headers: Headers,
|
94
94
|
) -> None:
|
95
95
|
rule, is_handled_path = self.get_rule(environ)
|
96
|
-
if is_handled_path or not self.filter_unhandled_paths:
|
96
|
+
if (is_handled_path or not self.filter_unhandled_paths) and environ["REQUEST_METHOD"] != "OPTIONS":
|
97
97
|
consumer = self.get_consumer()
|
98
98
|
consumer_identifier = consumer.identifier if consumer else None
|
99
99
|
self.client.consumer_registry.add_or_update_consumer(consumer)
|
apitally/starlette.py
CHANGED
@@ -92,7 +92,7 @@ class ApitallyMiddleware(BaseHTTPMiddleware):
|
|
92
92
|
exception: Optional[BaseException] = None,
|
93
93
|
) -> None:
|
94
94
|
path_template, is_handled_path = self.get_path_template(request)
|
95
|
-
if is_handled_path or not self.filter_unhandled_paths:
|
95
|
+
if (is_handled_path or not self.filter_unhandled_paths) and request.method != "OPTIONS":
|
96
96
|
consumer = self.get_consumer(request)
|
97
97
|
consumer_identifier = consumer.identifier if consumer else None
|
98
98
|
self.client.consumer_registry.add_or_update_consumer(consumer)
|
@@ -1,19 +1,19 @@
|
|
1
|
-
apitally/__init__.py,sha256=
|
1
|
+
apitally/__init__.py,sha256=tCUnamQN48_YKI84dtjiVJI4cF4gypc8nKdvXAnhY_E,23
|
2
2
|
apitally/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
apitally/client/asyncio.py,sha256=
|
3
|
+
apitally/client/asyncio.py,sha256=Y5sbRLRnJCIJx9VQ2DGgQsYNKGvURV2U1y3VxHuPhgQ,4874
|
4
4
|
apitally/client/base.py,sha256=v4LSOYNIOoeL3KTVyBlXBY5LCXc79Lvu9yK5Y_KILSQ,15442
|
5
5
|
apitally/client/logging.py,sha256=QMsKIIAFo92PNBUleeTgsrsQa7SEal-oJa1oOHUr1wI,507
|
6
|
-
apitally/client/threading.py,sha256=
|
6
|
+
apitally/client/threading.py,sha256=cASa0C9nyRp5gf5IzCDj6TE-v8t8SW4zJ38W6NdJ3Q8,5204
|
7
7
|
apitally/common.py,sha256=GbVmnXxhRvV30d7CfCQ9r0AeXj14Mv9Jm_Yd1bRWP28,1088
|
8
|
-
apitally/django.py,sha256=
|
8
|
+
apitally/django.py,sha256=Zw8a971UwGKaEMPUtmlBbjufAYwMkSjRSQlss8FDY-E,13795
|
9
9
|
apitally/django_ninja.py,sha256=dqQtnz2s8YWYHCwvkK5BjokjvpZJpPNhP0vng4kFtrQ,120
|
10
10
|
apitally/django_rest_framework.py,sha256=dqQtnz2s8YWYHCwvkK5BjokjvpZJpPNhP0vng4kFtrQ,120
|
11
11
|
apitally/fastapi.py,sha256=hEyYZsvIaA3OXZSSFdey5iqeEjfBPHgfNbyX8pLm7GI,123
|
12
|
-
apitally/flask.py,sha256=
|
12
|
+
apitally/flask.py,sha256=7TJIoAT91-bR_7gZkL0clDk-Whl-V21hbo4nASaDmB4,6447
|
13
13
|
apitally/litestar.py,sha256=sQcrHw-JV9AlpnXlrczmaDe0k6tD9PYQsc8nyQul8Ko,8802
|
14
14
|
apitally/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
|
-
apitally/starlette.py,sha256=
|
16
|
-
apitally-0.11.
|
17
|
-
apitally-0.11.
|
18
|
-
apitally-0.11.
|
19
|
-
apitally-0.11.
|
15
|
+
apitally/starlette.py,sha256=HvphuX401h_ccqvOk2RKu7GGEai2WbGOjJ-WOE7-fWM,8781
|
16
|
+
apitally-0.11.3.dist-info/LICENSE,sha256=vbLzC-4TddtXX-_AFEBKMYWRlxC_MN0g66QhPxo8PgY,1065
|
17
|
+
apitally-0.11.3.dist-info/METADATA,sha256=oIrHGgHHvCpqj7LzkhpvT3nbMiTChIkPK5pPGBwH8C8,6994
|
18
|
+
apitally-0.11.3.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
19
|
+
apitally-0.11.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|