Context Tracer

class opencensus.trace.tracers.context_tracer.ContextTracer(exporter=None, span_context=None)[source]

Bases: opencensus.trace.tracers.base.Tracer

The interface for tracing a request context.

Parameters

span_context (SpanContext) -- SpanContext encapsulates the current context within the request's trace.

add_attribute_to_current_span(attribute_key, attribute_value)[source]

Add attribute to current span.

Parameters

attribute_key (str) -- Attribute key.

:type attribute_value:str :param attribute_value: Attribute value.

current_span()[source]

Return the current span.

end_span(*args, **kwargs)[source]

End a span. Update the span_id in SpanContext to the current span's parent span id; Update the current span.

finish()[source]

Finish all spans

Return type

dict

Returns

JSON format trace.

get_span_datas(span)[source]

Extracts a list of SpanData tuples from a span

Return type

list of opencensus.trace.span_data.SpanData

:return list of SpanData tuples

list_collected_spans()[source]

List collected spans.

span(name='span')[source]

Create a new span with the trace using the context information.

Parameters

name (str) -- The name of the span.

Return type

Span

Returns

The Span object.

start_span(name='span')[source]

Start a span.

Parameters

name (str) -- The name of the span.

Return type

Span

Returns

The Span object.