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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

lightrun-1.83.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.83.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: lightrun-1.83.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.83.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 12943d1dbc19a7c1a97635c71f6d2c71b02aa2dac78bae4c4d65bc32cbc806b9
MD5 0f669e465db06ea5dd532732f6821ac8
BLAKE2b-256 9a735a84fd4099069ccbdfdeaf534c44256a2297d28e7371d0b547f0c28fa3d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.83.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 62abac540dfba9ce4ff2e926c9149c567e598094893984d12b732c6679affca3
MD5 4b285ab91ad8d669c25bb1a90e4b8340
BLAKE2b-256 110bc65227249f158b5a736470f1b9215846c8ddf80a25127fb7aeb519dc1620

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.83.0-cp311-cp311-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 6e7091d5f1b0a2f2fb7fcced8d2f2b732ea8a314f5267b707b4864d1379df6a6
MD5 80497de38beb295a70781157656884dc
BLAKE2b-256 72e60410f1b16dbbff388ccc64b5053472be82663b905ab2251aa26621908963

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.83.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a66ba10631b9304d06996699cb74853e3a16f46afbd44b7adaab933abc953afe
MD5 5becd29ee5dd63d57a4f3e0eeafc7045
BLAKE2b-256 055aaf6784ae0cee9b0a30a76597a770af725ec012e3fbca2168f3a7e26563ad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightrun-1.83.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.83.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e3b5719f85e48b07e788d7864b12e3aa1bdee62eeb4d2d95626edd6ec227f2bf
MD5 02f282c10b08c117b7d0b1cfbc1c5943
BLAKE2b-256 eb4897ae97bf98a465172f8eca33bf6012cacac715fe393b9204858b7a56b0fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.83.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 a5c5e2aa607ce171f4d627f785a096a30fa553d442da93ca0aab47d92e20c0c7
MD5 9048cac8273c3e2dbaa50b408f5623d2
BLAKE2b-256 7f3a3176f5cff99fafcf10f0e47fdf5c251ea9128a08cc4ca6f1943bf944fe98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.83.0-cp310-cp310-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 3456dad765e5029d4f0dd89f363c8bf31fd24373ba546164b210157bfa9f29c1
MD5 8b96d772814b88342e73b6e20d3958f8
BLAKE2b-256 80188fd70fdf2d976dfc33a9b436a4b844e7785520d370ae2a0e0bcd784b4664

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.83.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8966766568032a2463b44509c313d3f64c25e37295ed645b48543599be5c8f36
MD5 947596ac91c3ba2765a66f779035e3d4
BLAKE2b-256 36abe664ca12e457d49d997af67e482c4630b7be1f6236b48ca60372d2365fbf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightrun-1.83.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.83.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e33741546f314330b8ebb93b2e611646a6f4cceef1f584a4eb99aac24561cc79
MD5 a89d3969a8c36166146a1c04ac867f13
BLAKE2b-256 357f6ccf32c9ea4fc6f2a29c52148313d588567e87f99ddef1d13f4545f4c25e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.83.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 638653ebb0e852725d7b6093913eda28d266065cd15b9ed53aab696390744c4b
MD5 2d79ae20f2d335b002d0105b3a027612
BLAKE2b-256 5a6a1967a8b57f907d8fe4153e2c236882c4a3662bc92f835f2b37463ff6e7e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.83.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 40d9e078b2981af9df57fea90a9483d838814137aeac2583b66534c94f914067
MD5 95be5a1c2e419444c72ec4757429fefb
BLAKE2b-256 5af25c7d27b72a7baa9bd062ee665e01c83db2d86159bec7dc65a4885a565b4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.83.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a1f3d348fdae7163b845d69eff85992ecf2a9d524b7c98e0838a7dfaa951bd1
MD5 15f2e06095c4660d50154c4adb85e5f9
BLAKE2b-256 a8441b495410dda0a29ba4b749cfca37967f4c317ab15be348502cb8d184d4df

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