The LightStep distributed tracing library for Python.
apt-get install python-dev
pip install lightsteppyenvinstall2.7.15pyenvinstall3.4.9pyenvinstall3.5.6pyenvinstall3.6.6pyenvinstall3.7.0pyenvlocal2.7.153.4.9tox- Run the examples:
source .tox/py37/bin/activatepythonexamples/nontrivial/main.pyOnly required for LightStep developers
pipinstallmodernizeOnly required for LightStep developers
brewinstallprotobuf- Generating the proto code
cd ..
gitclonehttps://github.com/googleapis/googleapis.gitgitclonehttps://github.com/lightstep/lightstep-tracer-common.gitcdlightstep-tracer-pythonmakeprotoPlease see the example programs for examples of how to use this library. In particular:
- Trivial Example shows how to use the library on a single host.
- Context in Headers shows how to pass a
TraceContextthroughHTTPheaders.
Or if your python code is already instrumented for OpenTracing, you can simply switch to LightStep's implementation with:
importopentracingimportlightstepif__name__=="__main__":
opentracing.tracer=lightstep.Tracer(
component_name='your_microservice_name',
access_token='{your_access_token}')
withopentracing.tracer.start_active_span('TestSpan') asscope:
scope.span.log_event('test message', payload={'life': 42})
opentracing.tracer.flush()When using apache thrift rpc, make sure to both disable use_http by setting it to False as well as enabling use_thrift.
returnlightstep.Tracer(
...
use_http=False,
use_thrift=True)This library is the LightStep binding for OpenTracing. See the OpenTracing Python API for additional detail.