Request Tracer¶
-
class
opencensus.trace.tracer.
Tracer
(span_context=None, sampler=None, exporter=None, propagator=None)[source]¶ Bases:
object
The Tracer is for tracing a request for web applications.
- Parameters
span_context (
SpanContext
) -- SpanContext encapsulates the current context within the request's trace.sampler (
Sampler
) -- Instances of Sampler objects. Defaults toProbabilitySampler
. Other options includeAlwaysOnSampler
andAlwaysOffSampler
.exporter (
exporter
) -- Instances of exporter objects. Default toPrintexporter
. The rest options areFileexporter
,Printexporter
,Loggingexporter
,Zipkinexporter
,GoogleCloudexporter
-
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.
-
end_span
()[source]¶ End a span. Update the span_id in SpanContext to the current span's parent span id; Update the current span; Send the span to exporter.
-
should_sample
()[source]¶ Determine whether to sample this request or not. If the context enables tracing, return True. Else follow the decision of the sampler.
- Return type
bool
- Returns
Whether to trace the request or not.