AbstractSpan Class
Wraps a span from a distributed tracing implementation.
- Inheritance
-
AbstractSpan
Constructor
AbstractSpan(*args, **kwargs)
Methods
| add_attribute |
Add attribute (key value pair) to the current span. |
| change_context |
Change the context for the life of this context manager. |
| finish |
Set the end time for a span. |
| get_current_span |
Get the current span from the execution context. Return None otherwise. |
| get_current_tracer |
Get the current tracer from the execution context. Return None otherwise. |
| get_trace_parent |
Return traceparent string. |
| link |
Given a traceparent, extracts the context and links the context to the current tracer. |
| link_from_headers |
Given a dictionary, extracts the context and links the context to the current tracer. |
| set_current_span |
Set the given span as the current span in the execution context. |
| set_current_tracer |
Set the given tracer as the current tracer in the execution context. |
| set_http_attributes |
Add correct attributes for a http client span. |
| span |
Create a child span for the current span and append it to the child spans list. The child span must be wrapped by an implementation of AbstractSpan |
| start |
Set the start time for a span. |
| to_header |
Returns a dictionary with the header labels and values. |
| with_current_context |
Passes the current spans to the new context the function will be run in. |
add_attribute
Add attribute (key value pair) to the current span.
add_attribute(key: str, value: Union[str, int]) -> None
Parameters
change_context
Change the context for the life of this context manager.
change_context(span: AbstractSpan) -> ContextManager
Parameters
- cls
- span
Return type
finish
Set the end time for a span.
finish() -> None
get_current_span
Get the current span from the execution context. Return None otherwise.
get_current_span() -> Any
Parameters
- cls
get_current_tracer
Get the current tracer from the execution context. Return None otherwise.
get_current_tracer() -> Any
Parameters
- cls
get_trace_parent
link
Given a traceparent, extracts the context and links the context to the current tracer.
link(traceparent: str, attributes: Attributes = None) -> None
Parameters
- traceparent
- attributes
link_from_headers
Given a dictionary, extracts the context and links the context to the current tracer.
link_from_headers(headers: Dict[str, str], attributes: Attributes = None) -> None
Parameters
- headers
- attributes
set_current_span
Set the given span as the current span in the execution context.
set_current_span(span: Any) -> None
Parameters
- cls
- span
set_current_tracer
Set the given tracer as the current tracer in the execution context.
set_current_tracer(tracer: Any) -> None
Parameters
- cls
- tracer
set_http_attributes
Add correct attributes for a http client span.
set_http_attributes(request: HttpRequest, response: Optional[HttpResponseType] = None) -> None
Parameters
- response
- HttpResponse or AsyncHttpResponse
The response received by the server. Is None if no response received.
span
Create a child span for the current span and append it to the child spans list. The child span must be wrapped by an implementation of AbstractSpan
span(name: Optional[str] = 'child_span', **kwargs: Any) -> AbstractSpan
Parameters
- name
start
Set the start time for a span.
start() -> None
to_header
Returns a dictionary with the header labels and values.
to_header() -> Dict[str, str]
with_current_context
Passes the current spans to the new context the function will be run in.
with_current_context(func: Callable) -> Callable
Parameters
- func
The function that will be run in the new context
- func
Returns
The target the pass in instead of the function
Return type
Attributes
kind
span_instance
Returns the span the class is wrapping.
Feedback
Submit and view feedback for