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.95.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.95.0
File
lightrun-1.95.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
lightrun-1.95.0-cp311-cp311-musllinux_1_1_x86_64.whl CPython 3.11 CPython 3.11 Linux musl 1.1+ x86-64 Details
lightrun-1.95.0-cp311-cp311-manylinux2010_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.12+ x86-64 Details
lightrun-1.95.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
lightrun-1.95.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
lightrun-1.95.0-cp310-cp310-musllinux_1_1_x86_64.whl CPython 3.10 CPython 3.10 Linux musl 1.1+ x86-64 Details
lightrun-1.95.0-cp310-cp310-manylinux2010_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.12+ x86-64 Details
lightrun-1.95.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 1.2 MB

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

Download URL lightrun-1.95.0-cp311-cp311-win_amd64.whl
Size 134.9 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
6ce731af2d3fcab704569c7025dfc883d791afa5375525709e7ead0f62c67307
BLAKE2b-256 checksum
How to use checksums
c00e727c94700783e22588650067db212bfa64146fdfe0ba63ab008311d0f1e5
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.95.0-cp311-cp311-musllinux_1_1_x86_64.whl

Download URL lightrun-1.95.0-cp311-cp311-musllinux_1_1_x86_64.whl
Size 175.4 kB
Tags CPython 3.11 Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
4421c13bb9b415b832cf122221974d4f7d2c4ed30f933b13624353bf340acd58
BLAKE2b-256 checksum
How to use checksums
67aa68c0154f46423eff2da88caba9913de0ed0d6448f46225d21401ab587637
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.95.0-cp311-cp311-manylinux2010_x86_64.whl

Download URL lightrun-1.95.0-cp311-cp311-manylinux2010_x86_64.whl
Size 166.9 kB
Tags CPython 3.11 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
45f9cfa1489a8183feb3034ff668898393291d4b938f4fd1cd5bdcd31d86c205
BLAKE2b-256 checksum
How to use checksums
db6f2c36cd9d9935e1d0cf04bede1985e822176c0f32c7ae6528d73b2bc89085
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.95.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL lightrun-1.95.0-cp311-cp311-macosx_11_0_arm64.whl
Size 134.8 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0b4ff79d8282e62802bfe1a0b04d36f429ee667ed9d1c221f2bd8535f01786bf
BLAKE2b-256 checksum
How to use checksums
253f1e0cfbc6f4492f0cd5b569f84e97264cf3f9b735ea239a314e58acae260a
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.95.0-cp310-cp310-win_amd64.whl

Download URL lightrun-1.95.0-cp310-cp310-win_amd64.whl
Size 131.2 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
21d43bd602288820fe01d09a57624f24c2c79e3ebaaf381b063cd498cde2b894
BLAKE2b-256 checksum
How to use checksums
aa7e553ee6025507b0061cda9555a8d9276f0e55f9e443c596fcd056f325d4e4
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.95.0-cp310-cp310-musllinux_1_1_x86_64.whl

Download URL lightrun-1.95.0-cp310-cp310-musllinux_1_1_x86_64.whl
Size 170.3 kB
Tags CPython 3.10 Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
3bdb105fbd27d9d23f4ca6486762f50a0faeffe15a982f735c4865db9fbdca9e
BLAKE2b-256 checksum
How to use checksums
6759eb5da5bd744514d67b80491412ece8687aebe5e15c7161a72fffc3fb47b7
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.95.0-cp310-cp310-manylinux2010_x86_64.whl

Download URL lightrun-1.95.0-cp310-cp310-manylinux2010_x86_64.whl
Size 162.8 kB
Tags CPython 3.10 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
81826f4fdeca1b38fb4b694835b1ccb32aed57c578a4c2bd3cebbb9ee27aa6c1
BLAKE2b-256 checksum
How to use checksums
4b712573aefe96c7932379182bedc9b03aa8824d1f2bdb153ffd96089a148e03
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.95.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL lightrun-1.95.0-cp310-cp310-macosx_11_0_arm64.whl
Size 130.3 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a2b904a416349382a411fe15d93c714359700cd40090c9ce69f6cf6ced3d82a2
BLAKE2b-256 checksum
How to use checksums
96eaaa69b382676cc6b0cd761c5cd8ce04ed11a29c9d5dd364a5970df00ac6a7
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.95.0 This release

8 release files

1.94.0

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