forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.py
More file actions
46 lines (34 loc) · 1.23 KB
/
types.py
File metadata and controls
46 lines (34 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, TypedDict, Union
if TYPE_CHECKING:
from typing_extensions import NotRequired, TypeAlias
class PowertoolsLogRecord(TypedDict):
# Base fields (required)
level: str
location: str
message: dict[str, Any] | str | bool | list[Any]
timestamp: str | int
service: str
# Fields from logger.inject_lambda_context
cold_start: NotRequired[bool]
function_name: NotRequired[str]
function_memory_size: NotRequired[int]
function_arn: NotRequired[str]
function_request_id: NotRequired[str]
# From logger.inject_lambda_context if AWS X-Ray is enabled
xray_trace_id: NotRequired[str]
# If sample_rate is defined
sampling_rate: NotRequired[float]
# From logger.set_correlation_id
correlation_id: NotRequired[str]
# Fields from logger.exception
exception_name: NotRequired[str]
exception: NotRequired[str]
stack_trace: NotRequired[dict[str, Any]]
class PowertoolsStackTrace(TypedDict):
type: str
value: str
module: str
frames: list[dict[str, Any]]
LogRecord: TypeAlias = Union[Dict[str, Any], PowertoolsLogRecord]
LogStackTrace: TypeAlias = Union[Dict[str, Any], PowertoolsStackTrace]