apitally 0.16.0__tar.gz → 0.16.1__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 (53) hide show
  1. {apitally-0.16.0 → apitally-0.16.1}/PKG-INFO +1 -1
  2. {apitally-0.16.0 → apitally-0.16.1}/apitally/blacksheep.py +5 -10
  3. {apitally-0.16.0 → apitally-0.16.1}/tests/test_blacksheep.py +1 -1
  4. {apitally-0.16.0 → apitally-0.16.1}/.github/workflows/publish.yaml +0 -0
  5. {apitally-0.16.0 → apitally-0.16.1}/.github/workflows/summary.yaml +0 -0
  6. {apitally-0.16.0 → apitally-0.16.1}/.github/workflows/tests.yaml +0 -0
  7. {apitally-0.16.0 → apitally-0.16.1}/.gitignore +0 -0
  8. {apitally-0.16.0 → apitally-0.16.1}/.pre-commit-config.yaml +0 -0
  9. {apitally-0.16.0 → apitally-0.16.1}/LICENSE +0 -0
  10. {apitally-0.16.0 → apitally-0.16.1}/Makefile +0 -0
  11. {apitally-0.16.0 → apitally-0.16.1}/README.md +0 -0
  12. {apitally-0.16.0 → apitally-0.16.1}/apitally/__init__.py +0 -0
  13. {apitally-0.16.0 → apitally-0.16.1}/apitally/client/__init__.py +0 -0
  14. {apitally-0.16.0 → apitally-0.16.1}/apitally/client/client_asyncio.py +0 -0
  15. {apitally-0.16.0 → apitally-0.16.1}/apitally/client/client_base.py +0 -0
  16. {apitally-0.16.0 → apitally-0.16.1}/apitally/client/client_threading.py +0 -0
  17. {apitally-0.16.0 → apitally-0.16.1}/apitally/client/consumers.py +0 -0
  18. {apitally-0.16.0 → apitally-0.16.1}/apitally/client/logging.py +0 -0
  19. {apitally-0.16.0 → apitally-0.16.1}/apitally/client/request_logging.py +0 -0
  20. {apitally-0.16.0 → apitally-0.16.1}/apitally/client/requests.py +0 -0
  21. {apitally-0.16.0 → apitally-0.16.1}/apitally/client/sentry.py +0 -0
  22. {apitally-0.16.0 → apitally-0.16.1}/apitally/client/server_errors.py +0 -0
  23. {apitally-0.16.0 → apitally-0.16.1}/apitally/client/validation_errors.py +0 -0
  24. {apitally-0.16.0 → apitally-0.16.1}/apitally/common.py +0 -0
  25. {apitally-0.16.0 → apitally-0.16.1}/apitally/django.py +0 -0
  26. {apitally-0.16.0 → apitally-0.16.1}/apitally/django_ninja.py +0 -0
  27. {apitally-0.16.0 → apitally-0.16.1}/apitally/django_rest_framework.py +0 -0
  28. {apitally-0.16.0 → apitally-0.16.1}/apitally/fastapi.py +0 -0
  29. {apitally-0.16.0 → apitally-0.16.1}/apitally/flask.py +0 -0
  30. {apitally-0.16.0 → apitally-0.16.1}/apitally/litestar.py +0 -0
  31. {apitally-0.16.0 → apitally-0.16.1}/apitally/py.typed +0 -0
  32. {apitally-0.16.0 → apitally-0.16.1}/apitally/starlette.py +0 -0
  33. {apitally-0.16.0 → apitally-0.16.1}/pyproject.toml +0 -0
  34. {apitally-0.16.0 → apitally-0.16.1}/renovate.json +0 -0
  35. {apitally-0.16.0 → apitally-0.16.1}/tests/__init__.py +0 -0
  36. {apitally-0.16.0 → apitally-0.16.1}/tests/conftest.py +0 -0
  37. {apitally-0.16.0 → apitally-0.16.1}/tests/constants.py +0 -0
  38. {apitally-0.16.0 → apitally-0.16.1}/tests/django_ninja_urls.py +0 -0
  39. {apitally-0.16.0 → apitally-0.16.1}/tests/django_rest_framework_urls.py +0 -0
  40. {apitally-0.16.0 → apitally-0.16.1}/tests/test_client_asyncio.py +0 -0
  41. {apitally-0.16.0 → apitally-0.16.1}/tests/test_client_consumers.py +0 -0
  42. {apitally-0.16.0 → apitally-0.16.1}/tests/test_client_request_logging.py +0 -0
  43. {apitally-0.16.0 → apitally-0.16.1}/tests/test_client_requests.py +0 -0
  44. {apitally-0.16.0 → apitally-0.16.1}/tests/test_client_server_errors.py +0 -0
  45. {apitally-0.16.0 → apitally-0.16.1}/tests/test_client_threading.py +0 -0
  46. {apitally-0.16.0 → apitally-0.16.1}/tests/test_client_validation_errors.py +0 -0
  47. {apitally-0.16.0 → apitally-0.16.1}/tests/test_django_ninja.py +0 -0
  48. {apitally-0.16.0 → apitally-0.16.1}/tests/test_django_rest_framework.py +0 -0
  49. {apitally-0.16.0 → apitally-0.16.1}/tests/test_fastapi.py +0 -0
  50. {apitally-0.16.0 → apitally-0.16.1}/tests/test_flask.py +0 -0
  51. {apitally-0.16.0 → apitally-0.16.1}/tests/test_litestar.py +0 -0
  52. {apitally-0.16.0 → apitally-0.16.1}/tests/test_starlette.py +0 -0
  53. {apitally-0.16.0 → apitally-0.16.1}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apitally
