|
|
|
@ -605,11 +605,35 @@ def threaded(func): |
|
|
|
|
|
|
|
|
|
def set_sentry(): |
|
|
|
|
""" |
|
|
|
|
Initialize the Sentry SDK for error tracking and reporting if pytest is not currently running. |
|
|
|
|
Initialize the Sentry SDK for error tracking and reporting. Enabled when sync=True in settings and |
|
|
|
|
disabled when sync=False. Run 'yolo settings' to see and update settings YAML file. |
|
|
|
|
|
|
|
|
|
Conditions required to send errors: |
|
|
|
|
- sync=True in YOLO settings |
|
|
|
|
- pytest is not running |
|
|
|
|
- running in a pip package installation |
|
|
|
|
- running in a non-git directory |
|
|
|
|
- running with rank -1 or 0 |
|
|
|
|
- online environment |
|
|
|
|
- CLI used to run package (checked with 'yolo' as the name of the main CLI command) |
|
|
|
|
|
|
|
|
|
The function also configures Sentry SDK to ignore KeyboardInterrupt and FileNotFoundError |
|
|
|
|
exceptions and to exclude events with 'out of memory' in their exception message. |
|
|
|
|
|
|
|
|
|
Additionally, the function sets custom tags and user information for Sentry events. |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
def before_send(event, hint): |
|
|
|
|
"""A function executed before sending the event to Sentry.""" |
|
|
|
|
""" |
|
|
|
|
Modify the event before sending it to Sentry based on specific exception types and messages. |
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
|
event (dict): The event dictionary containing information about the error. |
|
|
|
|
hint (dict): A dictionary containing additional information about the error. |
|
|
|
|
|
|
|
|
|
Returns: |
|
|
|
|
dict: The modified event or None if the event should not be sent to Sentry. |
|
|
|
|
""" |
|
|
|
|
if 'exc_info' in hint: |
|
|
|
|
exc_type, exc_value, tb = hint['exc_info'] |
|
|
|
|
if exc_type in (KeyboardInterrupt, FileNotFoundError) \ |
|
|
|
@ -628,19 +652,19 @@ def set_sentry(): |
|
|
|
|
Path(sys.argv[0]).name == 'yolo' and \ |
|
|
|
|
not TESTS_RUNNING and \ |
|
|
|
|
ONLINE and \ |
|
|
|
|
((is_pip_package() and not is_git_dir()) or |
|
|
|
|
(get_git_origin_url() == 'https://github.com/ultralytics/ultralytics.git' and get_git_branch() == 'main')): |
|
|
|
|
is_pip_package() and \ |
|
|
|
|
not is_git_dir(): |
|
|
|
|
|
|
|
|
|
import sentry_sdk # noqa |
|
|
|
|
sentry_sdk.init( |
|
|
|
|
dsn='https://f805855f03bb4363bc1e16cb7d87b654@o4504521589325824.ingest.sentry.io/4504521592406016', |
|
|
|
|
dsn='https://5ff1556b71594bfea135ff0203a0d290@o4504521589325824.ingest.sentry.io/4504521592406016', |
|
|
|
|
debug=False, |
|
|
|
|
traces_sample_rate=1.0, |
|
|
|
|
release=__version__, |
|
|
|
|
environment='production', # 'dev' or 'production' |
|
|
|
|
before_send=before_send, |
|
|
|
|
ignore_errors=[KeyboardInterrupt, FileNotFoundError]) |
|
|
|
|
sentry_sdk.set_user({'id': SETTINGS['uuid']}) |
|
|
|
|
sentry_sdk.set_user({'id': SETTINGS['uuid']}) # SHA-256 anonymized UUID hash |
|
|
|
|
|
|
|
|
|
# Disable all sentry logging |
|
|
|
|
for logger in 'sentry_sdk', 'sentry_sdk.errors': |
|
|
|
|