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

Fix crashdump report #1079

Merged
merged 1 commit into from
Jul 12, 2023
Merged
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
19 changes: 11 additions & 8 deletions depthai_sdk/src/depthai_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import urllib.request
from pathlib import Path
from typing import Dict, List, Tuple, Optional, Union, Any

import tempfile
try:
import cv2
except ImportError:
Expand Down Expand Up @@ -487,11 +487,14 @@ def report_crash_dump(device: dai.Device) -> None:
device_id = crash_dump.deviceId

crash_dump_json = crash_dump.serializeToJson()
path = f'/tmp/crash_{commit_hash}_{device_id}.json'
with open(path, 'w') as f:
json.dump(crash_dump_json, f)

from sentry_sdk import capture_exception, configure_scope
with configure_scope() as scope:
scope.add_attachment(content_type='application/json', path=path)
capture_exception(CrashDumpException())
# Save crash dump to a temporary file
with tempfile.TemporaryDirectory() as temp_dir:
path = Path(temp_dir) / f'crash_{commit_hash}_{device_id}.json'
with open(path, 'w') as f:
json.dump(crash_dump_json, f)

with configure_scope() as scope:
logging.info('Reporting crash dump to sentry.')
scope.add_attachment(content_type='application/json', path=path)
capture_exception(CrashDumpException())
Loading