Span handlers
BaseSpanHandler #
Bases: BaseModel
, Generic[T]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
completed_spans
|
List[TypeVar]
|
List of completed spans. |
<dynamic>
|
dropped_spans
|
List[TypeVar]
|
List of completed spans. |
<dynamic>
|
current_span_ids
|
Dict[Any, Optional[str]]
|
Id of current spans in a given thread. |
{}
|
Source code in llama_index_instrumentation/span_handlers/base.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
class_name
classmethod
#
class_name() -> str
Class name.
Source code in llama_index_instrumentation/span_handlers/base.py
77 78 79 80 |
|
span_enter #
span_enter(id_: str, bound_args: BoundArguments, instance: Optional[Any] = None, parent_id: Optional[str] = None, tags: Optional[Dict[str, Any]] = None, **kwargs: Any) -> None
Logic for entering a span.
Source code in llama_index_instrumentation/span_handlers/base.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
span_exit #
span_exit(id_: str, bound_args: BoundArguments, instance: Optional[Any] = None, result: Optional[Any] = None, **kwargs: Any) -> None
Logic for exiting a span.
Source code in llama_index_instrumentation/span_handlers/base.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
span_drop #
span_drop(id_: str, bound_args: BoundArguments, instance: Optional[Any] = None, err: Optional[BaseException] = None, **kwargs: Any) -> None
Logic for dropping a span i.e. early exit.
Source code in llama_index_instrumentation/span_handlers/base.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
new_span
abstractmethod
#
new_span(id_: str, bound_args: BoundArguments, instance: Optional[Any] = None, parent_span_id: Optional[str] = None, tags: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Optional[T]
Create a span.
Subclasses of BaseSpanHandler should create the respective span type T and return it. Only NullSpanHandler should return a None here.
Source code in llama_index_instrumentation/span_handlers/base.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
prepare_to_exit_span
abstractmethod
#
prepare_to_exit_span(id_: str, bound_args: BoundArguments, instance: Optional[Any] = None, result: Optional[Any] = None, **kwargs: Any) -> Optional[T]
Logic for preparing to exit a span.
Subclasses of BaseSpanHandler should return back the specific span T that is to be exited. If None is returned, then the span won't actually be exited.
Source code in llama_index_instrumentation/span_handlers/base.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
prepare_to_drop_span
abstractmethod
#
prepare_to_drop_span(id_: str, bound_args: BoundArguments, instance: Optional[Any] = None, err: Optional[BaseException] = None, **kwargs: Any) -> Optional[T]
Logic for preparing to drop a span.
Subclasses of BaseSpanHandler should return back the specific span T that is to be dropped. If None is returned, then the span won't actually be dropped.
Source code in llama_index_instrumentation/span_handlers/base.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
SimpleSpanHandler #
Bases: BaseSpanHandler[SimpleSpan]
Span Handler that manages SimpleSpan's.
Source code in llama_index_instrumentation/span_handlers/simple.py
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
class_name #
class_name() -> str
Class name.
Source code in llama_index_instrumentation/span_handlers/simple.py
18 19 20 |
|
new_span #
new_span(id_: str, bound_args: BoundArguments, instance: Optional[Any] = None, parent_span_id: Optional[str] = None, tags: Optional[Dict[str, Any]] = None, **kwargs: Any) -> SimpleSpan
Create a span.
Source code in llama_index_instrumentation/span_handlers/simple.py
22 23 24 25 26 27 28 29 30 31 32 |
|
prepare_to_exit_span #
prepare_to_exit_span(id_: str, bound_args: BoundArguments, instance: Optional[Any] = None, result: Optional[Any] = None, **kwargs: Any) -> SimpleSpan
Logic for preparing to drop a span.
Source code in llama_index_instrumentation/span_handlers/simple.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
prepare_to_drop_span #
prepare_to_drop_span(id_: str, bound_args: BoundArguments, instance: Optional[Any] = None, err: Optional[BaseException] = None, **kwargs: Any) -> Optional[SimpleSpan]
Logic for droppping a span.
Source code in llama_index_instrumentation/span_handlers/simple.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
print_trace_trees #
print_trace_trees() -> None
Method for viewing trace trees.
Source code in llama_index_instrumentation/span_handlers/simple.py
144 145 146 147 148 149 |
|