Lumigo Tracer for Python v3.6 / v3.7 runtimes
Project description
Supported Runtimes: 3.6, 3.7, 3.8
How To Use
With Lambda Layers:
- Use the latest ARN version from these tables
With Serverless framework:
- Install the serverless-lumigo-plugin
Manually
- install with
pip install lumigo_tracer - import using
from lumigo_tracer import lumigo_tracer - wrap you lambda function using
@lumigo_traceror@lumigo_tracer(token='XXX'). As an example, your lambda should look like:
@lumigo_tracer(token='XXX')
def my_lambda(event, context):
print('I can finally troubleshoot!')
Configuration
- You can turn on the debug logs by setting the environment variable
LUMIGO_DEBUG=true - You can prevent lumigo from sending keys that answer specific regexes by defining
LUMIGO_SECRET_MASKING_REGEX=["regex1", "regex2"]. By default, we use the default regexes[".*pass.*", ".*key.*"]. All the regexes are case-insensitive. - Similarly, you can prevent lumigo from sending the entire headers and body of specific domains using the environment variable
LUMIGO_DOMAINS_SCRUBBER=[".*secret.*"](give it a list which is a json parsable), or by specify the list of regexes with the keydomains_scrubberin the tracer's decorator. By default, we will use["secretsmanager\..*\.amazonaws\.com", "ssm\..*\.amazonaws\.com", "kms\..*\.amazonaws\.com"]. - In case of need, there is a kill switch, that stops all the interventions of lumigo immediately, without changing the code. Simply add an environment variable
LUMIGO_SWITCH_OFF=true.
Logging Programmatic Errors
You can use report_error function to write logs which will be visible in the platform.
Add from lumigo_tracer import report_error.
Then use report_error("<msg>") from anywhere in your lambda code.
Adding Execution Tags
You can use add_execution_tag function to add an execution_tag with a dynamic value.
This value can be searched within the Lumigo platform.
Add from lumigo_tracer import add_execution_tag.
Then use add_execution_tag("<key>", "<value>") from anywhere in your lambda code.
Limitation:
- The maximum number of tags is 50.
- Key and value length should be between 1 and 50.
Step Functions
If this function is part of a step function, you can add the flag step_function=True or environment variable LUMIGO_STEP_FUNCTION=True, and we will track the states in the step function as a single transaction.
@lumigo_tracer(token='XXX', step_function=True)
def my_lambda(event, context):
print('Step function visibility!')
Note: we will add the key "_lumigo" to the return value of the function.
If you override the "Parameters" configuration, simply add "_lumigo.$": "$._lumigo".
For example:
"States": {
"state1": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-west-2:ACCOUNT:function:FUNCTION_NAME",
"Parameters": {
"Changed": "parameters",
"_lumigo.$": "$._lumigo"
},
"Next": "state2"
},
"state2": {
"Type": "pass",
"End": true
}
}
Frameworks
Chalice
- In chalice, you should add the following lines to the your file:
from lumigo_tracer import LumigoChalice
...
app = Chalice(app_name='chalice')
app = LumigoChalice(app, token="XXX")
Sentry/Raven Lambda Integration
Add our decorator beneath the Raven decorator
from lumigo_tracer import lumigo_tracer
...
@RavenLambdaWrapper()
@lumigo_tracer(token='XXX')
def lambda_handler (event, context): return {
'statusCode' : 200,
'body' : json.dumps( 'Hi!' ) }
How To Contribute
Prepare your machine
- Create a virtualenv
virtualenv venv -p python3 - Activate the virtualenv by running
. venv/bin/activate - Run
pip install -r requirements.txtto install dependencies. cd srcandpython setup.py develop.- If you use pycharm, make sure to change its virtualenv through the PyCharm -> Preferences -> Project -> Interpreter under the menu
- Run
pre-commit installin your repository to install pre-commits hooks.
Test
- To run the unit tests, run
py.testin the root folder. - To deploy the services for the component tests, move to the root test directory and run
sls deploy. This can be performed only once if the resources doesn't change. - To run the component tests, run
py.test --all.
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lumigo_tracer-1.1.121-py3-none-any.whl.
File metadata
- Download URL: lumigo_tracer-1.1.121-py3-none-any.whl
- Upload date:
- Size: 47.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69c4e0bf8ec6e690b274ae7bbf603308f43aa81d0cafd7cbff88adb71c5936f4
|
|
| MD5 |
a38e654a2e8e1d8a6e70003ed5b2b333
|
|
| BLAKE2b-256 |
11ed1a2eabaa08232367fd5d15564184af8d60749869a82487b99121a947c529
|