Skip to content

Commit

Permalink
Add detailed posthog logging for /ingest failures
Browse files Browse the repository at this point in the history
  • Loading branch information
KastanDay committed Mar 6, 2024
1 parent 80a1119 commit 9460933
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion ai_ta_backend/beam/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,34 @@ def _ingest_single(ingest_method: Callable, s3_path, *args, **kwargs):
success_status['failure_ingest'].append(
f"We don't have a ingest method for this filetype: {file_extension} (with generic type {mime_type}), for file: {s3_path}"
)
self.posthog.capture(
'distinct_id_of_the_user',
event='Ingest Failure',
properties={
'course_name':
course_name,
's3_path':
s3_paths,
'kwargs':
kwargs,
'error':
f"We don't have a ingest method for this filetype: {file_extension} (with generic type {mime_type}), for file: {s3_path}"
})

return success_status
except Exception as e:
success_status['failure_ingest'].append(f"MAJOR ERROR IN /bulk_ingest: Error: {str(e)}")
err = f"❌❌ Error in /ingest: `{inspect.currentframe().f_code.co_name}`: {e}\nTraceback:\n", traceback.format_exc()

success_status['failure_ingest'].append(f"MAJOR ERROR IN /bulk_ingest: Error: {err}")
self.posthog.capture('distinct_id_of_the_user',
event='Ingest Failure',
properties={
'course_name': course_name,
's3_path': s3_paths,
'kwargs': kwargs,
'error': err
})

sentry_sdk.capture_exception(e)
print(f"MAJOR ERROR IN /bulk_ingest: Error: {str(e)}")
return success_status
Expand Down

0 comments on commit 9460933

Please sign in to comment.