aury-boot 0.0.32__py3-none-any.whl → 0.0.33__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.
aury/boot/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.0.32'
32
- __version_tuple__ = version_tuple = (0, 0, 32)
31
+ __version__ = version = '0.0.33'
32
+ __version_tuple__ = version_tuple = (0, 0, 33)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -27,7 +27,7 @@
27
27
 
28
28
  from .aggregator import AlertAggregator
29
29
  from .events import AlertEvent, AlertEventType, AlertNotification, AlertSeverity
30
- from .manager import AlertManager, emit_alert
30
+ from .manager import AlertManager, emit_alert, emit_exception_alert
31
31
  from .notifiers import AlertNotifier, FeishuNotifier, WebhookNotifier
32
32
  from .rules import AlertRule, load_rules_from_dict
33
33
 
@@ -46,5 +46,6 @@ __all__ = [
46
46
  "WebhookNotifier",
47
47
  # 便捷函数
48
48
  "emit_alert",
49
+ "emit_exception_alert",
49
50
  "load_rules_from_dict",
50
51
  ]
@@ -424,7 +424,61 @@ def _detect_source() -> str:
424
424
  return "unknown"
425
425
 
426
426
 
427
+ async def emit_exception_alert(
428
+ exc: Exception,
429
+ message: str | None = None,
430
+ *,
431
+ severity: AlertSeverity = AlertSeverity.ERROR,
432
+ source: str | None = None,
433
+ **metadata: Any,
434
+ ) -> None:
435
+ """发送异常告警的便捷函数(带完整堆栈)。
436
+
437
+ 用于在 try/except 中捕获异常后手动发送告警。
438
+ 框架只会自动告警未被捕获的异常,被 catch 的异常需要手动调用此函数。
439
+
440
+ Args:
441
+ exc: 异常对象
442
+ message: 告警消息(默认使用异常信息)
443
+ severity: 严重级别(默认 ERROR)
444
+ source: 来源(可选,自动检测)
445
+ **metadata: 额外元数据(如 session_id, user_id 等)
446
+
447
+ Example:
448
+ try:
449
+ await some_operation()
450
+ except Exception as e:
451
+ await emit_exception_alert(
452
+ e,
453
+ source="task_stream",
454
+ session_id=session_id,
455
+ )
456
+ # 继续处理...
457
+ """
458
+ import traceback
459
+
460
+ exc_type = type(exc).__name__
461
+ exc_msg = str(exc)
462
+ tb = traceback.format_exc()
463
+
464
+ alert_message = message or f"{exc_type}: {exc_msg}"
465
+
466
+ # 合并异常信息到 metadata
467
+ metadata["error_type"] = exc_type
468
+ metadata["error_message"] = exc_msg
469
+ metadata["stacktrace"] = tb
470
+
471
+ await emit_alert(
472
+ AlertEventType.EXCEPTION,
473
+ alert_message,
474
+ severity=severity,
475
+ source=source,
476
+ **metadata,
477
+ )
478
+
479
+
427
480
  __all__ = [
428
481
  "AlertManager",
429
482
  "emit_alert",
483
+ "emit_exception_alert",
430
484
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aury-boot
3
- Version: 0.0.32
3
+ Version: 0.0.33
4
4
  Summary: Aury Boot - 基于 FastAPI 生态的企业级 API 开发框架
5
5
  Requires-Python: >=3.13
6
6
  Requires-Dist: alembic>=1.17.2
@@ -1,5 +1,5 @@
1
1
  aury/boot/__init__.py,sha256=pCno-EInnpIBa1OtxNYF-JWf9j95Cd2h6vmu0xqa_-4,1791
2
- aury/boot/_version.py,sha256=R_6iGx2TpbHTm0_3hIB8Kl5225iMZqRsqf47DXFHa64,706
2
+ aury/boot/_version.py,sha256=xrs8Qn_OZ3B9ijkPtzIwzsKzRxeJuFan8EOwBgLmnxE,706
3
3
  aury/boot/application/__init__.py,sha256=I2KqNVdYg2q5nlOXr0TtFGyHmhj4oWdaR6ZB73Mwg7Y,3041
4
4
  aury/boot/application/adapter/__init__.py,sha256=e1bcSb1bxUMfofTwiCuHBZJk5-STkMCWPF2EJXHQ7UU,3976
5
5
  aury/boot/application/adapter/base.py,sha256=Ar_66fiHPDEmV-1DKnqXKwc53p3pozG31bgTJTEUriY,15763
@@ -169,10 +169,10 @@ aury/boot/infrastructure/events/backends/__init__.py,sha256=1mj0rDauHdoRm4kXOg87
169
169
  aury/boot/infrastructure/events/backends/broadcaster.py,sha256=FnxO62LUXWLs1ZEiaYmNiMaL3ccXNtuc3DFzLe02eK0,6700
170
170
  aury/boot/infrastructure/events/backends/rabbitmq.py,sha256=XCuI9mc3GR-t0zht4yZ3e2nnyFl8UuTDir_0nsDbfxM,6495
171
171
  aury/boot/infrastructure/monitoring/__init__.py,sha256=KGtJU0slbRvFzzUv60LQHB12sX7eNNvGDu8Lyk9Owy8,22415
172
- aury/boot/infrastructure/monitoring/alerting/__init__.py,sha256=gBZ23JnCjqglyYTTUxfkmilZ4mY_ZkrkKMDo--3COGE,1363
172
+ aury/boot/infrastructure/monitoring/alerting/__init__.py,sha256=UvUsMhSZeGJOjZy05FnkZQmWytBlz3wiRd0y8EfZgpY,1413
173
173
  aury/boot/infrastructure/monitoring/alerting/aggregator.py,sha256=fiI-lBSqWxXv1eVPfaDNjcigX-81w41fcmhD_vN_XSs,5805
174
174
  aury/boot/infrastructure/monitoring/alerting/events.py,sha256=zJvTevQ-9JflIDyYVo1BRzOVyAGhdgEfRlMsD0NcBgM,4056
175
- aury/boot/infrastructure/monitoring/alerting/manager.py,sha256=ZcIMhBgHmrSGn8FeJOIBIiwKOcdWvT6NBm-6wvRmGc4,14525
175
+ aury/boot/infrastructure/monitoring/alerting/manager.py,sha256=vdWox9Pnjl_0IIE6w-Ne9R17IUrqtF9CPhZHwZvke6E,16044
176
176
  aury/boot/infrastructure/monitoring/alerting/rules.py,sha256=XcXJXWVrPpdZKKz63BiVWmwkKitIaNQWBfJATrSzG1M,6116
177
177
  aury/boot/infrastructure/monitoring/alerting/notifiers/__init__.py,sha256=dsfxThPHO_Ofb3Wo_dYlL8HvP_N63pb_S_UXm_qSxF8,321
178
178
  aury/boot/infrastructure/monitoring/alerting/notifiers/base.py,sha256=_RXZMzWX-YeTG0Up1U8CwK8ADfX34dd0Sh56ugfqOWM,1462
@@ -209,7 +209,7 @@ aury/boot/testing/client.py,sha256=KOg1EemuIVsBG68G5y0DjSxZGcIQVdWQ4ASaHE3o1R0,4
209
209
  aury/boot/testing/factory.py,sha256=8GvwX9qIDu0L65gzJMlrWB0xbmJ-7zPHuwk3eECULcg,5185
210
210
  aury/boot/toolkit/__init__.py,sha256=AcyVb9fDf3CaEmJPNkWC4iGv32qCPyk4BuFKSuNiJRQ,334
211
211
  aury/boot/toolkit/http/__init__.py,sha256=zIPmpIZ9Qbqe25VmEr7jixoY2fkRbLm7NkCB9vKpg6I,11039
212
- aury_boot-0.0.32.dist-info/METADATA,sha256=QlqZSaFqARK6vxLILTJn6BKGKBHejKRtO085_XZK2BE,8694
213
- aury_boot-0.0.32.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
214
- aury_boot-0.0.32.dist-info/entry_points.txt,sha256=f9KXEkDIGc0BGkgBvsNx_HMz9VhDjNxu26q00jUpDwQ,49
215
- aury_boot-0.0.32.dist-info/RECORD,,
212
+ aury_boot-0.0.33.dist-info/METADATA,sha256=pJ1jUTF2kmZXGKLj-gC0fF2i5Jj1Uq_tkRUjdqJMu-8,8694
213
+ aury_boot-0.0.33.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
214
+ aury_boot-0.0.33.dist-info/entry_points.txt,sha256=f9KXEkDIGc0BGkgBvsNx_HMz9VhDjNxu26q00jUpDwQ,49
215
+ aury_boot-0.0.33.dist-info/RECORD,,