GeniePy comes with built-in support for tracking application performance using Datadog.
Datadog is an excellent service for measuring application performance metrics of different kinds.
In this how-to, we'll focus on enabling two kinds of metrics: Application Performance Monitoring (also known as Tracing), and Dogstatsd metrics.
Register for a Datadog account if you do not already have one.
After you have an account, generate an API key and an application key for sending application data over to Datadog. Datadog has good documentation on what those two keys mean and how to generate them here: https://docs.datadoghq.com/account_management/api-app-keys/.
In short, API keys are unique to your organization while Application (or App) keys are required for programmatic access to the Datadog API.
- Generate an API key here: https://datadoghq.com/organization-settings/api-keys
- Generate an Application key here: https://datadoghq.com/organization-settings/application-keys
Before enabling tracing or dogstatsd metrics, set the following two environment variables:
DATADOG_API_KEY: this is the API key generated in the previous step
DATADOG_APP_KEY: this is the application key generated in the previous step
Application Performance Monitoring (Tracing)
DDTRACE_ENABLED environment variable to
This will automatically patch Starlette and SQLAlchemy to start sending application level traces to Datadog. These traces will start appearing in your APM dashboard.
DOGSTATSD_ENABLED environment variable to
This will start a thread in the main application process that sends over custom metrics to the Datadog agent container, which in turn sends them over to Datadog. All these metrics will start appearing in your Metrics Explorer.
In local development, we've switched both
DOGSTATSD_ENABLED variables to
In case you'd like to enable them locally to debug performance issues, simply
set them both (or either one of them) to
true and restart the main application