apitally 0.16.0__py3-none-any.whl → 0.16.1__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/blacksheep.py CHANGED
@@ -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()
@@ -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,5 +1,5 @@
1
1
  apitally/__init__.py,sha256=ShXQBVjyiSOHxoQJS2BvNG395W4KZfqMxZWBAR0MZrE,22
2
- apitally/blacksheep.py,sha256=LSdg5LG-bnXdhKtPkp71CBQKGVtUi3t_EirovoaRy-s,9973
2
+ apitally/blacksheep.py,sha256=KvcPFeiwQgWZmRglbm8SLaN6_WRs5kZ3SymB1IuLR-A,9616
3
3
  apitally/common.py,sha256=azDxepViH0QW0MuufTHxeSQyLGzCkocAX_KPziWTx8A,1605
4
4
  apitally/django.py,sha256=zwe8svC8rfo7TyHfOlkYTeXptxPFoRjvt0bbYvgtJKM,16892
5
5
  apitally/django_ninja.py,sha256=-CmrwFFRv7thFOUK_OrOSouhHL9bm5sIBNIQlpyE_2c,166
@@ -20,7 +20,7 @@ apitally/client/requests.py,sha256=SDptGOg9XvaEKFj2o3oxJz-JAuZzUrqpHnbOQixf99o,3
20
20
  apitally/client/sentry.py,sha256=qMjHdI0V7c50ruo1WjmjWc8g6oGDv724vSCvcuZ8G9k,1188
21
21
  apitally/client/server_errors.py,sha256=4B2BKDFoIpoWc55UVH6AIdYSgzj6zxCdMNUW77JjhZw,3423
22
22
  apitally/client/validation_errors.py,sha256=6G8WYWFgJs9VH9swvkPXJGuOJgymj5ooWA9OwjUTbuM,1964
23
- apitally-0.16.0.dist-info/METADATA,sha256=kWbylw8pJ0Q0xHBt1P7S3h6cTqx9UQ8SBAnrxFew5CM,9321
24
- apitally-0.16.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
25
- apitally-0.16.0.dist-info/licenses/LICENSE,sha256=vbLzC-4TddtXX-_AFEBKMYWRlxC_MN0g66QhPxo8PgY,1065
26
- apitally-0.16.0.dist-info/RECORD,,
23
+ apitally-0.16.1.dist-info/METADATA,sha256=eS5sdPc9rWZRyr8WS_ZcvjSxtmiByflQ8n1GI01_0VI,9321
24
+ apitally-0.16.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
25
+ apitally-0.16.1.dist-info/licenses/LICENSE,sha256=vbLzC-4TddtXX-_AFEBKMYWRlxC_MN0g66QhPxo8PgY,1065
26
+ apitally-0.16.1.dist-info/RECORD,,