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

Uploaded CPython 3.11Windows x86-64

lightrun-1.86.0-cp311-cp311-musllinux_1_1_x86_64.whl (162.4 kB view details)

Uploaded CPython 3.11musllinux: musl 1.1+ x86-64

lightrun-1.86.0-cp311-cp311-manylinux2010_x86_64.whl (154.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

lightrun-1.86.0-cp310-cp310-musllinux_1_1_x86_64.whl (157.5 kB view details)

Uploaded CPython 3.10musllinux: musl 1.1+ x86-64

lightrun-1.86.0-cp310-cp310-manylinux2010_x86_64.whl (150.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

lightrun-1.86.0-cp39-cp39-musllinux_1_1_x86_64.whl (157.5 kB view details)

Uploaded CPython 3.9musllinux: musl 1.1+ x86-64

lightrun-1.86.0-cp39-cp39-manylinux2010_x86_64.whl (150.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

lightrun-1.86.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.86.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: lightrun-1.86.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.86.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4eb9043c3cd28ebf9b47ff0e4c69038af2823d4a617f9e1fef69d20a4426f0b5
MD5 95e2604087c4dac454e0c6864520da84
BLAKE2b-256 23d02c4974b64dfed7c85c4e3aa1d4a5749730a7bd45c8613af26d62fc3d1fb6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.86.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 4041ca39dc9c505341901af7644ceca4b455c06fe2d690b6c9c54456875f8279
MD5 08618c507713b5dd56de3bfbd12bdb44
BLAKE2b-256 eb74757523b582eb46051f786274e5526071745179452b935389b3d75dfd8a28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.86.0-cp311-cp311-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 62286ed7b9794962c9afa58f3f663b17f3cd2860074465a470ab9dcaac11f20a
MD5 09a65271939e90b61def4ca4e4619622
BLAKE2b-256 442e2ceca2d05ca746b6adc7c1c7c86e8e210d10354a850998fdb6fa723e3d41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.86.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f36d8413b9b8f9acc31c3c3cf6b6acc6ef38cf81a0aec4f23929aa34769b69bc
MD5 9a597d8fae3d5d6f3006da42f9d2e6e4
BLAKE2b-256 893e2f3bf80144313a76652033a3b9ef0bd1ced202675308ddd528ab3f9211f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightrun-1.86.0-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.86.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d4550b0274f8c06ee8e9010d6ea1d646bd533bf07b3ed78357a1eb34c1daf6b6
MD5 8957206bc4b19743f2c3e4640d7c2595
BLAKE2b-256 89791d91623413cd65efccf3fcc2de65fc46b55883343c5f5e12cb8df6b4647f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.86.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 742ecb0dbb64a04fa12f8aec906eb294928ea009f1ba426d4d4ae1afafedb573
MD5 4841389c6369686960bb41a7066d0279
BLAKE2b-256 1789fddc370d942e6a0a9d792c062656e3c25daf6d5ca9558c02544fb1bedfa6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.86.0-cp310-cp310-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 2c35b9f451705db92e419862e773f862dc4a1f2d7b39f81e1b9d3f7472bd1960
MD5 baae0957aaa94cf9aca393c64e7b7a24
BLAKE2b-256 0eccae9858a1790080d618ca1227c5e69056c3b375e62a6e73d93c48e587e2ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.86.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b4ebfd0835d49829198af6a40293fbfb31c6236ce745ee37bfe046d0e35dac2c
MD5 d63da7996e16b1ec201469a7e970648e
BLAKE2b-256 6f6f8ddd6235dc75f0fdab23aeed054f910bd62d46e228379e941fcd05a2204d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightrun-1.86.0-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.86.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c5d543170dde7386a42e233f1c70ef527a21698cf8a06a175a004e0ceeff832b
MD5 ae870821546abbbc637221240ef1be1e
BLAKE2b-256 b409e56fb0e5f9a2bca63ddaa3cd3bfb8a0339f66068007dc6640a33d5e6f1cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.86.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 10085e79a70f184c4673518f3d9f140f265af489e1d2f615ee4c72b10d9ad09c
MD5 fca8081afc4722e47fac1d9e70bd4ebd
BLAKE2b-256 31e31f3e14422430376a8f7253ec7d1c02c0986492b1fcd8a43ca03f220f6ff5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.86.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c565ff3db3aeef428a6e72c89ee5306469c23935229c6c6ce77df6dc438fc9cf
MD5 21427bca8986d2d4327b4515e93eb564
BLAKE2b-256 cf29c9100aeadd20ee61e2253fc50517b4af8730df4b6c342ad381e3250f38ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.86.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fe708ea91e67f8b0032ccba79fe10cf5481d2845a5aa2a2ef4599531880a7290
MD5 7ae3007d25b648b6009346b49bea097f
BLAKE2b-256 97cae97b2182c31e1bba36fe6d5b2b2429667e1db1b812c33d7349ffc634fcfb

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