Skip to content

Commit

Permalink
[Sentry] add sentry tracker when dsn is set
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Aug 21, 2024
1 parent c23ef03 commit 9ca79b4
Show file tree
Hide file tree
Showing 15 changed files with 347 additions and 916 deletions.
2 changes: 0 additions & 2 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ wheel
pur

pylint

sentry-sdk==1.29.2
25 changes: 13 additions & 12 deletions octobot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
#
# You should have received a copy of the GNU General Public
# License along with OctoBot. If not, see <https://www.gnu.org/licenses/>.

import packaging.version as packaging_version

import time
import argparse
import os
import sys
import multiprocessing
import asyncio
import packaging.version as packaging_version

import octobot_commons.os_util as os_util
import octobot_commons.logging as logging
Expand Down Expand Up @@ -294,6 +293,8 @@ def start_octobot(args):
# Current running environment
_log_environment(logger)

octobot_community.init_sentry_tracker()

# load configuration
config, is_first_startup = _create_startup_config(logger)

Expand Down Expand Up @@ -326,9 +327,6 @@ def start_octobot(args):
# Can now perform config health check (some checks require a loaded profile)
configuration_manager.config_health_check(config, args.backtesting)

# Keep track of errors if any
octobot_community.register_error_uploader(constants.ERRORS_POST_ENDPOINT, config)

# Apply config limits if any
startup_messages += limits.apply_config_limits(config)

Expand Down Expand Up @@ -362,43 +360,46 @@ def start_octobot(args):
_disable_interface_from_param("web", args.no_web, logger)

commands.run_bot(bot, logger)

force_error_exit = False
except errors.RemoteConfigError as err:
logger.exception(err)
os._exit(-1)
force_error_exit = True

except errors.ConfigError as err:
logger.error("OctoBot can't start without a valid " + common_constants.CONFIG_FILE
+ " configuration file.\nError: " + str(err) + "\nYou can use " +
constants.DEFAULT_CONFIG_FILE + " as an example to fix it.")
os._exit(-1)
force_error_exit = True

except errors.NoProfileError:
logger.error("Missing default profiles. OctoBot can't start without a valid default profile configuration. "
"Please make sure that the {config.profiles_path} "
f"folder is accessible. To reinstall default profiles, delete the "
f"'{tentacles_manager_constants.TENTACLES_PATH}' "
f"folder or start OctoBot with the following arguments: tentacles --install --all")
os._exit(-1)
force_error_exit = True

except ModuleNotFoundError as err:
if 'tentacles' in str(err):
logger.error("Impossible to start OctoBot, tentacles are missing.\nTo install tentacles, "
"please use the following command:\nstart.py tentacles --install --all")
else:
logger.exception(err)
os._exit(-1)
force_error_exit = True

except errors.ConfigEvaluatorError:
logger.error("OctoBot can't start without a valid configuration file.\n"
"This file is generated on tentacle "
"installation using the following command:\nstart.py tentacles --install --all")
os._exit(-1)
force_error_exit = True

except errors.ConfigTradingError:
logger.error("OctoBot can't start without a valid configuration file.\n"
"This file is generated on tentacle "
"installation using the following command:\nstart.py tentacles --install --all")
force_error_exit = True
if force_error_exit:
octobot_community.flush_tracker()
os._exit(-1)


Expand Down
10 changes: 4 additions & 6 deletions octobot/community/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@
community_feed_factory,
)
from octobot.community.errors_upload import (
register_error_uploader,
Error,
ErrorsUploader,
init_sentry_tracker,
flush_tracker,
)
from octobot.community.identifiers_provider import (
IdentifiersProvider,
Expand All @@ -102,9 +101,8 @@
"CommunityTentaclesPackage",
"CommunitySupports",
"CommunityDonation",
"register_error_uploader",
"Error",
"ErrorsUploader",
"init_sentry_tracker",
"flush_tracker",
"StartupInfo",
"StrategyData",
"SyncConfigurationStorage",
Expand Down
20 changes: 6 additions & 14 deletions octobot/community/errors_upload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,13 @@
# You should have received a copy of the GNU General Public
# License along with OctoBot. If not, see <https://www.gnu.org/licenses/>.

from octobot.community.errors_upload import initializer
from octobot.community.errors_upload.initializer import (
register_error_uploader,
)
from octobot.community.errors_upload import error_model
from octobot.community.errors_upload.error_model import (
Error,
)
from octobot.community.errors_upload import errors_uploader
from octobot.community.errors_upload.errors_uploader import (
ErrorsUploader,
from octobot.community.errors_upload import sentry_tracker
from octobot.community.errors_upload.sentry_tracker import (
init_sentry_tracker,
flush_tracker,
)

__all__ = [
"register_error_uploader",
"Error",
"ErrorsUploader",
"init_sentry_tracker",
"flush_tracker",
]
62 changes: 0 additions & 62 deletions octobot/community/errors_upload/error_model.py

This file was deleted.

110 changes: 0 additions & 110 deletions octobot/community/errors_upload/errors_uploader.py

This file was deleted.

49 changes: 0 additions & 49 deletions octobot/community/errors_upload/initializer.py

This file was deleted.

Loading

0 comments on commit 9ca79b4

Please sign in to comment.