azure.core.tracing.ext.opentelemetry_span package¶
Implements azure.core.tracing.AbstractSpan to wrap OpenTelemetry spans.
-
class
azure.core.tracing.ext.opentelemetry_span.
OpenTelemetrySpan
(span=None, name='span')[source]¶ OpenTelemetry plugin for Azure client libraries.
- Parameters
span (Span) – The OpenTelemetry span to wrap, or nothing to create a new one.
name (str) – The name of the OpenTelemetry span to create if a new span is needed
-
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.
-
get_trace_parent
()[source]¶ Return traceparent string as defined in W3C trace context specification.
Example: Value = 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01 base16(version) = 00 base16(trace-id) = 4bf92f3577b34da6a3ce929d0e0e4736 base16(parent-id) = 00f067aa0ba902b7 base16(trace-flags) = 01 // sampled
- Returns
a traceparent string
- Return type
-
classmethod
link
(traceparent)[source]¶ Links the context to the current tracer.
- Parameters
traceparent (str) – A complete 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 key value pair dictionary
-
classmethod
set_current_tracer
(_)[source]¶ Set the given tracer as the current tracer in the execution context. :param tracer: The tracer to set the current tracer as :type tracer: :class: OpenTelemetry.trace.Tracer
-
set_http_attributes
(request, response=None)¶ 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='span')[source]¶ Create a child span for the current span and append it to the child spans list in the span instance. :param name: Name of the child span :type name: str :return: The OpenCensusSpan that is wrapping the child span instance
-
to_header
()[source]¶ Returns a dictionary with the header labels and values. :return: A key value pair dictionary
-
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
-
property
kind
¶ Get the span kind of this span.
-
property
span_instance
¶ The OpenTelemetry span that is being wrapped.
- Type
return