Base
Tracing utility
Usage Documentation
CLASS | DESCRIPTION |
---|---|
BaseProvider |
|
BaseSegment |
Holds common properties and methods on segment and subsegment. |
BaseProvider ¶
Bases: ABC
METHOD | DESCRIPTION |
---|---|
in_subsegment |
Return a subsegment context manger. |
in_subsegment_async |
Return a subsegment async context manger. |
patch |
Instrument a set of supported libraries |
patch_all |
Instrument all supported libraries |
put_annotation |
Annotate current active trace entity with a key-value pair. |
put_metadata |
Add metadata to the current active trace entity. |
in_subsegment
abstractmethod
¶
in_subsegment(
name=None, **kwargs
) -> Generator[BaseSegment, None, None]
Return a subsegment context manger.
PARAMETER | DESCRIPTION |
---|---|
name
|
Subsegment name
DEFAULT:
|
kwargs
|
Optional parameters to be propagated to segment
DEFAULT:
|
Source code in aws_lambda_powertools/tracing/base.py
87 88 89 90 91 92 93 94 95 96 97 98 |
|
in_subsegment_async
abstractmethod
¶
in_subsegment_async(
name=None, **kwargs
) -> Generator[BaseSegment, None, None]
Return a subsegment async context manger.
PARAMETER | DESCRIPTION |
---|---|
name
|
Subsegment name
DEFAULT:
|
kwargs
|
Optional parameters to be propagated to segment
DEFAULT:
|
Source code in aws_lambda_powertools/tracing/base.py
100 101 102 103 104 105 106 107 108 109 110 111 |
|
patch
abstractmethod
¶
patch(modules: Sequence[str]) -> None
Instrument a set of supported libraries
PARAMETER | DESCRIPTION |
---|---|
modules
|
Set of modules to be patched |
Source code in aws_lambda_powertools/tracing/base.py
143 144 145 146 147 148 149 150 151 |
|
patch_all
abstractmethod
¶
patch_all() -> None
Instrument all supported libraries
Source code in aws_lambda_powertools/tracing/base.py
153 154 155 |
|
put_annotation
abstractmethod
¶
put_annotation(
key: str, value: str | numbers.Number | bool
) -> None
Annotate current active trace entity with a key-value pair.
Note: Annotations will be indexed for later search query.
PARAMETER | DESCRIPTION |
---|---|
key
|
Metadata key
TYPE:
|
value
|
Annotation value |
Source code in aws_lambda_powertools/tracing/base.py
113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
put_metadata
abstractmethod
¶
put_metadata(
key: str, value: Any, namespace: str = "default"
) -> None
Add metadata to the current active trace entity.
Note: Metadata is not indexed but can be later retrieved by BatchGetTraces API.
PARAMETER | DESCRIPTION |
---|---|
key
|
Metadata key
TYPE:
|
value
|
Any object that can be serialized into a JSON string
TYPE:
|
namespace
|
Metadata namespace, by default 'default'
TYPE:
|
Source code in aws_lambda_powertools/tracing/base.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
BaseSegment ¶
Bases: ABC
Holds common properties and methods on segment and subsegment.
METHOD | DESCRIPTION |
---|---|
add_exception |
Add an exception to trace entities. |
add_subsegment |
Add input subsegment as a child subsegment. |
close |
Close the trace entity by setting |
put_annotation |
Annotate segment or subsegment with a key-value pair. |
put_metadata |
Add metadata to segment or subsegment. Metadata is not indexed |
remove_subsegment |
Remove input subsegment from child subsegments. |
add_exception
abstractmethod
¶
add_exception(
exception: BaseException,
stack: list[traceback.StackSummary],
remote: bool = False,
)
Add an exception to trace entities.
PARAMETER | DESCRIPTION |
---|---|
exception
|
Caught exception
TYPE:
|
stack
|
List of traceback summaries Output from
TYPE:
|
remote
|
Whether it's a client error (False) or downstream service error (True), by default False
TYPE:
|
Source code in aws_lambda_powertools/tracing/base.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
add_subsegment
abstractmethod
¶
add_subsegment(subsegment: Any)
Add input subsegment as a child subsegment.
Source code in aws_lambda_powertools/tracing/base.py
32 33 34 |
|
close
abstractmethod
¶
close(end_time: int | None = None)
Close the trace entity by setting end_time
and flip the in progress flag to False.
PARAMETER | DESCRIPTION |
---|---|
end_time
|
Time in epoch seconds, by default current time will be used.
TYPE:
|
Source code in aws_lambda_powertools/tracing/base.py
21 22 23 24 25 26 27 28 29 30 |
|
put_annotation
abstractmethod
¶
put_annotation(
key: str, value: str | numbers.Number | bool
) -> None
Annotate segment or subsegment with a key-value pair.
Note: Annotations will be indexed for later search query.
PARAMETER | DESCRIPTION |
---|---|
key
|
Metadata key
TYPE:
|
value
|
Annotation value |
Source code in aws_lambda_powertools/tracing/base.py
40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
put_metadata
abstractmethod
¶
put_metadata(
key: str, value: Any, namespace: str = "default"
) -> None
Add metadata to segment or subsegment. Metadata is not indexed but can be later retrieved by BatchGetTraces API.
PARAMETER | DESCRIPTION |
---|---|
key
|
Metadata key
TYPE:
|
value
|
Any object that can be serialized into a JSON string
TYPE:
|
namespace
|
Metadata namespace, by default 'default'
TYPE:
|
Source code in aws_lambda_powertools/tracing/base.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
remove_subsegment
abstractmethod
¶
remove_subsegment(subsegment: Any)
Remove input subsegment from child subsegments.
Source code in aws_lambda_powertools/tracing/base.py
36 37 38 |
|