Skip to content

Commit

Permalink
Remove sentry support (#117)
Browse files Browse the repository at this point in the history
* Remove sentry support

* Remove sentry support
  • Loading branch information
lalinsky authored Feb 13, 2024
1 parent 5c05072 commit 5dceef9
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 56 deletions.
7 changes: 0 additions & 7 deletions acoustid/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def run_web_cmd(config, workers=None, threads=None):
os.environ["ACOUSTID_CONFIG"] = config
script = Script(config)
script.setup_console_logging()
script.setup_sentry()
run_web_app(script.config, workers=workers, threads=threads)


Expand All @@ -47,7 +46,6 @@ def run_api_cmd(config, workers=None, threads=None):
os.environ["ACOUSTID_CONFIG"] = config
script = Script(config)
script.setup_console_logging()
script.setup_sentry()
run_api_app(script.config, workers=workers, threads=threads)


Expand All @@ -57,7 +55,6 @@ def run_cron_cmd(config: str) -> None:
"""Run cron."""
script = Script(config)
script.setup_console_logging()
script.setup_sentry()
run_cron(script)


Expand All @@ -67,7 +64,6 @@ def run_worker_cmd(config: str) -> None:
"""Run worker."""
script = Script(config)
script.setup_console_logging()
script.setup_sentry()
run_worker(script)


Expand All @@ -78,7 +74,6 @@ def run_import_cmd(config):
"""Run import."""
script = Script(config)
script.setup_console_logging(verbose=True)
script.setup_sentry()
run_import(script)


Expand All @@ -90,7 +85,6 @@ def run_script_cmd(name, config):
"""Run a built-in script."""
script = Script(config)
script.setup_console_logging()
script.setup_sentry()
mod = importlib.import_module("acoustid.scripts.{}".format(name))
func_name = "run_{}".format(name)
func = getattr(mod, func_name)
Expand All @@ -106,7 +100,6 @@ def shell_cmd(config):

script = Script(config)
script.setup_console_logging()
script.setup_sentry()
with script.context() as ctx:
_ = ctx
IPython.embed()
Expand Down
24 changes: 0 additions & 24 deletions acoustid/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,27 +453,6 @@ def read_env(self, prefix):
)


class SentryConfig(BaseConfig):
def __init__(self):
self.web_dsn = ""
self.api_dsn = ""
self.script_dsn = ""

def read_section(self, parser, section):
# type: (RawConfigParser, str) -> None
if parser.has_option(section, "web_dsn"):
self.web_dsn = parser.get(section, "web_dsn")
if parser.has_option(section, "api_dsn"):
self.api_dsn = parser.get(section, "api_dsn")
if parser.has_option(section, "script_dsn"):
self.script_dsn = parser.get(section, "script_dsn")

def read_env(self, prefix):
read_env_item(self, "web_dsn", prefix + "SENTRY_WEB_DSN")
read_env_item(self, "api_dsn", prefix + "SENTRY_API_DSN")
read_env_item(self, "script_dsn", prefix + "SENTRY_SCRIPT_DSN")


class StatsdConfig(BaseConfig):
def __init__(self):
# type: () -> None
Expand Down Expand Up @@ -572,7 +551,6 @@ def __init__(self):
self.replication = ReplicationConfig()
self.cluster = ClusterConfig()
self.rate_limiter = RateLimiterConfig()
self.sentry = SentryConfig()
self.gunicorn = GunicornConfig()
self.statsd = StatsdConfig()

Expand All @@ -589,7 +567,6 @@ def read(self, path):
self.replication.read(parser, "replication")
self.cluster.read(parser, "cluster")
self.rate_limiter.read(parser, "rate_limiter")
self.sentry.read(parser, "sentry")
self.gunicorn.read(parser, "gunicorn")
self.statsd.read(parser, "statsd")

Expand All @@ -607,6 +584,5 @@ def read_env(self, tests=False):
self.replication.read_env(prefix)
self.cluster.read_env(prefix)
self.rate_limiter.read_env(prefix)
self.sentry.read_env(prefix)
self.gunicorn.read_env(prefix)
self.statsd.read_env(prefix)
8 changes: 0 additions & 8 deletions acoustid/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from optparse import OptionParser
from typing import Any, Optional

