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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

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

File metadata

  • Download URL: lightrun-1.84.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.84.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cdfff1f761c639c95b4f2061cef61766b4a4a53a6b4814921a6cc7dc234f57d1
MD5 f75bf15b1d8cba4531306d0b43961048
BLAKE2b-256 03a8f77209f00f89aa712f2f62b06336d61dced2ae3c0b56d84fa8dfdc6100e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 a676e4ff13a5a62accb1edcd12c7a836626b6cbe4856fa0d05fe81f74fdc6780
MD5 32f1d107428c0e3fa219a114346d845d
BLAKE2b-256 bf0f9273648d9d711960ba2d498713bc61bd4cacca682ed04c473ac710ad9147

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.0-cp311-cp311-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9692019b2a3ec75f06e6a854c834978b6b41844b06995ec8e3d32d9a7604d939
MD5 f10e74db2a273153c694a7b4a64322ab
BLAKE2b-256 145a21bc484ed866c3de13bad0558f6bf32f85e269b26661cc4baf7aa7811f2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f4176224f771c28d1d09a6b79ee8811af18ec7e060721cc88c9ea11943389ff7
MD5 9c7cd3eb03e317aca49c363ddf70d28d
BLAKE2b-256 752b2b3eccfdf57debd94893103f34ee21b392ab8a8a54e1193dcc6f579024ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightrun-1.84.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.84.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c33e8f68c821dc96c7761b32187eb8136a366f7db0cb148ba3cf7687c8886886
MD5 36599693a4c41dd4f03e44bb167ae1e4
BLAKE2b-256 44c61354e07ff678db4074f1ddd3236f6f85d2bf3c82701213cb98f450ec5513

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 1eed73fe23799a17c9353c948f0e12a4da05fd40c1d4e9cd32c7775253a90aaf
MD5 f920e8f3f29c5e831fac3bb3918dae56
BLAKE2b-256 47dcc5256d6d1c492aac5e3960844fa790e8b75a3ba925bf4fd16f0c4805e497

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.0-cp310-cp310-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 29d352465e072f7d4018923541414293d8e094ef6933d2c96a1384fbc792bce7
MD5 2d20cd6d16d1f5d89917c7ffe0c77acc
BLAKE2b-256 dec46588f401f2bb6ab0eaf3633eacfa9d792bc276eeba228599079a456c0041

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1c6dbc2fab919f2a2d22e031677342d55dffdaf999e2f6df878aca6f36326618
MD5 7c9717cce5214e63af77ad6d36ebd8fa
BLAKE2b-256 90645c5d47fe343c5c7fc00467d9ab645485f66af66936d1fcf876abe7903067

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightrun-1.84.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.84.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d2c60af402c407f97a9499de79d4a77a7382f101fad208cf5fbbb891c31b2214
MD5 4fd46a5e751315b8ee9dc3ae6e5ceb8e
BLAKE2b-256 fbae2b25369aa4a9ff28d602317db43e4b3bcad1a751c8aea2ec852cfc2283ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 d0b79c829dd324c378e8ebc4694915e0e8a50798d7f900f03eeed7f6c514907c
MD5 27a37dd520e6c532e86017c36869206c
BLAKE2b-256 4aaf98d4df3789163c523e20c1594c142bd1ed2d30c57b56229e11d1b541fc1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c6e012e467ffcd638e921d70566b55f217975bfc0da804f1ae4217ddc9fd0be1
MD5 996a010a87d96bb510bea792e4d69c09
BLAKE2b-256 7d55d2aa459c416bff55e2a467f6c2da50d66ea82023f085cea90969cc8e6e34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightrun-1.84.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 208a881f01f11fd9b1cc22102bfaac38f6ad963005c72758e5b6d2003d04cfcb
MD5 216349520f5bf986d84638689e1afe7a
BLAKE2b-256 bc8d6fc0b2e8090036fea220b4f98588b504dcb7896e23169307956ab4c06d47

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