Skip to main content

Add logs and snapshots (virtual breakpoints) to live applications - without stopping them.

Project description

Lightrun for Python

Lightrun is a developer-native observabity platform. It's a way to add logs, inspect the state of the current execution (in a familiar, debugger-like view), and extract any type of code-level metric on the fly - without redeploying, restarting or even stopping the running application.

Check out our docs to learn more.

Getting Started

To get started with Lightrun you'll need three things:

  1. A Lightrun Account - you can get one here.
  2. A Lightrun Plugin - you'll have instructions to download it once you create an account, but you can also check them out here.
  3. A Lightrun Agent - which is this very PyPI package! It's the thing that actually does the magic.

Once you've signed up for an account and downloaded the plugin, you can install the agent in your application.

Installing the Lightrun Agent - Directly

In order to install the Lightrun Python Agent please follow these steps:

  1. Install the python agent by running python -m pip install lightrun.

  2. Add the following code to the beginning of your main function:

try:
    import lightrun
    lightrun.enable(company_key='<COMPANY_SECRET>')
except ImportError as e:
    print("Error importing Lightrun: ", e)

You will have a <COMPANY-SECRET> auto-generated for you during the onboarding process, right after signing up for an account.

  1. Run the application as you normally would, i.e. python app.py.

You should see the application's agent popping up in the Lightrun Plugin's sidebar - you can now add logs, snapshots and metrics to your application.

Providing Credentials Via Program Arguments

You can optionally choose to provide the <COMPANY-SECRET> as program argument. To do so, run your application in the following way:

python -m lightrun --company_key='<COMAPNY-SECRET>' -- app.py

Notice - The method above won't work well with applications based on gunicorn or any other multiprocessing libraries, as the debugger won't attach to the spawned sub-processes. Please use the import method instead.

Installing the Lightrun Agent - Django

In order to run a Django web server with the Lightrun agent please follow these steps:

  1. In the application folder, install the python agent by running python -m pip install lightrun
  2. Add the following code to your manage.py file and run your Django application as you did normally before:
try:
    if os.environ.get('RUN_MAIN') or '--noreload' in sys.argv:
        import lightrun
        lightrun.enable(company_key='<COMAPNY-SECRET>')
except ImportError as e:
    print("Error importing Lightrun: ", e)

Installing the Lightrun Agent - Flask

In order to run a Flask web app with the Lightrun agent please follow these steps:

  1. In the application folder, install the python agent by running python -m pip install lightrun
  2. Add the following code to your application's main init.py or app.py (the import shouldn't be added to a specific routed method, but to the main file code instead):
try: 
    import lightrun
    lightrun.enable(company_key='<COMAPNY-SECRET>')
except ImportError as e:
    print("Error importing Lightrun: ", e)

# Example route
@app.route("/")
def hello_world():
    return '<p>Hello world!</p>'

Installing the Lightrun Agent - Apache Airflow

In order to run Lightrun for Python with Apache Airflow you'll need to decide which step of the DAG you'd like to debug. Choose one (or more) steps and:

  1. Find a place in your system that has access to the same Python interpreter that is used by Airflow, and install the python agent by running python -m pip install lightrun.
  2. In an Airflow DAG file, add the following decorator above the operators you'd like to use Lightrun with:
@lightrun_airflow_task()
def operator_name():
    # Operator code

Debugging Airflow Multi-step DAGs with Lightrun's Free Tier

Please note that the Lightrun free tier limits usage to one agent per user. In practice, note this means that each operator can be debugged individually, but you cannot debug multiple operators simultaneously.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

lightrun-1.87.0-cp311-cp311-win_amd64.whl (135.0 kB view details)

Uploaded CPython 3.11Windows x86-64

lightrun-1.87.0-cp311-cp311-musllinux_1_1_x86_64.whl (162.4 kB view details)

Uploaded CPython 3.11musllinux: musl 1.1+ x86-64

