@@ -122,10 +122,11 @@ and ``ProbabilitySampler``
122122 Exporters
123123~~~~~~~~~
124124
125- You can choose different exporters to send the traces to. By default,
126- the traces are printed to stdout in JSON format. Other options include
127- writing to a file, sending to Python logging, or reporting to
128- Stackdriver.
125+ By default, the traces are printed to stdout in JSON format. You can choose
126+ different exporters to send the traces to. There are three built-in exporters,
127+ which are ``opencensus.trace.print_exporter ``, ``opencensus.trace.file_exporter ``
128+ and ``opencensus.trace.logging_exporter ``, other exporters are provided as
129+ `extensions <#trace-exporter >`__.
129130
130131This example shows how to configure OpenCensus to save the traces to a
131132file:
@@ -138,41 +139,6 @@ file:
138139 exporter = file_exporter.FileExporter(file_name = ' traces' )
139140 tracer = context_tracer.ContextTracer(exporter = exporter)
140141
141- This example shows how to report the traces to Stackdriver Trace:
142-
143- .. code :: python
144-
145- from opencensus.ext.stackdriver import trace_exporter as stackdriver_exporter
146- from opencensus.trace import tracer as tracer_module
147-
148- exporter = stackdriver_exporter.StackdriverExporter(
149- project_id = ' your_cloud_project' )
150- tracer = tracer_module.Tracer(exporter = exporter)
151-
152- StackdriverExporter requires the google-cloud-trace package. Install
153- google-cloud-trace using `pip `_ or `pipenv `_:
154-
155- ::
156-
157- pip install google-cloud-trace
158- pipenv install google-cloud-trace
159-
160- By default, traces are exported synchronously, which introduces latency during
161- your code's execution. To avoid blocking code execution, you can initialize
162- your exporter to use a background thread.
163-
164- This example shows how to configure OpenCensus to use a background thread:
165-
166- .. code :: python
167-
168- from opencensus.common.transports.async_ import AsyncTransport
169- from opencensus.ext.stackdriver import trace_exporter as stackdriver_exporter
170- from opencensus.trace import tracer as tracer_module
171-
172- exporter = stackdriver_exporter.StackdriverExporter(
173- project_id = ' your_cloud_project' , transport = AsyncTransport)
174- tracer = tracer_module.Tracer(exporter = exporter)
175-
176142 Propagators
177143~~~~~~~~~~~
178144
@@ -205,10 +171,10 @@ This example shows how to use the ``TraceContextPropagator``:
205171 from opencensus.trace.tracer import Tracer
206172
207173 config_integration.trace_integrations([' httplib' ])
208- tracer = Tracer(propagator = TraceContextPropagator())
174+ tracer = Tracer(propagator = TraceContextPropagator())
209175
210- with tracer.span(name = ' parent' ):
211- with tracer.span(name = ' child' ):
176+ with tracer.span(name = ' parent' ):
177+ with tracer.span(name = ' child' ):
212178 response = requests.get(' http://localhost:5000' )
213179
214180 Blacklist Paths
@@ -217,7 +183,7 @@ Blacklist Paths
217183You can specify which paths you do not want to trace by configuring the
218184blacklist paths.
219185
220- This example shows how to configure the blacklist to ignore the `_ah/health ` endpoint
186+ This example shows how to configure the blacklist to ignore the `` _ah/health ` ` endpoint
221187for a Flask application:
222188
223189.. code :: python
@@ -242,6 +208,10 @@ For Django, you can configure the blacklist in the ``OPENCENSUS_TRACE_PARAMS`` i
242208 .. note :: By default, the health check path for the App Engine flexible environment is not traced,
243209 but you can turn it on by excluding it from the blacklist setting.
244210
211+ ------------
212+ Extensions
213+ ------------
214+
245215Integration
246216-----------
247217
@@ -261,137 +231,38 @@ OpenCensus supports integration with popular web frameworks, client libraries an
261231- `SQLAlchemy `_
262232- `threading `_
263233
234+ Trace Exporter
235+ --------------
236+
237+ - `Jaeger `_
238+ - `OCAgent `_
239+ - `Stackdriver `_
240+ - `Zipkin `_
241+
242+ Stats Exporter
243+ --------------
244+
245+ - `Prometheus `_
246+ - `Stackdriver `_
247+
264248.. _Django : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-django
265249.. _Flask : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-flask
266250.. _Google Cloud Client Libraries : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-google-cloud-clientlibs
267251.. _gRPC : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-grpc
268252.. _httplib : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-httplib
253+ .. _Jaeger : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-jaeger
269254.. _MySQL : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-mysql
255+ .. _OCAgent : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-ocagent
270256.. _PostgreSQL : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-postgresql
257+ .. _Prometheus : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-prometheus
271258.. _pymongo : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-pymongo
272259.. _PyMySQL : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-pymysql
273260.. _Pyramid : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-pyramid
274261.. _requests : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-requests
275262.. _SQLAlchemy : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-sqlalchemy
263+ .. _Stackdriver : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-stackdriver
276264.. _threading : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-threading
277-
278- ------
279- Stats
280- ------
281-
282- Stackdriver Stats
283- -----------------
284-
285- The OpenCensus Stackdriver Stats Exporter allows users
286- to export metrics to Stackdriver Monitoring.
287- The API of this project is still evolving.
288- The use of vendoring or a dependency management tool is recommended.
289-
290- .. _Stackdriver : https://app.google.stackdriver.com/metrics-explorer
291-
292- Stackdriver Exporter Usage
293- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
294-
295- Stackdriver Import
296- ************************
297-
298- .. code :: python
299-
300- from opencensus.stats.exporters import stackdriver_exporter as stackdriver
301- from opencensus.stats import stats as stats_module
302-
303- Stackdriver Prerequisites
304- **************************
305-
306- - OpenCensus Python libraries require Python 2.7 or later.
307- - Google Cloud Platform account and project.
308- - Google Stackdriver Monitoring enabled on your project (Need help? `Click here `_).
309-
310- .. _Click here : https://opencensus.io/codelabs/stackdriver
311-
312- Register the Stackdriver exporter
313- **********************************
314-
315- .. code :: python
316-
317- stats = stats_module.Stats()
318- view_manager = stats.view_manager
319-
320- exporter = stackdriver.new_stats_exporter(stackdriver.Options(project_id = " <id_value>" ))
321- view_manager.register_exporter(exporter)
322- ...
323-
324-
325- Stackdriver Code Reference
326- ******************************
327-
328- In the *examples * folder, you can find all the necessary steps to get the exporter, register a view, put tags on the measure, and see the values against the Stackdriver monitoring tool once you have defined the *project_id *.
329-
330- For further details for the Stackdriver implementation, see the file *stackdriver_exporter.py *.
331-
332- +----------------------------------------------------+-------------------------------------+
333- | Path & File | Short Description |
334- +====================================================+=====================================+
335- | examples/stats/exporter/stackdriver.py | End to end example |
336- +----------------------------------------------------+-------------------------------------+
337- | opencensus/stats/exporters/stackdriver_exporter.py | Stats implementation for Stackdriver|
338- +----------------------------------------------------+-------------------------------------+
339-
340- Prometheus Stats
341- -----------------
342-
343- The OpenCensus `Prometheus `_ Stats Exporter allows users
344- to export metrics to Prometheus monitoring solution.
345- The API of this project is still evolving.
346- The use of vendoring or a dependency management tool is recommended.
347-
348- .. _Prometheus : https://prometheus.io/
349-
350- Prometheus Exporter Usage
351- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
352-
353- Prometheus Import
354- ********************
355-
356- .. code :: python
357-
358- from opencensus.stats.exporters import prometheus_exporter as prometheus
359- from opencensus.stats import stats as stats_module
360-
361- Prometheus Prerequisites
362- ***************************
363-
364- - OpenCensus Python libraries require Python 2.7 or later.
365- - Prometheus up and running.
366-
367- Register the Prometheus exporter
368- ***********************************
369-
370- .. code :: python
371-
372- stats = stats_module.Stats()
373- view_manager = stats.view_manager
374-
375- exporter = prometheus.new_stats_exporter(prometheus.Options(namespace = " <namespace>" ))
376- view_manager.register_exporter(exporter)
377- ...
378-
379-
380- Prometheus Code Reference
381- ***************************
382-
383- In the *examples * folder, you can find all the necessary steps to get the exporter, register a view, put tags on the measure, and see the values against the Prometheus monitoring tool.
384-
385- For further details for the Prometheus implementation, see the file *prometheus_exporter.py *.
386-
387-
388- +----------------------------------------------------+-------------------------------------+
389- | Path & File | Short Description |
390- +====================================================+=====================================+
391- | examples/stats/exporter/prometheus.py | End to end example |
392- +----------------------------------------------------+-------------------------------------+
393- | opencensus/stats/exporters/prometheus_exporter.py | Stats implementation for Prometheus |
394- +----------------------------------------------------+-------------------------------------+
265+ .. _Zipkin : https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-zipkin
395266
396267------------------
397268 Additional Info
0 commit comments