Skip to main content

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.

Metadata

Release files for lightrun 1.94.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for lightrun 1.94.0
File
lightrun-1.94.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
lightrun-1.94.0-cp311-cp311-musllinux_1_1_x86_64.whl CPython 3.11 CPython 3.11 Linux musl 1.1+ x86-64 Details
lightrun-1.94.0-cp311-cp311-manylinux2010_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.12+ x86-64 Details
lightrun-1.94.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
lightrun-1.94.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
lightrun-1.94.0-cp310-cp310-musllinux_1_1_x86_64.whl CPython 3.10 CPython 3.10 Linux musl 1.1+ x86-64 Details
lightrun-1.94.0-cp310-cp310-manylinux2010_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.12+ x86-64 Details
lightrun-1.94.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 1.1 MB

Release files / lightrun-1.94.0-cp311-cp311-win_amd64.whl

Download URL lightrun-1.94.0-cp311-cp311-win_amd64.whl
Size 135.0 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
fcd90edc1f4e96becbe7416cf2d45fa2140c77c4cff5386ad7067a08f99e001c
BLAKE2b-256 checksum
How to use checksums
2ac75625b37945f57a609573493b17d9191b1a912c5610ac3c14ac3320111369
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.5

Release files / lightrun-1.94.0-cp311-cp311-musllinux_1_1_x86_64.whl

Download URL lightrun-1.94.0-cp311-cp311-musllinux_1_1_x86_64.whl
Size 162.4 kB
Tags CPython 3.11 Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
97249766d1a739825f217cae2cab0fbbb6457e11cea04daf651354c9851099be
BLAKE2b-256 checksum
How to use checksums
121a90c0d67c149ebf645e33b185dcf33da8e23698d9f6dc7548bf520e5ef7c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.5

Release files / lightrun-1.94.0-cp311-cp311-manylinux2010_x86_64.whl

Download URL lightrun-1.94.0-cp311-cp311-manylinux2010_x86_64.whl
Size 154.7 kB
Tags CPython 3.11 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
7b5454fed2a7a0eaadbed368afcd1c2d181aaf3e698528c11179fe55e6572d27
BLAKE2b-256 checksum
How to use checksums
4a71b251b0c63ac21ceafb2f3daffd5462abaebd804e1582bc7a62dfd390216f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.5

Release files / lightrun-1.94.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL lightrun-1.94.0-cp311-cp311-macosx_11_0_arm64.whl
Size 126.7 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3bc25a53e54501ca2b5160d0c1a4fec777486c5ff93d1a5aaff59df3b820cb48
BLAKE2b-256 checksum
How to use checksums
915531bb76af98422f0cec049445f1ff115f7cb9a6dbe1418e6f7f3506779514
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.5

Release files / lightrun-1.94.0-cp310-cp310-win_amd64.whl

Download URL lightrun-1.94.0-cp310-cp310-win_amd64.whl
Size 132.3 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
49b8cccd7d7b044e8d131da76bbda9148524017dbc032b52882820e9f8c391ef
BLAKE2b-256 checksum
How to use checksums
c5aa5a54ea98ab64257093bcc0929852206a4c94f8c75361b011b1cb542d7c70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.5

Release files / lightrun-1.94.0-cp310-cp310-musllinux_1_1_x86_64.whl

Download URL lightrun-1.94.0-cp310-cp310-musllinux_1_1_x86_64.whl
Size 157.5 kB
Tags CPython 3.10 Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
1f16e44a5380c5bb02c3d1929994b0c00210f43aab1cd276109e7fa3d5b40935
BLAKE2b-256 checksum
How to use checksums
19dd8b4ee81eaecc7ead9d2e357b1dd29bf2a0db13c80cff8fc15b00c8e4edb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.5

Release files / lightrun-1.94.0-cp310-cp310-manylinux2010_x86_64.whl

Download URL lightrun-1.94.0-cp310-cp310-manylinux2010_x86_64.whl
Size 150.3 kB
Tags CPython 3.10 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
86b89a5754283e67634c05b1ca41f992c86c452a314b45de19f794e03e89a738
BLAKE2b-256 checksum
How to use checksums
2c6a91a7033eb5388a4f2048d2241e31dcdc4415653b751a634d3dd307868642
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.5

Release files / lightrun-1.94.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL lightrun-1.94.0-cp310-cp310-macosx_11_0_arm64.whl
Size 121.9 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b2357676595e1a1970a653079c03d411fc31c5d9f13367eabd49af05e1568698
BLAKE2b-256 checksum
How to use checksums
6d944f2bbf829a17031da3f3350a2369bfacec901236308be2f46ea998b51b9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

1.94.0 This release

8 release files

1.7.1

21 release files

1.7.0

21 release files

1.6.2

15 release files

1.6.0

15 release files

1.5.1

15 release files

1.5.0

15 release files

1.4.1

10 release files

1.4.0

10 release files

1.2.4

10 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page