Backend: Error Monitoring
Go
JS
Python
Backend: Logging
Fullstack Frameworks
Next.JS
Self Host & Local Dev
Menu
Using highlight.io with Other Python Frameworks
Learn how to set up highlight.io in your Python app.
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,
},
});
2
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
# or with pip
pip install highlight-io
3
Initialize the Highlight SDK.
Setup the SDK.
import highlight_io
H = highlight_io.H("YOUR_PROJECT_ID", record_logs=True)
4
Verify your installation.
Check that your installation is valid by throwing an error. Try raising an exception somewhere in your code. You should see a DivideByZero
error in the Highlight errors page within a few moments.
import logging
import random
import time
import highlight_io
H = highlight_io.H("YOUR_PROJECT_ID", record_logs=True)
def main():
with H.trace():
logging.info('hello, world!', {'favorite_number': 7})
return f"<h1>bad idea { 5/0 }</h1>"
if __name__ == "__main__":
main()
5
Verify your backend logs are being recorded.
With the Python SDK, your logs are reported automatically from the builtin logging methods (as long as record_logs=True
is provided to the highlight_io.H
constructor). Visit the highlight logs portal and check that backend logs are coming in.