import sentry_sdk
from redis import Redis
from redis.sentinel import Sentinel as RedisSentinel
from statsd import StatsClient
Expand Down Expand Up @@ -121,12 +120,6 @@ def setup_console_logging(self, quiet=False, verbose=False):
logging.getLogger().addHandler(handler)
self._console_logging_configured = True

def setup_sentry(self):
# type: () -> None
sentry_sdk.init(
self.config.sentry.script_dsn, release=GIT_RELEASE, sample_rate=0.01
)

def context(self, use_two_phase_commit=None):
# type: (Optional[bool]) -> ScriptContext
db = DatabaseContext(self, use_two_phase_commit=use_two_phase_commit)
Expand Down Expand Up @@ -156,7 +149,6 @@ def run_script(func, option_cb=None, master_only=False):
parser.error("no configuration file")
script = Script(options.config)
script.setup_console_logging(options.quiet)
script.setup_sentry()
if master_only and script.config.cluster.role != "master":
logger.debug("Not running script %s on a slave server", sys.argv[0])
else:
Expand Down
7 changes: 0 additions & 7 deletions acoustid/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import os
from typing import TYPE_CHECKING, Any, Callable, Iterable, List, Optional, Tuple

import sentry_sdk
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
from six import BytesIO
from werkzeug.exceptions import BadRequest, ClientDisconnected, HTTPException
from werkzeug.middleware.proxy_fix import ProxyFix
Expand Down Expand Up @@ -136,9 +134,6 @@ def wsgi_app(
return e(environ, start_response)
return response(environ, start_response)

def setup_sentry(self) -> None:
sentry_sdk.init(self.config.sentry.api_dsn, release=GIT_RELEASE)


class GzipRequestMiddleware(object):
"""WSGI middleware to handle GZip-compressed HTTP requests bodies
Expand Down Expand Up @@ -210,9 +205,7 @@ def make_application(config_path=None):
config_path = os.environ.get("ACOUSTID_CONFIG", "")
assert config_path is not None
server = Server(config_path)
server.setup_sentry()
server.wsgi_app = GzipRequestMiddleware(server.wsgi_app) # type: ignore
server.wsgi_app = SentryWsgiMiddleware(server.wsgi_app) # type: ignore
server.wsgi_app = replace_double_slashes(server.wsgi_app) # type: ignore
server.wsgi_app = add_cors_headers(server.wsgi_app) # type: ignore
server.wsgi_app = ProxyFix(server.wsgi_app) # type: ignore
Expand Down
6 changes: 0 additions & 6 deletions acoustid/web/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import os
import pickle

import sentry_sdk
from flask import Flask, request, session
from flask.sessions import SecureCookieSessionInterface
from sentry_sdk.integrations.flask import FlaskIntegration
from werkzeug.middleware.proxy_fix import ProxyFix

from acoustid._release import GIT_RELEASE
Expand Down Expand Up @@ -43,10 +41,6 @@ def make_application(config_filename=None, tests=False):

app.wsgi_app = ProxyFix(app.wsgi_app)

sentry_sdk.init(
config.sentry.web_dsn, release=GIT_RELEASE, integrations=[FlaskIntegration()]
)

# can't use json because of python-openid
app.session_interface = SecureCookieSessionInterface()
app.session_interface.serializer = pickle
Expand Down
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ ignore_missing_imports = True
[mypy-markdown.*]
ignore_missing_imports = True

[mypy-sentry_sdk.*]
ignore_missing_imports = True

[mypy-schedule]
ignore_missing_imports = True

Expand Down
1 change: 0 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pyasn1
mbdata==25.0.0
alembic>=0.8.4,<1.7
schedule
sentry-sdk[flask]
typing
six
subprocess32; python_version < "3.2"
Expand Down

0 comments on commit 5dceef9

Please sign in to comment.