mirror of
https://github.com/ansible/awx.git
synced 2026-05-03 23:55:28 -02:30
add a per-request GUID and log as it travels through background services
see: https://github.com/ansible/awx/issues/9329
This commit is contained in:
@@ -15,6 +15,10 @@ from django.apps import apps
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
|
||||
from django_guid.log_filters import CorrelationId
|
||||
from django_guid.middleware import GuidMiddleware
|
||||
|
||||
from awx import MODE
|
||||
from awx.main.constants import LOGGER_BLOCKLIST
|
||||
from awx.main.utils.common import get_search_fields
|
||||
|
||||
@@ -364,3 +368,14 @@ class SmartFilter(object):
|
||||
return res[0].result
|
||||
|
||||
raise RuntimeError("Parsing the filter_string %s went terribly wrong" % filter_string)
|
||||
|
||||
|
||||
|
||||
class DefaultCorrelationId(CorrelationId):
|
||||
|
||||
def filter(self, record):
|
||||
guid = GuidMiddleware.get_guid() or '-'
|
||||
if MODE == 'development':
|
||||
guid = guid[:8]
|
||||
record.guid = guid
|
||||
return True
|
||||
|
||||
@@ -154,6 +154,9 @@ class LogstashFormatter(LogstashFormatterBase):
|
||||
|
||||
if kind == 'job_events' and raw_data.get('python_objects', {}).get('job_event'):
|
||||
job_event = raw_data['python_objects']['job_event']
|
||||
guid = job_event.event_data.pop('guid', None)
|
||||
if guid:
|
||||
data_for_log['guid'] = guid
|
||||
for field_object in job_event._meta.fields:
|
||||
|
||||
if not field_object.__class__ or not field_object.__class__.__name__:
|
||||
|
||||
Reference in New Issue
Block a user