Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 2bc3745

Browse files
stewartreichlingliyanhui1228
authored andcommitted
Document 'google-cloud-trace' and BackgroundThreadTransport (#262)
1 parent a7e7573 commit 2bc3745

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

README.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,31 @@ This example shows how to report the traces to Stackdriver Trace:
136136
project_id='your_cloud_project')
137137
tracer = tracer_module.Tracer(exporter=exporter)
138138
139+
StackdriverExporter requires the google-cloud-trace package. Install
140+
google-cloud-trace using `pip`_ or `pipenv`_:
141+
142+
::
143+
144+
pip install google-cloud-trace
145+
pipenv install google-cloud-trace
146+
147+
By default, traces are exported synchronously, which introduces latency during
148+
your code's execution. To avoid blocking code execution, you can initialize
149+
your exporter to use a background thread.
150+
151+
This example shows how to configure Census to use a background thread:
152+
153+
.. code:: python
154+
155+
from opencensus.trace.exporters import stackdriver_exporter
156+
from opencensus.trace import tracer as tracer_module
157+
from opencensus.trace.exporters.transports.background_thread \
158+
import BackgroundThreadTransport
159+
160+
exporter = stackdriver_exporter.StackdriverExporter(
161+
project_id='your_cloud_project', transport=BackgroundThreadTransport)
162+
tracer = tracer_module.Tracer(exporter=exporter)
163+
139164
Propagators
140165
~~~~~~~~~~~
141166

0 commit comments

Comments
 (0)