|
4 | 4 | import inspect |
5 | 5 | import sys |
6 | 6 | import traceback |
7 | | -import typing |
8 | 7 | import warnings |
9 | 8 | from functools import cached_property, partial |
10 | 9 | from time import time |
|
51 | 50 | from .metrics import ProxyMeterProvider |
52 | 51 | from .stack_info import get_user_stack_info |
53 | 52 | from .tracer import ProxyTracerProvider |
54 | | -from .utils import SysExcInfo, handle_internal_errors, log_internal_error, uniquify_sequence |
| 53 | +from .utils import handle_internal_errors, log_internal_error, uniquify_sequence |
55 | 54 |
|
56 | 55 | if TYPE_CHECKING: |
57 | 56 | import anthropic |
|
75 | 74 | from .integrations.redis import RedisInstrumentKwargs |
76 | 75 | from .integrations.sqlalchemy import SQLAlchemyInstrumentKwargs |
77 | 76 | from .integrations.starlette import StarletteInstrumentKwargs |
| 77 | + from .utils import SysExcInfo |
| 78 | + |
| 79 | + # This is the type of the exc_info/_exc_info parameter of the log methods. |
| 80 | + # sys.exc_info() returns a tuple of (type, value, traceback) or (None, None, None). |
| 81 | + # We just need the exception, but we allow the user to pass the tuple because: |
| 82 | + # 1. It's convenient to pass the result of sys.exc_info() directly |
| 83 | + # 2. It mirrors the exc_info argument of the stdlib logging methods |
| 84 | + # 3. The argument name exc_info is very suggestive of the sys function. |
| 85 | + ExcInfo = Union[SysExcInfo, BaseException, bool, None] |
78 | 86 |
|
79 | 87 | try: |
80 | 88 | from pydantic import ValidationError |
81 | 89 | except ImportError: # pragma: no cover |
82 | 90 | ValidationError = None |
83 | 91 |
|
84 | | -# This is the type of the exc_info/_exc_info parameter of the log methods. |
85 | | -# sys.exc_info() returns a tuple of (type, value, traceback) or (None, None, None). |
86 | | -# We just need the exception, but we allow the user to pass the tuple because: |
87 | | -# 1. It's convenient to pass the result of sys.exc_info() directly |
88 | | -# 2. It mirrors the exc_info argument of the stdlib logging methods |
89 | | -# 3. The argument name exc_info is very suggestive of the sys function. |
90 | | -ExcInfo: typing.TypeAlias = Union[SysExcInfo, BaseException, bool, None] |
91 | | - |
92 | 92 |
|
93 | 93 | class Logfire: |
94 | 94 | """The main logfire class.""" |
|
0 commit comments