|
| 1 | +from _typeshed import Incomplete |
1 | 2 | from logging import Logger |
2 | 3 | from traceback import StackSummary |
3 | | -from typing import Any |
| 4 | +from typing import Any, Final, Literal, overload |
| 5 | + |
| 6 | +from .subsegment import Subsegment |
| 7 | +from .throwable import Throwable |
4 | 8 |
|
5 | 9 | log: Logger |
6 | | -ORIGIN_TRACE_HEADER_ATTR_KEY: str |
| 10 | +ORIGIN_TRACE_HEADER_ATTR_KEY: Final[str] |
7 | 11 |
|
8 | 12 | class Entity: |
9 | | - id: Any |
10 | | - name: Any |
11 | | - start_time: Any |
12 | | - parent_id: Any |
| 13 | + id: str |
| 14 | + name: str |
| 15 | + start_time: float |
| 16 | + parent_id: str | None |
13 | 17 | sampled: bool |
14 | 18 | in_progress: bool |
15 | | - http: Any |
16 | | - annotations: Any |
17 | | - metadata: Any |
18 | | - aws: Any |
19 | | - cause: Any |
20 | | - subsegments: Any |
21 | | - end_time: Any |
22 | | - def __init__(self, name, entity_id=None) -> None: ... |
23 | | - def close(self, end_time=None) -> None: ... |
24 | | - def add_subsegment(self, subsegment) -> None: ... |
25 | | - def remove_subsegment(self, subsegment) -> None: ... |
26 | | - def put_http_meta(self, key, value) -> None: ... |
27 | | - def put_annotation(self, key, value) -> None: ... |
28 | | - def put_metadata(self, key, value, namespace: str = "default") -> None: ... |
| 19 | + http: dict[str, dict[str, str | int]] |
| 20 | + annotations: dict[str, float | str | bool] |
| 21 | + metadata: dict[str, dict[str, Any]] # value is any object that can be serialized into JSON string |
| 22 | + aws: dict[str, Incomplete] |
| 23 | + cause: dict[str, str | list[Throwable]] |
| 24 | + subsegments: list[Subsegment] |
| 25 | + end_time: float |
| 26 | + def __init__(self, name: str, entity_id: str | None = None) -> None: ... |
| 27 | + def close(self, end_time: float | None = None) -> None: ... |
| 28 | + def add_subsegment(self, subsegment: Subsegment) -> None: ... |
| 29 | + def remove_subsegment(self, subsegment: Subsegment) -> None: ... |
| 30 | + @overload |
| 31 | + def put_http_meta(self, key: Literal["status", "content_length"], value: int) -> None: ... |
| 32 | + @overload |
| 33 | + def put_http_meta(self, key: Literal["url", "method", "user_agent", "client_ip", "x_forwarded_for"], value: str) -> None: ... |
| 34 | + def put_annotation(self, key: str, value: float | str | bool) -> None: ... |
| 35 | + def put_metadata( |
| 36 | + self, key: str, value: Any, namespace: str = "default" # value is any object that can be serialized into JSON string |
| 37 | + ) -> None: ... |
29 | 38 | def set_aws(self, aws_meta) -> None: ... |
30 | 39 | throttle: bool |
31 | 40 | def add_throttle_flag(self) -> None: ... |
32 | 41 | fault: bool |
33 | 42 | def add_fault_flag(self) -> None: ... |
34 | 43 | error: bool |
35 | 44 | def add_error_flag(self) -> None: ... |
36 | | - def apply_status_code(self, status_code) -> None: ... |
| 45 | + def apply_status_code(self, status_code: int | None) -> None: ... |
37 | 46 | def add_exception(self, exception: Exception, stack: StackSummary, remote: bool = False) -> None: ... |
38 | 47 | def save_origin_trace_header(self, trace_header) -> None: ... |
39 | 48 | def get_origin_trace_header(self): ... |
40 | | - def serialize(self): ... |
41 | | - def to_dict(self): ... |
| 49 | + def serialize(self) -> str: ... |
| 50 | + def to_dict(self) -> dict[str, Incomplete]: ... |
0 commit comments