apitally 0.14.1__py3-none-any.whl → 0.14.2__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/client/request_logging.py +20 -1
- {apitally-0.14.1.dist-info → apitally-0.14.2.dist-info}/METADATA +1 -1
- {apitally-0.14.1.dist-info → apitally-0.14.2.dist-info}/RECORD +5 -5
- {apitally-0.14.1.dist-info → apitally-0.14.2.dist-info}/WHEEL +0 -0
- {apitally-0.14.1.dist-info → apitally-0.14.2.dist-info}/licenses/LICENSE +0 -0
@@ -35,6 +35,12 @@ EXCLUDE_PATH_PATTERNS = [
|
|
35
35
|
r"/ready$",
|
36
36
|
r"/live$",
|
37
37
|
]
|
38
|
+
EXCLUDE_USER_AGENT_PATTERNS = [
|
39
|
+
r"health[_- ]?check",
|
40
|
+
r"microsoft-azure-application-lb",
|
41
|
+
r"googlehc",
|
42
|
+
r"kube-probe",
|
43
|
+
]
|
38
44
|
MASK_QUERY_PARAM_PATTERNS = [
|
39
45
|
r"auth",
|
40
46
|
r"api-?key",
|
@@ -162,7 +168,12 @@ class RequestLogger:
|
|
162
168
|
if not self.enabled or self.suspend_until is not None:
|
163
169
|
return
|
164
170
|
parsed_url = urlparse(request["url"])
|
165
|
-
|
171
|
+
user_agent = self._get_user_agent(request["headers"])
|
172
|
+
if (
|
173
|
+
self._should_exclude_path(request["path"] or parsed_url.path)
|
174
|
+
or self._should_exclude_user_agent(user_agent)
|
175
|
+
or self._should_exclude(request, response)
|
176
|
+
):
|
166
177
|
return
|
167
178
|
|
168
179
|
query = self._mask_query_params(parsed_url.query) if self.config.log_query_params else ""
|
@@ -271,6 +282,10 @@ class RequestLogger:
|
|
271
282
|
patterns = self.config.exclude_paths + EXCLUDE_PATH_PATTERNS
|
272
283
|
return self._match_patterns(url_path, patterns)
|
273
284
|
|
285
|
+
@lru_cache(maxsize=1000)
|
286
|
+
def _should_exclude_user_agent(self, user_agent: Optional[str]) -> bool:
|
287
|
+
return self._match_patterns(user_agent, EXCLUDE_USER_AGENT_PATTERNS) if user_agent is not None else False
|
288
|
+
|
274
289
|
def _mask_query_params(self, query: str) -> str:
|
275
290
|
query_params = parse_qsl(query)
|
276
291
|
masked_query_params = [(k, v if not self._should_mask_query_param(k) else MASKED) for k, v in query_params]
|
@@ -302,6 +317,10 @@ class RequestLogger:
|
|
302
317
|
content_type = next((v for k, v in headers if k.lower() == "content-type"), None)
|
303
318
|
return content_type is not None and any(content_type.startswith(t) for t in ALLOWED_CONTENT_TYPES)
|
304
319
|
|
320
|
+
@staticmethod
|
321
|
+
def _get_user_agent(headers: List[Tuple[str, str]]) -> Optional[str]:
|
322
|
+
return next((v for k, v in headers if k.lower() == "user-agent"), None)
|
323
|
+
|
305
324
|
|
306
325
|
def _check_writable_fs() -> bool:
|
307
326
|
try:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: apitally
|
3
|
-
Version: 0.14.
|
3
|
+
Version: 0.14.2
|
4
4
|
Summary: Simple API monitoring & analytics for REST APIs built with FastAPI, Flask, Django, Starlette and Litestar.
|
5
5
|
Project-URL: Homepage, https://apitally.io
|
6
6
|
Project-URL: Documentation, https://docs.apitally.io
|
@@ -14,11 +14,11 @@ apitally/client/client_base.py,sha256=w5AXAbg3hw5Qds5rovCZFtePB9bHNcJsr9l7kDgbro
|
|
14
14
|
apitally/client/client_threading.py,sha256=MbytG8EopF84nmr5ShAZaq-VviSXYnBfBl7cRFRe1Kg,7479
|
15
15
|
apitally/client/consumers.py,sha256=w_AFQhVgdtJVt7pVySBvSZwQg-2JVqmD2JQtVBoMkus,2626
|
16
16
|
apitally/client/logging.py,sha256=QMsKIIAFo92PNBUleeTgsrsQa7SEal-oJa1oOHUr1wI,507
|
17
|
-
apitally/client/request_logging.py,sha256=
|
17
|
+
apitally/client/request_logging.py,sha256=5i7Gv4yP7iq4tBgw-ppkhlZd_OwMc719ZvWEm16TCvg,13047
|
18
18
|
apitally/client/requests.py,sha256=RdJyvIqQGVHvS-wjpAPUwcO7byOJ6jO8dYqNTU2Furg,3685
|
19
19
|
apitally/client/server_errors.py,sha256=axEhOxqV5SWjk0QCZTLVv2UMIaTfqPc81Typ4DXt66A,4646
|
20
20
|
apitally/client/validation_errors.py,sha256=6G8WYWFgJs9VH9swvkPXJGuOJgymj5ooWA9OwjUTbuM,1964
|
21
|
-
apitally-0.14.
|
22
|
-
apitally-0.14.
|
23
|
-
apitally-0.14.
|
24
|
-
apitally-0.14.
|
21
|
+
apitally-0.14.2.dist-info/METADATA,sha256=AUai6BWmcRZKC2mnN3om1SLIxPkyzPPMRAY-qdu1kus,7577
|
22
|
+
apitally-0.14.2.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
23
|
+
apitally-0.14.2.dist-info/licenses/LICENSE,sha256=vbLzC-4TddtXX-_AFEBKMYWRlxC_MN0g66QhPxo8PgY,1065
|
24
|
+
apitally-0.14.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|