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.1-cp311-cp311-win_amd64.whl (135.0 kB view details)

Uploaded CPython 3.11Windows x86-64

lightrun-1.87.1-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.1-cp311-cp311-manylinux2010_x86_64.whl (154.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

lightrun-1.87.1-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.1-cp310-cp310-manylinux2010_x86_64.whl (150.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

lightrun-1.87.1-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.1-cp39-cp39-manylinux2010_x86_64.whl (150.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

lightrun-1.87.1-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.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: lightrun-1.87.1-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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ba89086ad5e792df0dafbf2e3a6eaa84fce510660f3bcea3b7cb8833c1b5e6fa
MD5 ea7eba674b81b4d61d35aa7a4e6e87c3
BLAKE2b-256 06373d6c349be9b9f60fc13dd5627f3dd2b8b36f66afe8a58bf258a19e44923a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.87.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 838a1631e138a6df887088c445bea19e607fc4756f062b63c1836feff5f33184
MD5 85913308424f2ad52dfe4fafdd054820
BLAKE2b-256 13d87d3e2b536a48e12602239662579a5b9eef0a4026f50aa7dfbe093588f5ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.87.1-cp311-cp311-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c12e5bc9105170aa0fabb0bc646871f838f9cf7a77fd5d336488e1c0edb752d9
MD5 7da1e99fcd28bfb409bf6b92596a2d65
BLAKE2b-256 8c2fe24fbc344e347f3d63d4b538f0b9b4205c86ec473cf5b943203976889b8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.87.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7691988d0e46fdc200a4064b68d219ce88671feaf9d99df2030b27d8bea0609c
MD5 a80824de13cf50fee10e336744876c82
BLAKE2b-256 6665dca3e948f31b6292a4b506cc5dabbe120d4be556a7a32811a745070dfcf5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightrun-1.87.1-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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 22ad1c39ade758e91c08933bc35fa8c2d5f4eaaeb7a9210b70a61242c0a5ecc4
MD5 296556207f7e1edd593d2e293c212932
BLAKE2b-256 1f826ad11e89987ade9ec2ead5af9621837b28f461ffe52e999d7b2c4f2863e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.87.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 ec8ef657d812d24a55b33dd8d4659641158f4fb00389d9ffff19ec649287ca39
MD5 ab0ec416f40534b312b8219c31163f2c
BLAKE2b-256 1e0bf37ba05571a59decb7aaf139b1ec595411bfaeeb1ac462d1ef033c553fa7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.87.1-cp310-cp310-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 1fa0b73ac647a565351f477600bf6d0024eb806fec1832f9223dbba007489407
MD5 c0f2ab9c8a8f37e5cc8da7285b6bb214
BLAKE2b-256 5989bdd075e8132c26482fb356b22243596b3670e5b7dada51a171da1b500d75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.87.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bdd26e2d89c2c2cc660c8608a350456a55b50f82a6ea10125d9c0b2ae1c42a5f
MD5 6fea46144feb92537d4e8fb8c68ed4e9
BLAKE2b-256 0d447b887931d9788484177368dd27c0b488299b0fc6c4f016b3b5573ed8e814

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightrun-1.87.1-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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 28e50968666d39b26453f55061641e7cb034a200e15c45c08213e26df5072692
MD5 ab6dd2c41e536691b80ece14bff9e30c
BLAKE2b-256 b49d41cd2c87ef3346762fd3db3a10c6000e6e486f058e9ae7affe1bfe3087a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.87.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 f3b7dd83700863a1367ce3bca5d65bcdba08b4b47a5de13c36920d3e5b1f6a05
MD5 7e23313bde046aa8de184fdd5a3b12e1
BLAKE2b-256 7a1e487e1c081ab058d7355a1d40704e8218fcc2edb0736b0cd94384445fb589

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.87.1-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ff91107292258e29fcf6a2353621a5b15740accc0ac8c19a04496823b5e828d7
MD5 394a30462a55c0bb6d774a510ea7df64
BLAKE2b-256 f96481f08b06c2e2c7704f3b3511c4719f87ad5dbed2ffca076eee871ca31163

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.87.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 de12510ad7834d324b99a174f0c13d4c218ff85f6dad6b0ab6f5d85fa5a08ae7
MD5 4772fa5e054c028c82fe5cac7d3b120d
BLAKE2b-256 3c69a53a043b09f26a734544560be37f43e552fb7ba90be6b00f4015130ebcf6

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