Star us on GitHub
Star
Menu

AWS Lambda Tracing

Learn how to set up highlight.io tracing for on AWS Lambda.

1

Setup your frontend Highlight snippet with tracingOrigins.

Make sure that you followed the fullstack mapping guide.

H.init("<YOUR_PROJECT_ID>", { tracingOrigins: ['localhost', 'example.myapp.com/backend'], networkRecording: { enabled: true, recordHeadersAndBody: true, }, });
Copy
2

Optionally, set up OTel auto-instrumentation.

Follow the instructions for setting up AWS Lambda auto-instrumentation. This is not required, but can be used independently or alongside manual instrumentation (documented below).

3

Install the highlight-io python package.

Download the package from pypi and save it to your requirements. If you use a zip or s3 file upload to publish your function, you will want to make sure highlight-io is part of the build.

poetry add highlight-io
Copy
# or with pip pip install highlight-io
Copy
4

Initialize the Highlight SDK.

Setup the SDK. Add the @observe_handler decorator to your lambdas.

import highlight_io from highlight_io.integrations.aws import observe_handler # `instrument_logging=True` sets up logging instrumentation. # if you do not want to send logs or are using `loguru`, pass `instrument_logging=False` H = highlight_io.H( "<YOUR_PROJECT_ID>", instrument_logging=True, service_name="my-app", service_version="git-sha", environment="production", ) @observe_handler def lambda_handler(event, context): return { "statusCode": 200, "body": f"Hello, {name}. This HTTP triggered function executed successfully.", }
Copy
5

Hit your Lambda function.

Setup an HTTP trigger and visiting your Lambda on the internet.

6

Verify your backend traces are being recorded.

Visit the highlight traces portal and check that backend traces are coming in.