Lumigo Docs

Python

Instructions for manually installing the Lumigo tracer in a Lambda Python environment

Overview

This page will help you to set up the Lumigo tracer. This allows for manual tracing of your Lambda functions.

To begin, add the following line to your requirements.txt file:

lumigo_tracer

Next, open your Lambda function code. Import the lumigo tracer so that it may be used locally:

from lumigo_tracer import lumigo_tracer

Once you've imported the tracer, add the lumigo_tracer decorator to your Lambda function's handler. Use your Lumigo token which can be found in the Onboarding Page.

@lumigo_tracer(token='YOUR TOKEN HERE', enhance_print=True)
def my_lambda(event, context):
    print('I can view this line now')

Once these two steps have been completed, your code should resemble the following example:

import json
from lumigo_tracer import lumigo_tracer
...
@lumigo_tracer(token='YOUR TOKEN HERE')
def lambda_handler(event, context):
  return {
    'statusCode': 200,
    'body': json.dumps('Hi!')
  }

Features

Support for Enhanced Print

If you are using print() or python logging to log information from your source code, you are able to make use of Lumigo's enhanced print capabilities. this feature of the tracer allows you to view your logs as they are in the platform view.

To enable support for Enhanced Print, add enhance_print=True to the tracer configuration as shown in the following code sample:

@lumigo_tracer(token='YOUR TOKEN HERE', enhance_print=True)
def my_lambda(event, context):
    print('I can view this line now')

Framework Support

Lumigo's Manual Tracing can be configured for many popular frameworks

Chalice

Add the following lines to your Lambda function's file to enable Chalice support for Lumigo:

from lumigo_tracer import LumigoChalice
...
app = Chalice(app_name='hello-world')
app = LumigoChalice(app, token='YOUR TOKEN HERE')
...

Sentry/Raven Lambda Integration

To enable Sentry/Raven integration, simply add the @lumigo_tracer decorator beneath the Raven decorator for your handler function:

from lumigo_tracer import lumigo_tracer
...
@RavenLambdaWrapper()
@lumigo_tracer(token='YOUR TOKEN HERE')
def lambda_handler(event, context):
  return {
    'statusCode': 200,
    'body': json.dumps('Hi!')
  }

📘

Using Lambda Layers?

You can find our Python Lambda Layer here.

Learn more about Lambda Layers

👍

Using Step Functions?

Monitor your step functions by adding the flag step_function=True to your @lumigo_tracer decorator.

Learn more about our step function support on our GitHub repository

Updated 6 months ago


Python


Instructions for manually installing the Lumigo tracer in a Lambda Python environment

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.