3
- Version: 0.16.0
3
+ Version: 0.16.1
4
4
  Summary: Simple API monitoring & analytics for REST APIs built with FastAPI, Flask, Django, Starlette, Litestar and BlackSheep.
5
5
  Project-URL: Homepage, https://apitally.io
6
6
  Project-URL: Documentation, https://docs.apitally.io
@@ -1,4 +1,3 @@
1
- import asyncio
2
1
  import time
3
2
  from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple, Union
4
3
 
@@ -60,15 +59,14 @@ class ApitallyMiddleware:
60
59
  identify_consumer_callback: Optional[Callable[[Request], Union[str, ApitallyConsumer, None]]] = None,
61
60
  ) -> None:
62
61
  self.app = app
62
+ self.app_version = app_version
63
63
  self.identify_consumer_callback = identify_consumer_callback
64
64
  self.client = ApitallyClient(
65
65
  client_id=client_id,
66
66
  env=env,
67
67
  request_logging_config=request_logging_config,
68
68
  )
69
- self.client.start_sync_loop()
70
- self._delayed_set_startup_data_task: Optional[asyncio.Task] = None
71
- self.delayed_set_startup_data(app_version)
69
+ self.app.on_start += self.after_start
72
70
  self.app.on_stop += self.on_stop
73
71
 
74
72
  self.capture_request_body = (
@@ -78,13 +76,10 @@ class ApitallyMiddleware:
78
76
  self.client.request_logger.config.enabled and self.client.request_logger.config.log_response_body
79
77
  )
80
78
 
81
- def delayed_set_startup_data(self, app_version: Optional[str] = None) -> None:
82
- self._delayed_set_startup_data_task = asyncio.create_task(self._delayed_set_startup_data(app_version))
83
-
84
- async def _delayed_set_startup_data(self, app_version: Optional[str] = None) -> None:
85
- await asyncio.sleep(1.0) # Short delay to allow app routes to be registered first
86
- data = _get_startup_data(self.app, app_version=app_version)
79
+ async def after_start(self, application: Application) -> None:
80
+ data = _get_startup_data(application, app_version=self.app_version)
87
81
  self.client.set_startup_data(data)
82
+ self.client.start_sync_loop()
88
83
 
89
84
  async def on_stop(self, application: Application) -> None:
90
85
  await self.client.handle_shutdown()
@@ -21,7 +21,6 @@ async def app(module_mocker: MockerFixture) -> Application:
21
21
  module_mocker.patch("apitally.client.client_asyncio.ApitallyClient._instance", None)
22
22
  module_mocker.patch("apitally.client.client_asyncio.ApitallyClient.start_sync_loop")
23
23
  module_mocker.patch("apitally.client.client_asyncio.ApitallyClient.set_startup_data")
24
- module_mocker.patch("apitally.blacksheep.ApitallyMiddleware.delayed_set_startup_data")
25
24
  app = get_app()
26
25
  await app.start()
27
26
  return app
@@ -46,6 +45,7 @@ def get_app() -> Application:
46
45
  log_request_body=True,
47
46
  log_response_body=True,
48
47
  ),
48
+ app_version="1.2.3",
49
49
  identify_consumer_callback=identify_consumer,
50
50
  )
51
51
 
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
File without changes
File without changes
File without changes
File without changes