You can set additional configurations along with license key in the Python agent.
Configurations
You can set following configurations in the Python agent.
Option | Description | Type |
---|---|---|
LICENSE_KEY | APM License Key of your account. | string |
APP_NAME | Name of your Java project/app. | string |
APP_VERSION | Application version to identify release of your app. | string |
ENVIRONMENT | Environments allow you to easily filter data on your APM app. | string |
TRANSACTION_SAMPLE_RATE | Adjust the rate at which transactions are forwarded to Atatus, with the rate value ranging from 0 to 1. | integer |
ANALYTICS | Flag to enable/disable app analytics. | boolean |
LOG_BODY | Capture request and response body in analytics. | string |
ANALYTICS_CAPTURE_OUTGOING | Capture outgoing request and response body in analytics. | boolean |
ANALYTICS_SKIP | Function to skip/ignore a request in analytics. | function |
ANALYTICS_MASK | Function to mask field in analytics. | function |
SKIP | Function to skip/ignore a transaction in APM and analytics. | function |
SANITIZE_FIELD_NAMES | Configuration to customize the fields that will be sanitized in the headers, request body and response body | tuple |
HOSTNAME | Default hostname is machine name. You can override it by this option. | string |
ENABLED | Enable/Disable the Atatus Python agent. By default, it is set to True. | boolean |
In Django
# settings.py
ATATUS = {
'APP_NAME': 'Django App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'APP_VERSION': '1.0.0',
'ENVIRONMENT': 'production',
'ANALYTICS': True,
'ANALYTICS_CAPTURE_OUTGOING': True,
'LOG_BODY': 'all',
'HOSTNAME': 'web1.example.com',
'TRANSACTION_SAMPLE_RATE': 0.5,
'SANITIZE_FIELD_NAMES': (
"password",
"passwd",
"pwd",
"secret",
"*key",
"*token*",
"*session*",
"*credit*",
"*card*",
"*auth*",
"set-cookie",
),
'ENABLED': True
}
In Flask
# Add atatus agent to your app.
app.config['ATATUS'] = {
'APP_NAME': 'Flask App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'APP_VERSION': '1.0.0',
'ENVIRONMENT': 'production',
'ANALYTICS': True,
'ANALYTICS_CAPTURE_OUTGOING': True,
'LOG_BODY': 'all',
'HOSTNAME': 'web1.example.com',
'TRANSACTION_SAMPLE_RATE': 0.5,
'SANITIZE_FIELD_NAMES': (
"password",
"passwd",
"pwd",
"secret",
"*key",
"*token*",
"*session*",
"*credit*",
"*card*",
"*auth*",
"set-cookie",
),
'ENABLED': True
}
atatus = Atatus(app)
Setting app version
If you use an appVersion to identify releases of your app, you can send it to Atatus. It is highly recommended to set appVersion.
In Django
# settings.py
ATATUS = {
'APP_NAME': 'Django App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'APP_VERSION': '1.0.0'
}
In Flask
# Add atatus agent to your app.
app.config['ATATUS'] = {
'APP_NAME': 'Flask App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'APP_VERSION': '1.0.0'
}
atatus = Atatus(app)
Setting environment
If you are tracking multiple environments with a single APM project, then you can set a environment as follows.
In Django
# settings.py
ATATUS = {
'APP_NAME': 'Django App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ENVIRONMENT': 'production'
}
In Flask
# Add atatus agent to your app.
app.config['ATATUS'] = {
'APP_NAME': 'Flask App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ENVIRONMENT': 'production'
}
atatus = Atatus(app)
Setting analytics
App Analytics collects all requests individually with contextual data.
In Django
# settings.py
ATATUS = {
'APP_NAME': 'Django App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True
}
In Flask
# Add atatus agent to your app.
app.config['ATATUS'] = {
'APP_NAME': 'Flask App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True
}
atatus = Atatus(app)
Enable log body
The log body option is available only for analytics
This log body option is disabled by default. If you want to capture request and/or response body in analytics, you can set this option. There are three possible values when enabling log body in analytics.
all: Capture both request body and response body. request: Capture only request body. response: Capture only response body.
In Django
# settings.py
ATATUS = {
'APP_NAME': 'Django App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True,
'LOG_BODY': 'all' # 'all' (or) 'request' (or) 'response'
}
In Flask
# Add atatus agent to your app.
app.config['ATATUS'] = {
'APP_NAME': 'Flask App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True,
'LOG_BODY': 'all' # 'all' (or) 'request' (or) 'response'
}
atatus = Atatus(app)
Enable capture outgoing API calls
If you want to capture outgoing request and/or response body in analytics, you can set this option. This capture outgoing option is disabled by default.
In Django
# settings.py
ATATUS = {
'APP_NAME': 'Django App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True,
'LOG_BODY': 'all', # 'all' (or) 'request' (or) 'response'
'ANALYTICS_CAPTURE_OUTGOING': True
}
In Flask
# Add atatus agent to your app.
app.config['ATATUS'] = {
'APP_NAME': 'Flask App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True,
'LOG_BODY': 'all', # 'all' (or) 'request' (or) 'response'
'ANALYTICS_CAPTURE_OUTGOING': True
}
atatus = Atatus(app)
Setting analytics skip function
The ANALYTICS_SKIP
function helps you exclude specific API requests (such as health-related requests) from being sent to Atatus.
In Django
# settings.py
def skip_analytics_event(event):
# define url segments that you want to skip
skip_urls = ['/health', '/books_fbv/edit', '/books_fbv/new', '/books_fbv/']
if any(item in event['url'] for item in skip_urls):
return True
# define transaction names that you want to skip
skip_transactions = ['books_cbv.views.BookCreate', 'books_cbv.views.BookUpdate']
if any(item in event['name'] for item in skip_transactions):
return True
# Skip content type text/html
if 'Content-Type' in event['responseHeaders'] and 'text/html' in event['responseHeaders']['Content-Type']:
return True
return False
ATATUS = {
'APP_NAME': 'Django App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True,
'LOG_BODY': 'all', # 'all' (or) 'request' (or) 'response'
'ANALYTICS_SKIP': skip_analytics_event
}
In Flask
def skip_analytics_event(event):
# define url segments that you want to skip
skip_urls = ['/health', '/books_fbv/edit', '/books_fbv/new', '/books_fbv/']
if any(item in event['url'] for item in skip_urls):
return True
# define transaction names that you want to skip
skip_transactions = ['books_cbv.views.BookCreate', 'books_cbv.views.BookUpdate']
if any(item in event['name'] for item in skip_transactions):
return True
# Skip content type text/html
if 'Content-Type' in event['responseHeaders'] and 'text/html' in event['responseHeaders']['Content-Type']:
return True
return False
# Add atatus agent to your app.
app.config['ATATUS'] = {
'APP_NAME': 'Flask App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True,
'LOG_BODY': 'all', # 'all' (or) 'request' (or) 'response'
'ANALYTICS_SKIP': skip_analytics_event
}
atatus = Atatus(app)
Setting analytics mask function
The ANALYTICS_MASK
function allows you to modify the request/response headers, body, or query parameters before they are sent to Atatus. You can utilize this function to make alterations such as removing specific header or body fields. It will give you the flexibility to customize the request data that is ultimately sent to Atatus.
In Django
# settings.py
def mask_analytics_event(event):
if 'x-powered-by' in event.responseHeaders:
event.responseHeaders['x-powered-by'] = ''
ATATUS = {
'APP_NAME': 'Django App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True,
'LOG_BODY': 'all', # 'all' (or) 'request' (or) 'response'
'ANALYTICS_MASK': mask_analytics_event
}
In Flask
def mask_analytics_event(event):
if 'x-powered-by' in event.responseHeaders:
event.responseHeaders['x-powered-by'] = ''
# Add atatus agent to your app.
app.config['ATATUS'] = {
'APP_NAME': 'Flask App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True,
'LOG_BODY': 'all', # 'all' (or) 'request' (or) 'response'
'ANALYTICS_MASK': mask_analytics_event
}
atatus = Atatus(app)
Setting skip event function
The SKIP
function helps you exclude specific transactions, errors, HTTP failures, as well as analytics requests from being sent to Atatus.
In Django
# settings.py
def skip_event(event):
# define url segments that you want to skip
skip_urls = ['/health', '/books_fbv/edit', '/books_fbv/new', '/books_fbv/']
if any(item in event['url'] for item in skip_urls):
return True
# define transaction names that you want to skip
skip_transactions = ['books_cbv.views.BookCreate', 'books_cbv.views.BookUpdate']
if any(item in event['name'] for item in skip_transactions):
return True
return False
ATATUS = {
'APP_NAME': 'Django App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'SKIP': skip_event
}
In Flask
def skip_event(event):
# define url segments that you want to skip
skip_urls = ['/health', '/books_fbv/edit', '/books_fbv/new', '/books_fbv/']
if any(item in event['url'] for item in skip_urls):
return True
# define transaction names that you want to skip
skip_transactions = ['books_cbv.views.BookCreate', 'books_cbv.views.BookUpdate']
if any(item in event['name'] for item in skip_transactions):
return True
return False
# Add atatus agent to your app.
app.config['ATATUS'] = {
'APP_NAME': 'Flask App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'SKIP': skip_event
}
atatus = Atatus(app)
Configure a custom host name
By default, we will fetch the host name using Python, but you can override this as follows:
In Django
# settings.py
ATATUS = {
'APP_NAME': 'Django App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'HOSTNAME': 'web1.example.com'
}
In Flask
# Add atatus agent to your app.
app.config['ATATUS'] = {
'APP_NAME': 'Flask App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'HOSTNAME': 'web1.example.com'
}
atatus = Atatus(app)
Configuration for transaction sample rate
To ensure Atatus receives a representative sample of your transactions, configure the sample rate option in your agent settings. Set this value between 0 (sending 0% of transactions) and 1 (sending 100% of transactions). This rate remains consistent across all transactions. For instance, to sample 50% of your transactions:
In Django
# settings.py
ATATUS = {
'APP_NAME': 'Django App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True,
'LOG_BODY': 'all', # 'all' (or) 'request' (or) 'response'
'TRANSACTION_SAMPLE_RATE': 0.5
}
In Flask
# Add atatus agent to your app.
app.config['ATATUS'] = {
'APP_NAME': 'Flask App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True,
'LOG_BODY': 'all', # 'all' (or) 'request' (or) 'response'
'TRANSACTION_SAMPLE_RATE': 0.5
}
atatus = Atatus(app)
Configuration for sanitizing data
By default, we automatically sanitize certain data that is being sent to us in request and response headers and body. You can configure by adding or removing certain fields using the configuration SANITIZE_FIELD_NAMES
:
In Django
# settings.py
ATATUS = {
'APP_NAME': 'Django App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True,
'LOG_BODY': 'all', # 'all' (or) 'request' (or) 'response'
'SANITIZE_FIELD_NAMES': (
"password",
"passwd",
"pwd",
"secret",
"*key",
"*token*",
"*session*",
"*credit*",
"*card*",
"*auth*",
"set-cookie",
)
}
In Flask
# Add atatus agent to your app.
app.config['ATATUS'] = {
'APP_NAME': 'Flask App',
'LICENSE_KEY': 'lic_apm_xxxxxxx',
'ANALYTICS': True,
'LOG_BODY': 'all', # 'all' (or) 'request' (or) 'response'
'SANITIZE_FIELD_NAMES': (
"password",
"passwd",
"pwd",
"secret",
"*key",
"*token*",
"*session*",
"*credit*",
"*card*",
"*auth*",
"set-cookie",
)
}
atatus = Atatus(app)
For other configurations, you can use the APIs