Python Installation [BETA]
Integrate Hud Python SDK for enhanced observability in your application in a few simple steps
Python support is currently in beta
While the core functionality is stable, some features may evolve. We welcome your feedback during this phase.
Prerequisites for Hud Integration
Before integrating Hud, please make sure your application meets the requirements.
1. Install SDK package
Run the installation command according to your package manager.
pip install hud-sdk
poetry add hud-sdk
2. Set environment variables
Configure the following environment variables to enable Hud's SDK:
HUD_ENABLE=true //Hud’s SDK will not be loaded without this being set to true
HUD_KEY=xxx //The API key provided to you, treat it as a secret
HUD_SERVICE=xxx //The service name which will identify this service
HUD_MODULES_TO_TRACE=server //The modules hud will trace, recommended when using running like gunicorn or celery; comma seprated string
Note: The environment variables need to be set before Hud's import
3. Initialize Hud in Your Application
Hud's SDK need to be imported and initialized as early as possible in your code, to make sure it maps any forthcoming modules' functions.
Call to init can be done after your imports. Note: the SDK does not map the functions in the file it's imported in.
# 1. Import Hud first
from hud_sdk.auto_hook import init
# 2. Add your imports
## from acme.api import server
# 3. Initialize Hud magic
init()
# 4. Run your code
## server.run()
4. Run your service and trigger it!
Start your service and trigger the functions you want to measure - metrics collection will begin automatically.
Then, head over to the web app to explore your data live, or install the IDE extension to view it directly alongside your code.
Updated 10 days ago