reqly 0.1.1__tar.gz → 0.1.3__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.
Files changed (25) hide show
  1. {reqly-0.1.1 → reqly-0.1.3}/PKG-INFO +1 -1
  2. {reqly-0.1.1 → reqly-0.1.3}/pyproject.toml +1 -1
  3. {reqly-0.1.1 → reqly-0.1.3}/reqly/__init__.py +1 -1
  4. {reqly-0.1.1 → reqly-0.1.3}/reqly/core/capture.py +9 -1
  5. {reqly-0.1.1 → reqly-0.1.3}/reqly/core/config.py +9 -1
  6. {reqly-0.1.1 → reqly-0.1.3}/reqly/core/shipper.py +17 -3
  7. {reqly-0.1.1 → reqly-0.1.3}/reqly.egg-info/PKG-INFO +1 -1
  8. {reqly-0.1.1 → reqly-0.1.3}/README.md +0 -0
  9. {reqly-0.1.1 → reqly-0.1.3}/reqly/core/__init__.py +0 -0
  10. {reqly-0.1.1 → reqly-0.1.3}/reqly/core/buffer.py +0 -0
  11. {reqly-0.1.1 → reqly-0.1.3}/reqly/core/client.py +0 -0
  12. {reqly-0.1.1 → reqly-0.1.3}/reqly/core/sampling.py +0 -0
  13. {reqly-0.1.1 → reqly-0.1.3}/reqly/integrations/__init__.py +0 -0
  14. {reqly-0.1.1 → reqly-0.1.3}/reqly/integrations/fastapi.py +0 -0
  15. {reqly-0.1.1 → reqly-0.1.3}/reqly/integrations/flask.py +0 -0
  16. {reqly-0.1.1 → reqly-0.1.3}/reqly.egg-info/SOURCES.txt +0 -0
  17. {reqly-0.1.1 → reqly-0.1.3}/reqly.egg-info/dependency_links.txt +0 -0
  18. {reqly-0.1.1 → reqly-0.1.3}/reqly.egg-info/requires.txt +0 -0
  19. {reqly-0.1.1 → reqly-0.1.3}/reqly.egg-info/top_level.txt +0 -0
  20. {reqly-0.1.1 → reqly-0.1.3}/setup.cfg +0 -0
  21. {reqly-0.1.1 → reqly-0.1.3}/tests/test_buffer.py +0 -0
  22. {reqly-0.1.1 → reqly-0.1.3}/tests/test_capture.py +0 -0
  23. {reqly-0.1.1 → reqly-0.1.3}/tests/test_fastapi_integration.py +0 -0
  24. {reqly-0.1.1 → reqly-0.1.3}/tests/test_flask_integration.py +0 -0
  25. {reqly-0.1.1 → reqly-0.1.3}/tests/test_sampling.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reqly
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Auto-instrumentation SDK for FastAPI and Flask: zero-code latency, error rates, and status codes shipped to a Reqly collector.
5
5
  Author: reqly
6
6
  License-Expression: GPL-3.0-or-later
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "reqly"
7
- version = "0.1.1"
7
+ version = "0.1.3"
8
8
  description = "Auto-instrumentation SDK for FastAPI and Flask: zero-code latency, error rates, and status codes shipped to a Reqly collector."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -44,7 +44,7 @@ def instrument(
44
44
  max_queue_size: int | None = None,
45
45
  ignore_routes: list[str] | None = None,
46
46
  capture_request_body: bool | None = None,
47
- ) -> ReqlyClient:
47
+ ) -> ReqlyClient | None:
48
48
  """Instrument a FastAPI or Flask app with one line.
49
49
 
50
50
  Config resolution order for any omitted argument: explicit kwarg >
@@ -4,6 +4,14 @@ import socket
4
4
  import uuid
5
5
  from dataclasses import asdict, dataclass, field
6
6
  from datetime import datetime, timezone
7
+ from importlib.metadata import PackageNotFoundError, version as _pkg_version
8
+
9
+
10
+ def _get_sdk_version() -> str:
11
+ try:
12
+ return _pkg_version("reqly")
13
+ except PackageNotFoundError:
14
+ return "0.1.0"
7
15
 
8
16
  _HOSTNAME = socket.gethostname()
9
17
 
@@ -27,7 +35,7 @@ class RequestEvent:
27
35
  error: bool = False
28
36
  error_type: str | None = None
29
37
  host: str = _HOSTNAME
30
- sdk_version: str = "0.1.0"
38
+ sdk_version: str = field(default_factory=_get_sdk_version)
31
39
 
32
40
  def to_dict(self) -> dict:
33
41
  return asdict(self)
@@ -2,6 +2,14 @@ from __future__ import annotations
2
2
 
3
3
  import os
4
4
  from dataclasses import dataclass, field
5
+ from importlib.metadata import PackageNotFoundError, version as _pkg_version
6
+
7
+
8
+ def _get_sdk_version() -> str:
9
+ try:
10
+ return _pkg_version("reqly")
11
+ except PackageNotFoundError:
12
+ return "0.1.0"
5
13
 
6
14
 
7
15
  def _env_float(name: str, default: float) -> float:
@@ -48,7 +56,7 @@ class Config:
48
56
  max_queue_size: int = 2000
49
57
  ignore_routes: list[str] = field(default_factory=lambda: ["/health", "/metrics"])
50
58
  capture_request_body: bool = False
51
- sdk_version: str = "0.1.0"
59
+ sdk_version: str = field(default_factory=_get_sdk_version)
52
60
 
53
61
  @classmethod
54
62
  def resolve(
@@ -59,12 +59,19 @@ class Shipper:
59
59
  for attempt in range(_MAX_RETRIES):
60
60
  try:
61
61
  response = self._client.post("/v1/ingest", json=payload)
62
- if response.status_code < 500:
62
+ if response.status_code < 400:
63
63
  self.shipped_events += len(events)
64
64
  return True
65
+ if response.status_code != 429:
66
+ # permanent client error (auth failure, bad payload, etc.) — no point retrying
67
+ logger.warning(
68
+ "reqly: collector rejected batch with %s, dropping",
69
+ response.status_code,
70
+ )
71
+ self.dropped_batches += 1
72
+ return False
65
73
  logger.debug(
66
- "reqly: collector returned %s, attempt %d/%d",
67
- response.status_code,
74
+ "reqly: rate-limited (429), attempt %d/%d",
68
75
  attempt + 1,
69
76
  _MAX_RETRIES,
70
77
  )
@@ -75,6 +82,13 @@ class Shipper:
75
82
  attempt + 1,
76
83
  _MAX_RETRIES,
77
84
  )
85
+ except Exception as exc:
86
+ logger.warning(
87
+ "reqly: unexpected shipper error %s, attempt %d/%d",
88
+ exc,
89
+ attempt + 1,
90
+ _MAX_RETRIES,
91
+ )
78
92
 
79
93
  if attempt < _MAX_RETRIES - 1:
80
94
  backoff = _BACKOFF_BASE_SECONDS * (2**attempt)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reqly
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Auto-instrumentation SDK for FastAPI and Flask: zero-code latency, error rates, and status codes shipped to a Reqly collector.
5
5
  Author: reqly
6
6
  License-Expression: GPL-3.0-or-later
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes