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

lightrun-1.45.2-cp311-cp311-win_amd64.whl (887.3 kB view details)

Uploaded CPython 3.11 Windows x86-64

lightrun-1.45.2-cp311-cp311-musllinux_1_1_x86_64.whl (821.0 kB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

lightrun-1.45.2-cp311-cp311-manylinux2010_x86_64.whl (819.4 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.12+ x86-64

lightrun-1.45.2-cp311-cp311-macosx_11_0_arm64.whl (760.2 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

lightrun-1.45.2-cp310-cp310-win_amd64.whl (743.5 kB view details)

Uploaded CPython 3.10 Windows x86-64

lightrun-1.45.2-cp310-cp310-musllinux_1_1_x86_64.whl (771.8 kB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

lightrun-1.45.2-cp310-cp310-manylinux2010_x86_64.whl (772.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.12+ x86-64

lightrun-1.45.2-cp310-cp310-macosx_11_0_arm64.whl (617.7 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

lightrun-1.45.2-cp39-cp39-win_amd64.whl (745.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

lightrun-1.45.2-cp39-cp39-musllinux_1_1_x86_64.whl (771.7 kB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

lightrun-1.45.2-cp39-cp39-manylinux2010_x86_64.whl (615.6 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

lightrun-1.45.2-cp39-cp39-macosx_11_0_arm64.whl (564.7 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

lightrun-1.45.2-cp38-cp38-win_amd64.whl (744.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

lightrun-1.45.2-cp38-cp38-musllinux_1_1_x86_64.whl (771.2 kB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

lightrun-1.45.2-cp38-cp38-manylinux2010_x86_64.whl (615.1 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

lightrun-1.45.2-cp38-cp38-macosx_11_0_arm64.whl (564.3 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

File details

Details for the file lightrun-1.45.2-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for lightrun-1.45.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 62506caaeb158388c57646bcaedae49c87e935d89560fa5a4cc3100d0de9f793
MD5 bc71ec2ee41a06170fba6c87340df3bb
BLAKE2b-256 778495049c30c28337875d525e0a6402a2c2fa4673b2e9ef751fc9b6afeeadec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.45.2-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 6212222320e51bc064fe3af16e9c1bac0c2eefcd1997d9983c14d20d6ed8ccb2
MD5 9b458e3b1442a75002c6fc1422822874
BLAKE2b-256 85d05602781984fe40f287530dfd147fa3e2191bdfcb4dfbac1b3ddc4f3808b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.45.2-cp311-cp311-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d0f4dba8b947f76a7166382b823ab2c914d1febc7db2f130f0ed4b9f5a4614d3
MD5 ef0ce69d1d82e1aed1e98718f8c45113
BLAKE2b-256 26d6a507d549bd8f4c0e95febed3a938fe1069abbf76582bfb05fb3c1d29804b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.45.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3b6c6546debdafbd8e4c5f04d7b566b54c553f31ecd5be1e57c08610876967d0
MD5 65a2148969d35472c735aeed008736a5
BLAKE2b-256 fb198fe51fe751c0c936ad271d73d9a6ab63b1411023ab45c03a83085d931e0e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.45.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e9559805ae1499f36aa58d2d6a640bf48d60e7470ddd69e82c46494533b0e27d
MD5 7b9319b87f473f1a0886dba50310aa0d
BLAKE2b-256 938eb26d4cfd242c85c000ad6951b5e5f45e4567c47a7bf9ae511a0e142f192c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.45.2-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 46e3dbf0181ee445d2aaf38b4d39c5e8b04eb64327e3dfe815eae217bee8876f
MD5 1724c3cf7de56aeffe50e634b9c2bcab
BLAKE2b-256 13e41d16f30151496df8f3635bb94f4ca1e4c5cfd43e8950c86cb1f4bf6d3fb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.45.2-cp310-cp310-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 03deb2a07f64b257f01437e9c3f0bacf4e32181a1a133c4cd8ca209755c7ba4e
MD5 4107b5edfc4e138e01f1d2eb811754b2
BLAKE2b-256 642c9300eb5d74dfd0ad830542e8dc42b8a8b31df31b0ff22815d572ca245dcb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.45.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 53eccdf46b795bff492a935f111221e3e8e6bf1d9ae1828150716ead4fbef611
MD5 54b5d42933dd7b2448c5332bf13dfe6e
BLAKE2b-256 e24253118aed4abd2c30006556827835d4f3df2feb94cf886df8a99a8d1fe06c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightrun-1.45.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 745.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for lightrun-1.45.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0406139f16fbd006554f8322f9139c827aa8325db40590817a45d3174f010e32
MD5 c3b52ba48d0699eabd9bfa89da4db18c
BLAKE2b-256 2e0ea1ddc08b34c4b2086c77707be300994fdfb6de9f1f57d5c322faa192c48a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.45.2-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 452ceb55ab9b1df83c2a473327217f32ab6614c68c6864f331f2e64709a1d676
MD5 b35067b4d658fc4ee890dbaec3086344
BLAKE2b-256 c530a48f07b408a963d7781e3526fa5313458c14f97cc964cb3f692d00eec85a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.45.2-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 0f599d6e1e983c380a8a92885da81ff2de639b7e44de1e0501cfce88c6507314
MD5 55b28b1d6d15ed52cc4686f8854093bf
BLAKE2b-256 39e927d180ce993a0a78d13dd51f4ebce573d49e0adea74f2576a6d01888bccb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.45.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d89a3e43d4f6bacb0111970a03601eb7edfae175bcd7861c793812fbce24672d
MD5 915cad60a3445449cae30c3a5e90f0ab
BLAKE2b-256 6429f55d35a90bd7f2d7700c4ac4e72fea119e6e7c70127b672868b15dcf9762

See more details on using hashes here.

File details

Details for the file lightrun-1.45.2-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: lightrun-1.45.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 744.5 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for lightrun-1.45.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 7d04891a0c607dc2c03d560dde9a14b8aaab22758ac21dba573c850bed5039dd
MD5 7baeb2344828742b1362a4017c3bb7eb
BLAKE2b-256 ca4a1b8f7cb224a1b8ad34bb0ad77c65cb2ffe2a99e4a5be2a020ff2f7a01d27

See more details on using hashes here.

File details

Details for the file lightrun-1.45.2-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for lightrun-1.45.2-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 b478b5d0feaa1927b3cf97cbc28f4201724ea49106b45909f211a1edc136a9a4
MD5 91737043ee5ba08de56fa132c14da9cf
BLAKE2b-256 686570157a9214bc20c5c8a2cee97ccca3a4c38272ecdc076b706e67b125bdda

See more details on using hashes here.

File details

Details for the file lightrun-1.45.2-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for lightrun-1.45.2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d55059cc573872e4f2d2acf696e2164848659649fb2dc738dec85b3825b2077a
MD5 2c5cea250c992f525314631af4f9db50
BLAKE2b-256 209ae97e12b538e2ab32171c361979d82230822507f20f7408f36955250281f0

See more details on using hashes here.

File details

Details for the file lightrun-1.45.2-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lightrun-1.45.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c7aaca48b22c7cdd15376df6b3a033cf498bcb2b274cee102a0dc044267f164
MD5 24183980544fc700826c194e55773d19
BLAKE2b-256 b5ebcaa8ba5f5e41a8c379c4d4505d3681ec5b536ed8bac1a3dd8a49ce519ca9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page