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:
- A Lightrun Account - you can get one here.
- A Lightrun Plugin - you'll have instructions to download it once you create an account, but you can also check them out here.
- 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:
-
Install the python agent by running
python -m pip install lightrun
. -
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.
- 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:
- In the application folder, install the python agent by running
python -m pip install lightrun
- 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:
- In the application folder, install the python agent by running
python -m pip install lightrun
- Add the following code to your application's main
init.py
orapp.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:
- 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
. - 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
Built Distributions
Hashes for lightrun-1.38.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86035c30073fefba8f9a352c32a9bf92dd1ae8629c5147deaf488d823433824d |
|
MD5 | 89b22b8caf0eb484a75b4ead447460f4 |
|
BLAKE2b-256 | 743bfe17cccc99575112f9166792e766ae33905022fd40dc95adde8535be0758 |
Hashes for lightrun-1.38.2-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1334c7fa0783dd01abfbc1d4e8791c7840578fad0ad32c0eb80ebf512c0c5b6 |
|
MD5 | e2b91a4af56dc3e040aa2fa3f17bf646 |
|
BLAKE2b-256 | 9d2563f522271f576216ac362866bde79d4aae7737a404e39e87c4db9c8f2b47 |
Hashes for lightrun-1.38.2-cp311-cp311-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2059a984451c283de55ca0b34c29f2967769d2c5405b7564cadd5aea7fb8e98 |
|
MD5 | cc520d35cce5f37c0ff2fba88fd00178 |
|
BLAKE2b-256 | 4bced39f166244ae842c014049a91e886d520a76d224a740ebb027d3d989b48f |
Hashes for lightrun-1.38.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fec997d5b2d444db5921574261851bb257e71be7850cc18b5e70d18db13bc78 |
|
MD5 | 6bcb9332bca320df8ceec59a0b80683f |
|
BLAKE2b-256 | ccc7a60ffdcd525d4cc6afcdfe44511483c87b4aa109c2cf0c82600d346873a2 |
Hashes for lightrun-1.38.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ac218ccf8b7ad8eb0209d1b1f3c437de0c39c3694cdb594703b5d0187a19496 |
|
MD5 | 4cd3626690038a47c0f41e75f8892166 |
|
BLAKE2b-256 | b67f19339b7789453c1b5d2ed9cf108881b34e186d7b5198024eae80651bdb56 |
Hashes for lightrun-1.38.2-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 442794fe85a3f48dd96d6c754945bb4f27bb1ad80844151a949cca51858af63a |
|
MD5 | 45844e8cef3f5b2c660cb8a9155b7e86 |
|
BLAKE2b-256 | aaeef0fd301cab14aceba03f835ebde9f627566e0ddab791356bd52a87b71d8a |
Hashes for lightrun-1.38.2-cp310-cp310-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c093d0d1815c65c722044708b1d1705ef0442e5d4b2387b59f9da1772fbf0a9a |
|
MD5 | e1ef09822b4c8744fae36a48bcf5becd |
|
BLAKE2b-256 | 1095d9fac5fb080b4952cb0b5be0aea9899a9352b4610dfb7747a4d4773a6dc8 |
Hashes for lightrun-1.38.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6eca61d7832df12a356a9548cfd17f0ecc666c2ecf1fdc92b797689d306c3ea1 |
|
MD5 | 466ad854dd296d8a437ccb2cdd230857 |
|
BLAKE2b-256 | a0882400f460be5ffb90b32ecf9866ed84d6cf948d5cbc613da2f00ccdffb9c4 |
Hashes for lightrun-1.38.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7855e7a4370709c56b4540b8d88f0543f8b8aabb7f2cfe5593c8941d224264b4 |
|
MD5 | bcb4bf43735153a3b4b91fc147df797b |
|
BLAKE2b-256 | dd28f4c9f0414b0490ad588ab2fdfe234f08b346c9f06b05cfdba9ebf09f0727 |
Hashes for lightrun-1.38.2-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a2443a901679e85879488d33a36763e2ec8a456b505a8cfa57a70ba09d68926 |
|
MD5 | 8d70993bc11e437b82e2244e0b268712 |
|
BLAKE2b-256 | 33616ee88fcdd70603e97886347ce0a29c65e95465fdbd7b0676f5fe7244b2b0 |
Hashes for lightrun-1.38.2-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ddaf80f6d2ea123a10f228e1d8b15bbfcdf4738c7fd22c38abc90dc57223c40 |
|
MD5 | b1a43316f4335c8367bdaebde71d01db |
|
BLAKE2b-256 | 4e2ce7c1837d5a0d3713c3f34f4f4eb106e14d814726912bfc345f1e4596f9fc |
Hashes for lightrun-1.38.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c6792dad10db60eb3f3005e0e4fdaed62d5ea4f8502c2a9537e59e310fc432a |
|
MD5 | 03e6185264b80708a350497f066c7619 |
|
BLAKE2b-256 | 0ad2f89bf67a70319bedbbccf075fa4c655cc1336ffcfd89890c8ab7b6f65c19 |
Hashes for lightrun-1.38.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e54b3b9452e474c8f7d6183a80bd37674096380e574bdec6e00ea096b532f458 |
|
MD5 | aadb7a6df38aeb667cbfc72be2ec6dd5 |
|
BLAKE2b-256 | 87bf434021d4a52fe18a0188fbea8c6fd827722f18bf943cbac3f9d0d66d862b |
Hashes for lightrun-1.38.2-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74514f9985104fe560dafebff744772c52aa377471edb935c0abd1aa11d45767 |
|
MD5 | d70683670fb417b43f75b1909fc63df1 |
|
BLAKE2b-256 | b711f810a6d292231f1289fa613ecfce7e5edb5868764b12a39c82c75353303a |
Hashes for lightrun-1.38.2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30dfedef2cd06b881e3bf89d3542c125464dffc2482295fb040292565d05d995 |
|
MD5 | 4eb8f9649cdeac3722da78fd7409ef51 |
|
BLAKE2b-256 | 63738e7763afe09a7521f6336810a038d8eb2e6d2145e61119678281c56aaf71 |
Hashes for lightrun-1.38.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61bb29e5e627dc1637ca29ffe029c4bb0280107c67fcd9d1d6d715541a536413 |
|
MD5 | 55be5da8b4fdada8018e5af1e98416ef |
|
BLAKE2b-256 | 2ec8a97e9c5aeaba5d6d658163c50a1d1bb38b01137ae2d840520cc354a6e6ac |