I will take an example of an application for blog creation and listing API using Python Django framework. First, we have to install the APM agent for Python Django:
pip install elastic-apm
Then, we have to configure the agent with the Django application; we need to make the following changes in the settings.py file:
# Add the agent to the installed apps
INSTALLED_APPS = (
'elasticapm.contrib.django',
# ...
)
ELASTIC_APM = {
# Set required service name. Allowed characters:
# a-z, A-Z, 0-9, -, _, and space
'SERVICE_NAME': 'django application',
# Use if APM Server requires a token
'SECRET_TOKEN': 'mysecrettoken',
# Set custom APM Server URL (default: http://localhost:8200)
'SERVER_URL': 'http://localhost:8200',
}
# To send performance metrics, add our tracing middleware...