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.93.1

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

Total release size: 1.3 MB

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

Download URL lightrun-1.93.1-cp311-cp311-win_amd64.whl
Size 135.0 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
7c6cbbd0929ef7f1865be97aa5a21e9ef2628539650307abdc0e07cb5a1c22ed
BLAKE2b-256 checksum
How to use checksums
5fb8df664ef464bc2c5cab16bd508eb37dc2cfe5d10bbc6b7ec9e73b50f9517c
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.93.1-cp311-cp311-musllinux_1_1_x86_64.whl

Download URL lightrun-1.93.1-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
a022fa099f7d002d0701baf4596ccdd54799039cbd2da64de8a2bbe3334df2e1
BLAKE2b-256 checksum
How to use checksums
2759fb19daf79fc0e724315d1f4c3d8bd9d6539603ef6361cf5705f88aba1178
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.93.1-cp311-cp311-manylinux2010_x86_64.whl

Download URL lightrun-1.93.1-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
6334789b00838ee84bb48d7c7308b78a03756b630f6cb5ff2e2ab1cc15e299ad
BLAKE2b-256 checksum
How to use checksums
f33e7a2bd3f26534a19c83ab52f84b0a4f1a0f92213589fb2d8dc544552ad12a
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.93.1-cp311-cp311-macosx_11_0_arm64.whl

Download URL lightrun-1.93.1-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
409551ec8ffbd08250acbbc67160e717adb5dcb7fee2b812bb489fe7f4b4ba49
BLAKE2b-256 checksum
How to use checksums
5c2be326453d006729fe51446bd7e9e7914f054aba2aa85c07d5f80d3c919eeb
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.93.1-cp310-cp310-win_amd64.whl

Download URL lightrun-1.93.1-cp310-cp310-win_amd64.whl
Size 132.3 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
5533cd30481ba408309d7e0c2366c0b542856a1467587d27a924cb8f033816c2
BLAKE2b-256 checksum
How to use checksums
341d57b1e469848420529ac7f0fda83893fae893c8106bd1ea0d4c23818760da
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.93.1-cp310-cp310-musllinux_1_1_x86_64.whl

Download URL lightrun-1.93.1-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
badad52efb8d839c6235289f0b134645f2c7c39eab3f2c6ac2dec99983c85337
BLAKE2b-256 checksum
How to use checksums
45670b62aa72dc9e14118f70d5c2cbaf8fdb4b8f54d11c29aec82ab3965feb9c
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.93.1-cp310-cp310-manylinux2010_x86_64.whl

Download URL lightrun-1.93.1-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
0f9017b6999a890492f0cb7ae6030a8939ab2b052b5550710fb960ce05a9cde0
BLAKE2b-256 checksum
How to use checksums
34fcb113d136984a44753fdb49fe47f7cc18bdc849ab7b4131a43769fe40df09
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.93.1-cp310-cp310-macosx_11_0_arm64.whl

Download URL lightrun-1.93.1-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
ff92375c2ce010170438ea0620431079f5f5abba436400690106ccdf48b8c8b9
BLAKE2b-256 checksum
How to use checksums
ee98b730135a07f29728e66026ef88cdbcff94129974b0203994870ad9a9856a
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.93.1-cp39-cp39-win_amd64.whl

Download URL lightrun-1.93.1-cp39-cp39-win_amd64.whl
Size 136.5 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
0f58cdc47ed1d30de55cf734d7c4b0c9a6ccf3e42381adf8079b9f9a81ad2923
BLAKE2b-256 checksum
How to use checksums
6c323b160e50ff90a769874b1219bf30ec8fbf497f2dff8559d3a7568f97a3e7
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

1.94.0

8 release files

This release

1.93.1 This release

9 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