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

Uploaded CPython 3.11Windows x86-64

lightrun-1.79.0-cp311-cp311-musllinux_1_1_x86_64.whl (827.5 kB view details)

Uploaded CPython 3.11musllinux: musl 1.1+ x86-64

lightrun-1.79.0-cp311-cp311-manylinux2010_x86_64.whl (825.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.12+ x86-64

lightrun-1.79.0-cp311-cp311-macosx_11_0_arm64.whl (765.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

lightrun-1.79.0-cp310-cp310-win_amd64.whl (739.8 kB view details)

Uploaded CPython 3.10Windows x86-64

lightrun-1.79.0-cp310-cp310-musllinux_1_1_x86_64.whl (775.5 kB view details)

Uploaded CPython 3.10musllinux: musl 1.1+ x86-64

lightrun-1.79.0-cp310-cp310-manylinux2010_x86_64.whl (776.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.12+ x86-64

lightrun-1.79.0-cp310-cp310-macosx_11_0_arm64.whl (621.2 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

lightrun-1.79.0-cp39-cp39-win_amd64.whl (744.1 kB view details)

Uploaded CPython 3.9Windows x86-64

lightrun-1.79.0-cp39-cp39-musllinux_1_1_x86_64.whl (775.5 kB view details)

Uploaded CPython 3.9musllinux: musl 1.1+ x86-64

lightrun-1.79.0-cp39-cp39-manylinux2010_x86_64.whl (619.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

lightrun-1.79.0-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.79.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: lightrun-1.79.0-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.79.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fd21fe8caebe6b21f2653850ec53122479e3290eb3f74f13cb20f29aefdb7dcd
MD5 d1320ac75c69d649740ff5232cefd36b
BLAKE2b-256 62f0c25046513a9d3e7518432031ea293d686270c824319d6d4cba88882e9d29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.79.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 6e8046e295eafef901414ba4777440b63a928bf0c9471b2cc1f733fd6453d35d
MD5 2e5c454b9de2bae36021994624a01d38
BLAKE2b-256 b0404999db62067c4c81df72a527c268e10c9ee97796b6ae247f6d943986e34c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.79.0-cp311-cp311-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 34b492a70f8b3ac4c16a3656ffac1000e2124098ae5636cdd23f09dc43dc33c7
MD5 eb1026e336b3ba4d4045b873b897a60d
BLAKE2b-256 b931c4b592d28e0364f1b972d8abdc7f50d765c3a9bf976ae6392666de259775

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.79.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ba8575432960e7ef15d7e1c16e6c440f0c3e780ee31dd4cbed51375e033d7ccd
MD5 9c5b3f658dd00b58ca2087eb22d15463
BLAKE2b-256 166095bc0bdb782d31e194b18b39d2b13a8e497378c8f893b5c49a8dc9124a9c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightrun-1.79.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 739.8 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.79.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f356fe76a1e81885b1d5a26ff3d8c1f0368e1cf0b44fb7bb370764fbf08378a4
MD5 66b56e952abe8cbb3f4e16851b7ebfeb
BLAKE2b-256 d395cf4efcacef0960d9e7c56e815ee0d96fa87fc50ed538d641aad744dff390

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.79.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 10a51c043f5910cba3f3480a5925f0b7d4d72462ebef008f0d49f59fa6c2836d
MD5 26088d252a599354d9ecc1fc657c2fe4
BLAKE2b-256 c57b9f22ee38841cdefa5f2be9dbc65f3b81470802fb9714822df6a0b8ae830a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.79.0-cp310-cp310-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 70a6069d58645916e427130709dd8ba2db76c8517bca26bdb295037bc1972f2d
MD5 707f4439d76ef099771cd77e0e6800fb
BLAKE2b-256 9faaa740c1333a473f84207f10e2b7d7d6a2c41bf2e7aef425c2fbd27e5c23b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.79.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 84a632e918b69619bc43ce9a1f8bef17f065ae89243475abfc2782435077c9fc
MD5 f14563886c28e6dbb420b9b73cb4bad2
BLAKE2b-256 67a36603401f05f20efe217258811f0c0bcdbc55a797a6170b1722b6ae2e7915

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightrun-1.79.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 744.1 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.79.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 fbbd4978a0c3ddce1804766ef2a1dcf480f7600bf2e94f51ad91d9d32f2290d8
MD5 3e1cd7fe9d06c8a9f441e60a341d3acb
BLAKE2b-256 41b45e782c1f97a8744ebfdbcbda09a3998580d1bbfdb9892c24e8010c23b19b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.79.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 7b8af2b6838ad51963398430f5a6229eb14906e2afeda7aa252aac04c2e4d4e8
MD5 d51c730503c665215b29914817c5ce43
BLAKE2b-256 e6abc7f6004e89db0aa7c1d2befc0fc8cbb4a0c6667fae8e763ffa3ec4db6336

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.79.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 21395e065fe8456b803ee23ff72eb421c3d6c3562308addde16ea0c507030186
MD5 38d75b96a31bc52b469ab51284c5f703
BLAKE2b-256 e48b50aa1910cce9c3f13ede9def348d95cbfeb9d77c8fa9ddd1e1d1d0da2ca5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.79.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 419c934f44b85f1adcab8b677f0f68b32ba00e46e501628cd321b9b54590d413
MD5 1cd7533c1d6e16be88e7c2ecc1ac1d61
BLAKE2b-256 e9a900a049f5ff0d6c9185c088a40d1b3db46ea00e0e6ad396130fccb40c3cdc

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