Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions awx/api/generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ def initialize_request(self, request, *args, **kwargs):
"""
remote_headers = ['REMOTE_ADDR', 'REMOTE_HOST']

self.time_started = time.time()
if getattr(settings, 'SQL_DEBUG', False):
self.queries_before = len(connection.queries)

Expand Down Expand Up @@ -272,15 +271,13 @@ def finalize_response(self, request, response, *args, **kwargs):
logger.warning(status_msg)

response = super(APIView, self).finalize_response(request, response, *args, **kwargs)
time_started = getattr(self, 'time_started', None)
if request.user.is_authenticated:
response['X-API-Product-Version'] = get_awx_version()
response['X-API-Product-Name'] = detect_server_product_name()
# Note: X-API-Time and X-API-Node are added by ObservabilityMiddleware when profiling is enabled

response['X-API-Node'] = settings.CLUSTER_HOST_ID
if time_started:
time_elapsed = time.time() - self.time_started
response['X-API-Time'] = '%0.3fs' % time_elapsed
# SQL_DEBUG is a legacy setting, kept for backwards compatibility
# For production use, enable ANSIBLE_BASE_SQL_PROFILING instead
if getattr(settings, 'SQL_DEBUG', False):
queries_before = getattr(self, 'queries_before', 0)
q_times = [float(q['time']) for q in connection.queries[queries_before:]]
Expand Down
22 changes: 16 additions & 6 deletions awx/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import socket

DEBUG = True
SQL_DEBUG = DEBUG
# SQL_DEBUG is a legacy setting - use ANSIBLE_BASE_SQL_PROFILING instead
SQL_DEBUG = False

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
Expand Down Expand Up @@ -339,7 +340,6 @@
'rest_framework',
'django_extensions',
'polymorphic',
'django_guid',
'corsheaders',
'awx.conf',
'awx.main',
Expand Down Expand Up @@ -884,10 +884,9 @@
RECEPTOR_LOG_LEVEL = 'info'

MIDDLEWARE = [
'django_guid.middleware.guid_middleware',
'ansible_base.lib.middleware.observability.ObservabilityMiddleware',
'ansible_base.lib.middleware.logging.log_request.LogTracebackMiddleware',
'awx.main.middleware.SettingsCacheMiddleware',
'awx.main.middleware.TimingMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'awx.main.middleware.MigrationRanCheckMiddleware',
'corsheaders.middleware.CorsMiddleware',
Expand Down Expand Up @@ -932,8 +931,6 @@
# How often should web instances advertise themselves?
BROADCAST_WEBSOCKET_BEACON_FROM_WEB_RATE_SECONDS = 15

DJANGO_GUID = {'GUID_HEADER_NAME': 'X-API-Request-Id'}

# Name of the default task queue
DEFAULT_EXECUTION_QUEUE_NAME = 'default'
# pod spec used when the default execution queue is a container group, e.g. when deploying on k8s/ocp with the operator
Expand Down Expand Up @@ -1101,6 +1098,19 @@
ANSIBLE_BASE_ALLOW_SINGLETON_TEAM_ROLES = False # System auditor has always been restricted to users
ANSIBLE_BASE_ALLOW_SINGLETON_ROLES_API = False # Do not allow creating user-defined system-wide roles

# Observability and Profiling Settings
# Each feature can be independently enabled/disabled for safe production use
# ANSIBLE_BASE_PROFILE_TIMING: Add X-API-Time header (minimal overhead, safe for prod)
# ANSIBLE_BASE_PROFILE_NODE: Add X-API-Node header (may expose internal topology)
# ANSIBLE_BASE_CPROFILE_REQUESTS: Generate cProfile files (high overhead, debug only)
# ANSIBLE_BASE_SQL_PROFILING: Add SQL metrics + trace_id comments (moderate overhead)
ANSIBLE_BASE_PROFILE_TIMING = False
ANSIBLE_BASE_PROFILE_NODE = False
ANSIBLE_BASE_CPROFILE_REQUESTS = False
ANSIBLE_BASE_SQL_PROFILING = False
# Directory where cProfile files are written (defaults to system temp directory if not set)
ANSIBLE_BASE_CPROFILE_DIR = '/tmp'

# system username for django-ansible-base
SYSTEM_USERNAME = None

Expand Down
Loading