Skip to content

The Lightstep distributed tracing library for Python

License

Notifications You must be signed in to change notification settings

lightstep/lightstep-tracer-python

This branch is 1 commit ahead of master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

798f5f0 · Aug 2, 2024
Apr 21, 2020
May 19, 2020
Aug 22, 2019
Feb 8, 2016
Oct 31, 2019
Sep 22, 2020
Oct 4, 2016
Sep 18, 2020
Nov 27, 2019
Sep 18, 2020
Dec 12, 2019
Aug 2, 2024
Mar 23, 2016
Apr 21, 2020
Aug 29, 2022
Sep 8, 2020
Sep 22, 2020
Apr 9, 2016
Oct 1, 2016
Oct 1, 2016
Apr 9, 2016
Sep 22, 2020
Apr 21, 2020

Repository files navigation

lightstep-tracer-python

This instrumentation is no longer recommended. Please review documentation on setting up and configuring the OpenTelemetry Python Launcher for more information on migrating to OpenTelemetry.

PyPI Circle CI MIT license

The LightStep distributed tracing library for Python.

Installation

apt-get install python-dev
pip install lightstep

Developer Setup

Prerequisites

pyenv install 2.7.15
pyenv install 3.4.9
pyenv install 3.5.6
pyenv install 3.6.6
pyenv install 3.7.0
pyenv local 2.7.15 3.4.9
tox
  • Run the examples:
source .tox/py37/bin/activate
python examples/nontrivial/main.py

Only required for LightStep developers

pip install modernize

Only required for LightStep developers

brew install protobuf
  • Generating the proto code
cd ..
git clone https://github.com/googleapis/googleapis.git
git clone https://github.com/lightstep/lightstep-tracer-common.git
cd lightstep-tracer-python
make proto

Getting Started with Tracing

Please see the example programs for examples of how to use this library. In particular:

Or if your python code is already instrumented for OpenTracing, you can simply switch to LightStep's implementation with:

import opentracing
import lightstep

if __name__ == "__main__":
  opentracing.tracer = lightstep.Tracer(
    component_name='your_microservice_name',
    access_token='{your_access_token}')

  with opentracing.tracer.start_active_span('TestSpan') as scope:
    scope.span.log_event('test message', payload={'life': 42})

  opentracing.tracer.flush()

Thrift

When using apache thrift rpc, make sure to both disable use_http by setting it to False as well as enabling use_thrift.

return lightstep.Tracer(
    ...
    use_http=False,
    use_thrift=True)

This library is the LightStep binding for OpenTracing. See the OpenTracing Python API for additional detail.