lightrun-1.87.0-cp311-cp311-manylinux2010_x86_64.whl (154.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.12+ x86-64

lightrun-1.87.0-cp311-cp311-macosx_11_0_arm64.whl (126.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

lightrun-1.87.0-cp310-cp310-win_amd64.whl (132.3 kB view details)

Uploaded CPython 3.10Windows x86-64

lightrun-1.87.0-cp310-cp310-musllinux_1_1_x86_64.whl (157.5 kB view details)

Uploaded CPython 3.10musllinux: musl 1.1+ x86-64

lightrun-1.87.0-cp310-cp310-manylinux2010_x86_64.whl (150.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.12+ x86-64

lightrun-1.87.0-cp310-cp310-macosx_11_0_arm64.whl (121.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

lightrun-1.87.0-cp39-cp39-win_amd64.whl (136.5 kB view details)

Uploaded CPython 3.9Windows x86-64

lightrun-1.87.0-cp39-cp39-musllinux_1_1_x86_64.whl (157.5 kB view details)

Uploaded CPython 3.9musllinux: musl 1.1+ x86-64

lightrun-1.87.0-cp39-cp39-manylinux2010_x86_64.whl (150.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

lightrun-1.87.0-cp39-cp39-macosx_11_0_arm64.whl (122.0 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file lightrun-1.87.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: lightrun-1.87.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 135.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for lightrun-1.87.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 81a98ff4c5f69f357646451ab8e476017ad6bf8f48cdf8139b662f2f8a18e50d
MD5 bb7ea849df440816026d8fac9f266d5b
BLAKE2b-256 7ee2bd89c118bd1c17348f3ea8e4fcc460c95f803b9bb92c8309a789472eb5c1

See more details on using hashes here.

File details

Details for the file lightrun-1.87.0-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for lightrun-1.87.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 34eaceb166945c51a36ba26b85b56801f70aa86bb5a339d51849b0771c745f89
MD5 d172bb9c775fc22406ff1b6b0c6006bf
BLAKE2b-256 bf0b9d9f70a1837de12f699741e413999cc07d785c7a569c1ad14d2ef1443d6e

See more details on using hashes here.

File details

Details for the file lightrun-1.87.0-cp311-cp311-manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for lightrun-1.87.0-cp311-cp311-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c97f472ce55faa3b8c0cc83ff11600ac4acbc88c6173ccb26e26158c1df34c2b
MD5 0d921fec5f4dfc89472dc9bbd3a159e2
BLAKE2b-256 7ef12c924ce0e491655f11a7bb152671aac9e40068d1a0bbaf36e641aa067d95

See more details on using hashes here.

File details

Details for the file lightrun-1.87.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lightrun-1.87.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 de3f2004776522f4c771f5402da0ce641f7369db55145dd6086316f39052a574
MD5 49ab2b945fbdc2541a7542cb6f38c9c6
BLAKE2b-256 2aa2d6c93afaba7323efd4853f812e8ba15dd4f1c036d4abff9159ae67fdba7c

See more details on using hashes here.

File details

Details for the file lightrun-1.87.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: lightrun-1.87.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 132.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for lightrun-1.87.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 efcf0bde09fa1136f972348c37446d99c0df8abb710e8e00a21c27417a47d6bc
MD5 9f9140be7664a505c519c37379205a47
BLAKE2b-256 a994356d7dfed71e33851fadc331f930ad9fd9f5c55dcf95a932df110b5f43a1

See more details on using hashes here.

File details

Details for the file lightrun-1.87.0-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for lightrun-1.87.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 2d37c17fa42b7fefc76133e17ecebfdc6dafdc564d4bb675a1810ad835648722
MD5 3d89c9d774ac09c23dab9055b63e51a5
BLAKE2b-256 727f25a2112ef12a964f39e0bea7bb1e2eec0591ce063099baf77702362e264b

See more details on using hashes here.

File details

Details for the file lightrun-1.87.0-cp310-cp310-manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for lightrun-1.87.0-cp310-cp310-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 3989d8334d08fa62806d6a07ff4a38587a854023e120740182ef4433bc72ed1a
MD5 0fb30b2d8eb43d2271232e096ad459ca
BLAKE2b-256 424722f4089b7c90b5b5d108886e9127035496d645b8f57c2def858f6e430378

See more details on using hashes here.

File details

Details for the file lightrun-1.87.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lightrun-1.87.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ea60532aec48cb46506d3fc772dc15fbc34aa72d1e9753c892ac62b52ea37126
MD5 2985fd17fb0995ab0365800d03b29eda
BLAKE2b-256 5d8054ada22f44fdfd0ced036272dc13ac16f84465fd170dada853d8e676e3a6

See more details on using hashes here.

File details

Details for the file lightrun-1.87.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: lightrun-1.87.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 136.5 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for lightrun-1.87.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 28b1b6e80d319e08b3bf65b0c2ac04fabd3dd2c9875fde40b672e7d69e627b12
MD5 f38b47e7b6992d977a4a25880ccfe47e
BLAKE2b-256 9d9db57ec92aaec0c1d1ad42a7509ccfcf476d676a2d585bb4f7e917df613bae

See more details on using hashes here.

File details

Details for the file lightrun-1.87.0-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for lightrun-1.87.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 2a10a8cf928d32f89eea2b31e6a387f90544bd9dc4c0f845660bb0f9a823723a
MD5 52cf523732281ed04e24b2de2451db80
BLAKE2b-256 0c8bdeb3a1a52c427140921d44be5acdb692655c37eb4a76df0294d9ae07f0c6

See more details on using hashes here.

File details

Details for the file lightrun-1.87.0-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for lightrun-1.87.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 591b0f17ad850abced6e1860b54ddfe4975d4edb8e4e72cdb1d9deadc5bcfc3f
MD5 6ef0cddb052f4b1bc3897a7235ae1679
BLAKE2b-256 36ee87e472e1fa054961c0f3ba8b9dc2fb1c57bdd7daa7b3cfd6c09eec18e83a

See more details on using hashes here.

File details

Details for the file lightrun-1.87.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lightrun-1.87.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cfd2fb31e56d842fc3db9c12fa36849978482005c650f1db71e9de63636df058
MD5 9ca18df1c859d07700b7d80713a77bda
BLAKE2b-256 cae3f8b784056b2d148367316c56426177c8bbf33475160e345f148d43e6882e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page