azure.core.tracing package¶
Submodules¶
azure.core.tracing.common module¶
Common functions shared by both the sync and the async decorators.
-
azure.core.tracing.common.
change_context
(span)[source]¶ Execute this block inside the given context and restore it afterwards.
This does not start and ends the span, but just make sure all code is executed within that span.
If span is None, no-op.
Parameters: span (AbstractSpan) – A span Return type: contextmanager
azure.core.tracing.decorator module¶
The decorator to apply if you want the given function traced.
-
azure.core.tracing.decorator.
distributed_trace
(_func=None, name_of_span=None, **kwargs)[source]¶ Decorator to apply to function to get traced automatically.
Span will use the func name or “name_of_span”.
Parameters: - func (callable) – A function to decorate
- name_of_span (str) – The span name to replace func name if necessary
azure.core.tracing.decorator_async module¶
The decorator to apply if you want the given function traced.
-
azure.core.tracing.decorator_async.
distributed_trace_async
(_func=None, name_of_span=None, *, tracing_attributes=None)[source]¶ Decorator to apply to async function to get traced automatically.
Span will use the func name or “name_of_span”.
Parameters: - func (callable) – A function to decorate
- name_of_span (str) – The span name to replace func name if necessary
Module contents¶
-
class
azure.core.tracing.
AbstractSpan
(span=None, name=None)[source]¶ Bases:
object
Wraps a span from a distributed tracing implementation.
If a span is given wraps the span. Else a new span is created. The optional arguement name is given to the new span.
-
add_attribute
(key, value)[source]¶ Add attribute (key value pair) to the current span.
Parameters: - key (str) – The key of the key value pair
- value (str) – The value of the key value pair
-
classmethod
change_context
(span)[source]¶ Change the context for the life of this context manager.
Return type: contextmanager
-
classmethod
get_current_span
()[source]¶ Get the current span from the execution context. Return None otherwise.
-
classmethod
get_current_tracer
()[source]¶ Get the current tracer from the execution context. Return None otherwise.
-
classmethod
link
(traceparent)[source]¶ Given a traceparent, extracts the context and links the context to the current tracer.
Parameters: traceparent (str) – A string representing a traceparent
-
classmethod
link_from_headers
(headers)[source]¶ Given a dictionary, extracts the context and links the context to the current tracer.
Parameters: headers (dict) – A dictionary of the request header as key value pairs.
-
classmethod
set_current_span
(span)[source]¶ Set the given span as the current span in the execution context.
-
classmethod
set_current_tracer
(tracer)[source]¶ Set the given tracer as the current tracer in the execution context.
-
set_http_attributes
(request, response=None)[source]¶ Add correct attributes for a http client span.
Parameters: - request (HttpRequest) – The request made
- response (HttpResponse or AsyncHttpResponse) – The response received by the server. Is None if no response received.
-
span
(name='child_span')[source]¶ 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
-
classmethod
with_current_context
(func)[source]¶ Passes the current spans to the new context the function will be run in.
Parameters: func – The function that will be run in the new context Returns: The target the pass in instead of the function Return type: callable
-
span_instance
¶ Returns the span the class is wrapping.
-
-
class
azure.core.tracing.
SpanKind
[source]¶ Bases:
enum.Enum
An enumeration.
-
CLIENT
= 3¶
-
CONSUMER
= 5¶
-
INTERNAL
= 6¶
-
PRODUCER
= 4¶
-
SERVER
= 2¶
-
UNSPECIFIED
= 1¶
-
-
class
azure.core.tracing.
HttpSpanMixin
[source]¶ Bases:
object
Can be used to get HTTP span attributes settings for free.
-
set_http_attributes
(request, response=None)[source]¶ Add correct attributes for a http client span.
Parameters: - request (HttpRequest) – The request made
- response (HttpResponse or AsyncHttpResponse) – The response received by the server. Is None if no response received.
-