Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update logger extra for sentry-logging #1399

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion apps/analysis/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ def validate(self, data):
if snaphost_file is None:
logger.error(
f'Failed to generate snapshot for report-pk: {report.id}',
extra={'context': errors}
extra={'data': {'errors': errors}},
)
raise serializers.ValidationError('Failed to generate snapshot')
data['report_data_file'] = snaphost_file
Expand Down
27 changes: 18 additions & 9 deletions apps/deepl_integration/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,27 @@ def send_trigger_request_to_extractor(cls, draft_entry):
'authoring_organization': author_organizations,
'callback_url': cls.get_callback_url(),
}
response_content = None
try:
response = requests.post(
DeeplServiceEndpoint.ASSISTED_TAGGING_ENTRY_PREDICT_ENDPOINT,
headers=cls.REQUEST_HEADERS,
json=payload
)
response_content = response.content
if response.status_code == 202:
return True
except Exception:
logger.error('Assisted tagging send failed, Exception occurred!!', exc_info=True)
draft_entry.prediction_status = DraftEntry.PredictionStatus.SEND_FAILED
draft_entry.save(update_fields=('prediction_status',))
_response = locals().get('response')
logger.error(
'Assisted tagging send failed!!',
extra={
'payload': payload,
'response': _response.content if _response else None
'data': {
'payload': payload,
'response': response_content,
},
},
)

Expand Down Expand Up @@ -365,12 +368,14 @@ def auto_trigger_request_to_extractor(cls, lead):
],
"callback_url": cls.get_callback_url()
}
response_content = None
try:
response = requests.post(
url=DeeplServiceEndpoint.ENTRY_EXTRACTION_CLASSIFICATION,
headers=cls.REQUEST_HEADERS,
json=payload
)
response_content = response.content
if response.status_code == 202:
lead.auto_entry_extraction_status = Lead.AutoExtractionStatus.PENDING
lead.save(update_fields=('auto_entry_extraction_status',))
Expand All @@ -380,12 +385,13 @@ def auto_trigger_request_to_extractor(cls, lead):
logger.error('Entry Extraction send failed, Exception occurred!!', exc_info=True)
lead.auto_entry_extraction_status = Lead.AutoExtractionStatus.FAILED
lead.save(update_fields=('auto_entry_extraction_status',))
_response = locals().get('response')
logger.error(
'Entry Extraction send failed!!',
extra={
'payload': payload,
'response': _response.content if _response else None
'data': {
'payload': payload,
'response': response_content,
},
},
)

Expand Down Expand Up @@ -566,23 +572,24 @@ def send_trigger_request_to_extractor(
'callback_url': callback_url,
'request_type': NlpRequestType.USER if high_priority else NlpRequestType.SYSTEM,
}
response_content = None
try:
response = requests.post(
DeeplServiceEndpoint.DOCS_EXTRACTOR_ENDPOINT,
headers=cls.REQUEST_HEADERS,
data=json.dumps(payload)
)
response_content = response.content
if response.status_code == 202:
return True
except Exception:
logger.error('Lead Extraction Failed, Exception occurred!!', exc_info=True)
_response = locals().get('response')
logger.error(
'Lead Extraction Request Failed!!',
extra={
'data': {
'payload': payload,
'response': _response.content if _response else None
'response': response_content
}
},
)
Expand Down Expand Up @@ -871,7 +878,9 @@ def send_trigger_request_to_extractor(cls, obj: DeeplTrackBaseModel):
logger.error(
f'{cls.model.__name__} send failed!!',
extra={
'context': error_extra_context
'data': {
'context': error_extra_context
}
}
)
obj.status = cls.model.Status.SEND_FAILED
Expand Down
Loading