OpenCensusSpan Class
Wraps a given OpenCensus Span so that it implements azure.core.tracing.AbstractSpan
- Inheritance
-
azure.core.tracing._abstract_span.HttpSpanMixinOpenCensusSpanbuiltins.objectOpenCensusSpan
Constructor
OpenCensusSpan(span: Optional[Span] = None, name: Optional[str] = 'span', **kwargs: Any)
Parameters
- span
- name
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 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 |
| link |
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. :param tracer: The tracer to set the current tracer as :type tracer: :class: opencensus.trace.Tracer |
| span |
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 :keyword SpanKind kind: The span kind of this span. :keyword links: The list of links to be added to the span. :paramtype links: list[~azure.core.tracing.Link] :return: The OpenCensusSpan that is wrapping the child span instance |
| start |
Set the start time for a span. |
| to_header |
Returns a dictionary with the header labels and values. :return: A key value pair dictionary |
| 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: Span) -> ContextManager
Parameters
- cls
- span
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() -> opencensus.trace.span.Span
Parameters
- cls
get_current_tracer
Get the current tracer from the execution context. Return None otherwise.
get_current_tracer() -> opencensus.trace.tracer.Tracer
Parameters
- cls
get_trace_parent
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
get_trace_parent()
Returns
a traceparent string
Return type
link
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: opencensus.trace.span.Span) -> None
Parameters
- span
The span to set the current span as
- span
set_current_tracer
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: opencensus.trace.Tracer
set_current_tracer(tracer: opencensus.trace.tracer.Tracer) -> None
Parameters
- cls
- tracer
span
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 :keyword SpanKind kind: The span kind of this span. :keyword links: The list of links to be added to the span. :paramtype links: list[~azure.core.tracing.Link] :return: The OpenCensusSpan that is wrapping the child span instance
span(name: Optional[str] = 'span', **kwargs: Any) -> OpenCensusSpan
Parameters
- name
start
Set the start time for a span.
start() -> None
to_header
Returns a dictionary with the header labels and values. :return: A key value pair dictionary
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
Attributes
kind
Get the span kind of this span.
span_instance
The OpenCensus span that is being wrapped.
Feedback
Submit and view feedback for