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

Commit 0d23c69

Browse files
reyangsongy23
authored andcommitted
update the doc with TraceContextPropagator (#309)
* update the doc with TraceContextPropagator * make a real working sample * put TraceContextPropagator as a separate sample
1 parent a76bd5d commit 0d23c69

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

README.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ Propagators
169169
~~~~~~~~~~~
170170

171171
You can specify the propagator type for serializing and deserializing the
172-
``SpanContext`` and its headers. There are currently two built in propagators:
173-
``GoogleCloudFormatPropagator`` and ``TextFormatPropagator``.
172+
``SpanContext`` and its headers. There are currently three built in propagators:
173+
``GoogleCloudFormatPropagator``, ``TextFormatPropagator`` and ``TraceContextPropagator``.
174174

175175
This example shows how to use the ``GoogleCloudFormatPropagator``:
176176

@@ -186,6 +186,23 @@ This example shows how to use the ``GoogleCloudFormatPropagator``:
186186
# Serialize
187187
header = propagator.to_header(span_context)
188188
189+
This example shows how to use the ``TraceContextPropagator``:
190+
191+
.. code:: python
192+
193+
import requests
194+
195+
from opencensus.trace import config_integration
196+
from opencensus.trace.propagation.trace_context_http_header_format import TraceContextPropagator
197+
from opencensus.trace.tracer import Tracer
198+
199+
config_integration.trace_integrations(['httplib'])
200+
tracer = Tracer(propagator = TraceContextPropagator())
201+
202+
with tracer.span(name = 'parent'):
203+
with tracer.span(name = 'child'):
204+
response = requests.get('http://localhost:5000')
205+
189206
Blacklist Paths
190207
~~~~~~~~~~~~~~~
191208

0 commit comments

Comments
 (0)