highlight_io.integrations.Integration
optional
RequestsIntegration() for the Requests library.
Highlight's Python SDK makes it easy to monitor errors and logs on your Python backend.
Check out our getting started guide to get up and running quickly.
H() initializes the Highlight backend SDK.
List[Integration]
optional
A list of integrations to disable.
highlight_io.integrations.Integration
optional
RequestsIntegration() for the Requests library.
boolean
optional
If enabled, Highlight will record log output from the logging module.
string
optional
The name of your app.
string
optional
The version of this app. We recommend setting this to the most recent deploy SHA of your app.
string
optional
Specifies the environment your application is running in. This helpful to differentiate if your project is running in production or locally.
import highlight_io
from highlight_io.integrations.flask import FlaskIntegration
app = Flask('test-app')
H = highlight_io.H(
"<YOUR_PROJECT_ID>",
integrations=[FlaskIntegration()],
instrument_logging=True,
service_name="my-flask-app",
service_version="git-sha",
environment="production"
)
import highlight_io
from highlight_io.integrations.django import DjangoIntegration
H = highlight_io.H(
"<YOUR_PROJECT_ID>",
integrations=[DjangoIntegration()],
instrument_logging=True,
service_name="my-django-app",
service_version="git-sha",
environment="production"
)
import highlight_io
from highlight_io.integrations.fastapi import FastAPIMiddleware
H = highlight_io.H(
"<YOUR_PROJECT_ID>",
instrument_logging=True,
service_name="my-fastapi-app",
service_version="git-sha",
environment="production"
)
app = FastAPI()
app.add_middleware(FastAPIMiddleware)
Record arbitrary exceptions raised within your app.
Exception
optional
The exception to record. The contents and stacktrace will be recorded.
dict[str, any]
optional
Metadata to associate with this exception.
try:
for i in range(20):
result = 100 / (10 - i)
print(f'dangerous: {result}')
except Exception as e:
H.record_exception(e)
Catch exceptions raised by your app using this context manager. Exceptions will be recorded with the Highlight project and associated with a frontend session when headers are provided. Exceptions will be re-raised in case you want to have them propagate.
string
optional
A Highlight session ID that the request is being made from. If omitted, the error will be associated with the project ID passed to H().
string
optional
A Highlight network request ID that initiated the handler raising this error.
dict[str, any]
optional
Metadata to associate with this exception.
with H.trace(span_name="my_span"):
for idx in range(1000):
logging.info(f"hello {idx}")
time.sleep(0.001)
if random.randint(0, 100) == 1:
raise Exception(f"random error! {idx}")
logging.warning("made it outside the loop!")