@@ -21,7 +21,6 @@ Installation
2121 from opencensus.trace import request_tracer
2222
2323 tracer = request_tracer.RequestTracer()
24- tracer.start_trace()
2524
2625 Usage
2726-----
@@ -39,9 +38,8 @@ Usage 1: ``with`` statement (Recommended)
3938
4039 from opencensus.trace import request_tracer
4140
42- # Initialize a tracer, by default using the `PrintReporter `
41+ # Initialize a tracer, by default using the `PrintExporter `
4342 tracer = request_tracer.RequestTracer()
44- tracer.start_trace()
4543
4644 # Example for creating nested spans
4745 with tracer.span(name = ' span1' ) as span1:
@@ -53,8 +51,7 @@ Usage 1: ``with`` statement (Recommended)
5351 with tracer.span(name = ' span2' ) as span2:
5452 do_something_to_trace()
5553
56- # The trace spans will be sent to the reporter when you call `end_trace()`
57- tracer.end_trace()
54+ # The spans will be exported when exiting the with block.
5855
5956 Usage 2: Explicitly start and end spans
6057~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -63,7 +60,7 @@ Usage 2: Explicitly start and end spans
6360
6461 from opencensus.trace import request_tracer
6562
66- # Initialize a tracer, by default using the `PrintReporter `
63+ # Initialize a tracer, by default using the `PrintExporter `
6764 tracer = request_tracer.RequestTracer()
6865 tracer.start_trace()
6966
@@ -79,44 +76,44 @@ Samplers
7976
8077You can specify different samplers when initializing a tracer, default
8178is using ``AlwaysOnSampler ``, the other options are ``AlwaysOffSampler ``
82- and ``FixedRateSampler ``
79+ and ``ProbabilitySampler ``
8380
8481.. code :: python
8582
86- from opencensus.trace.samplers import fixed_rate
83+ from opencensus.trace.samplers import probability
8784 from opencensus.trace import request_tracer
8885
8986 # Sampling the requests at the rate equals 0.5
90- sampler = fixed_rate.FixedRateSampler (rate = 0.5 )
87+ sampler = probability.ProbabilitySampler (rate = 0.5 )
9188 tracer = request_tracer.RequestTracer(sampler = sampler)
9289
93- Reporters
90+ Exporters
9491~~~~~~~~~
9592
96- You can choose different reporters to send the traces to. Default is
93+ You can choose different exporters to send the traces to. Default is
9794printing the traces in JSON format. The rest options are sending to
98- logging, or write to a file. Will add reporters to report to different
95+ logging, or write to a file. Will add exporters to report to different
9996trace backend later.
10097
10198.. code :: python
10299
103- from opencensus.trace.reporters import file_reporter
100+ from opencensus.trace.exporters import file_exporter
104101 from opencensus.trace.tracer import context_tracer
105102
106103 # Export the traces to a local file
107- reporter = file_reporter.FileReporter (file_name = ' traces' )
108- tracer = context_tracer.ContextTracer(reporter = reporter )
104+ exporter = file_exporter.FileExporter (file_name = ' traces' )
105+ tracer = context_tracer.ContextTracer(exporter = exporter )
109106
110107 Report to Stackdriver Trace:
111108
112109.. code :: python
113110
114- from opencensus.trace.reporters import google_cloud_reporter
111+ from opencensus.trace.exporters import stackdriver_exporter
115112 from opencensus.trace import request_tracer
116113
117- reporter = google_cloud_reporter.GoogleCloudReporter (
114+ exporter = stackdriver_exporter.StackdriverExporter (
118115 project_id = ' your_cloud_project' )
119- tracer = request_tracer.RequestTracer(reporter = reporter )
116+ tracer = request_tracer.RequestTracer(exporter = exporter )
120117
121118 Propagators
122119~~~~~~~~~~~
@@ -158,8 +155,8 @@ requests will be automatically traced.
158155
159156 app = flask.Flask(__name__ )
160157
161- # You can also specify the sampler, reporter , propagator in the middleware,
162- # default is using `AlwaysOnSampler` as sampler, `PrintReporter ` as reporter ,
158+ # You can also specify the sampler, exporter , propagator in the middleware,
159+ # default is using `AlwaysOnSampler` as sampler, `PrintExporter ` as exporter ,
163160 # `GoogleCloudFormatPropagator` as propagator.
164161 middleware = FlaskMiddleware(app)
165162
@@ -179,13 +176,13 @@ Add this line to the ``INSTALLED_APPS`` section:
179176
180177 'opencensus.trace.ext.django',
181178
182- Customize the sampler, reporter , propagator in the ``settings.py `` file:
179+ Customize the sampler, exporter , propagator in the ``settings.py `` file:
183180
184181::
185182
186183 OPENCENSUS_TRACE = {
187- 'SAMPLER': 'opencensus.trace.samplers.fixed_rate.FixedRateSampler ',
188- 'REPORTER': 'opencensus.trace.reporters.print_reporter.PrintReporter ',
184+ 'SAMPLER': 'opencensus.trace.samplers.probability.ProbabilitySampler ',
185+ 'REPORTER': 'opencensus.trace.exporters.print_exporter.PrintExporter ',
189186 'PROPAGATOR': 'opencensus.trace.propagation.google_cloud_format.'
190187 'GoogleCloudFormatPropagator',
191188 }
@@ -200,13 +197,10 @@ Webapp2
200197 from opencensus.trace.tracer import webapp2_tracer
201198
202199 tracer = webapp2_tracer.WebApp2Tracer()
203- tracer.start_trace()
204200
205201 with tracer.span(name = ' span1' ):
206202 do_something_to_trace()
207203
208- tracer.end_trace()
209-
210204 Service Integration
211205-------------------
212206
@@ -226,15 +220,12 @@ want to instrument. Usage for enabling MySQL instrumentation like below:
226220 config_integration.trace_integrations(INTEGRATIONS )
227221
228222 tracer = request_tracer.RequestTracer()
229- tracer.start_trace()
230223
231224 conn = mysql.connector.connect(user = ' user' , password = ' password' )
232225 cursor = conn.cursor()
233226 query = ' SELECT 2*3'
234227 cursor.execute(query)
235228
236- tracer.end_trace()
237-
238229 MySQL
239230~~~~~
240231
@@ -294,7 +285,6 @@ integration with requests module.
294285
295286 # Create a tracer
296287 tracer = RequestTracer()
297- tracer.start_trace()
298288
299289 # Integrate with requests module
300290 trace_integrations([' requests' ])
0 commit comments