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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

lightrun-1.84.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.84.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: lightrun-1.84.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.84.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f67e7a40e32302779625f8876b73a322c666e34533bb457a217d46f0f4d1fb8c
MD5 0d4ac389887a49567c5b5bf3ee6a2e97
BLAKE2b-256 8479a6d80059f6dc7d98c5516f276ff2f5f2a5c908479b1c472e28158788bf95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 b22bcabac69e6825b462c7d1f1d01a6e4f397561752ed917097490a139a50971
MD5 b8b6a9365d331350f6b4b10510296572
BLAKE2b-256 4fb800091d2a9ca2cf9b23821d09b714080fd3148b1cba9c8a64cf037fb80fff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.1-cp311-cp311-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 2e918a001922ff3b09987794f815921a2b68376e83596a11dc93d122c3c0949a
MD5 0711731a69f8a99388b952bce634f201
BLAKE2b-256 9cadbf22efb4e138bca8a38f172e6041396d3c7f33784636e8e82262e741c6ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6adaf10f52bcbad84d6f0a5647783efdeb4353ac54ed9b258e6a1c92399bccea
MD5 7d69d74fcbac0a743657b7b790fde563
BLAKE2b-256 0c7e446956ead9b181ec9cea99b6d87d9b8f4a9394a5668f5d9c2f0cac247706

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightrun-1.84.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.84.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 124b2e8789c8fe9c0bc5498db484cebc421821611d6c27ad5b079905056bbc5d
MD5 8705296d5a90e2b1c78390ed8240079c
BLAKE2b-256 6831ee3a042fbae4ca6ff7e98036d67d509856469e52024e26c938655262da35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 184a4fe2c747cd9b943c83bea4ee3a08c48250e27ce371be266b05af4742df52
MD5 2ede9e2a695ae057d5bd06ad614e4e1e
BLAKE2b-256 562ade08174bb03edc58d1943ede1c75661f90d19e1154764b12dabf84cd9601

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.1-cp310-cp310-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 8ae20db45161c2c26821553b565f7d3cdfe11fe7a922e1ad892066759b496c77
MD5 04b42b40b5a1b5bb733b4fe159068ac1
BLAKE2b-256 729f635047d97dceb2596cb455daff24caacc3cdd77f6e269c2c3a8216f9b6b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f86f6959025145f8707aeb86905b11b2168300a356948d63b67006d3267c78b8
MD5 32df5065d3dcc1bb3e4dc407501ce8df
BLAKE2b-256 542f58bcfeee21da4c5b9fd39d04aeeca84b901baba055a98f31a0f5b47a48f5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightrun-1.84.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.84.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8ec4d2a29d8d7ba764b60734f9b5fd14f624a70dea28a695fda78b7e8358e6aa
MD5 45a7c2f3fdc061fb75924fb9057bc593
BLAKE2b-256 e08f8dc3be6888ab7d992dfc5dd2329e630ecf5b9e8891d0895d30237c4942df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 7d33c99f11dd1f287105e01e5a56a9d258fa0abfe5a144045fc72097b92f01cd
MD5 12903f49a3bf2831377bb79c49e93dd3
BLAKE2b-256 9855cfcf11a90f87b867579288a7670fb38031bb11be191b1ea16fd482d933eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.1-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 562b6d96d02d287ade072a676eb817b2c90e7a0dc473b81863869b78ebf7f6f6
MD5 f6efbb57a7666438706dd74f1367c0d3
BLAKE2b-256 a1afaf9bc804c3cd2c21e0513f02967d3ceea4e8e345d94791514d463adc2d58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92bc88ded7fcf64439a3f085c777ce892c76b619cdfc6fb3031b37f991e42056
MD5 c74ff263d62796df2a6cae551f7562cd
BLAKE2b-256 d3cc40b3ed3be672903a9195cfd90cc9b5c95e8e6f9df68ce5c55c7d739a3e36

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