Commit 2c84f087 authored by EKbfh's avatar EKbfh 🐼
Browse files

Merge branch 'update/sentry_client' into 'master'

Sentry: Change client

See merge request noc/noc!3478
parents 3a794841 ec0bf36c
......@@ -506,6 +506,10 @@ class Config(BaseConfig):
class sentry(ConfigSection):
url = StringParameter(default="")
shutdown_timeout = IntParameter(min=1, max=10, default=2)
default_integrations = BooleanParameter(default=False)
debug = BooleanParameter(default=False)
max_breadcrumbs = IntParameter(min=1, max=100, default=10)
class syslogcollector(ConfigSection):
listen = StringParameter(default="0.0.0.0:514")
......
......@@ -39,14 +39,25 @@ CP_SET_UID = None
SERVICE_NAME = os.path.relpath(sys.argv[0] or sys.executable)
# Sentry error reporting
if config.features.sentry:
from raven import Client as RavenClient
import sentry_sdk
raven_client = RavenClient(
def before_send(event, hint):
if "exc_info" not in hint:
return event
exception = hint["exc_info"][1]
event["fingerprint"] = ["{{ type }}", str(exception), error_fingerprint()]
return event
sentry_sdk.init(
config.sentry.url,
processors=("raven.processors.SanitizePasswordsProcessor",),
shutdown_timeout=config.sentry.shutdown_timeout,
release=version.version,
max_breadcrumbs=config.sentry.max_breadcrumbs,
default_integrations=config.sentry.default_integrations,
debug=config.sentry.debug,
before_send=before_send,
)
......@@ -268,7 +279,7 @@ def error_report(reverse=config.traceback.reverse, logger=logger):
metrics["errors"] += 1
if config.sentry.url:
try:
raven_client.captureException(fingerprint=[fp])
sentry_sdk.capture_exception()
except Exception as e:
logger.error("Failed to sent problem report to Sentry: %s", e)
if ENABLE_CP:
......
......@@ -83,7 +83,7 @@ supervisor==4.1.0; extra == "supervisor"
supervisor-serialrestart==0.1.1; extra == "supervisor"
# Additional prod tools
alerta==4.7.16; extra == "prod-tools"
raven==6.1.0; extra == "prod-tools"
sentry-sdk==0.16.5; extra == "prod-tools"
supervisor-wildcards==0.1.3; extra == "prod-tools"
# Test
Coverage[toml]==5.0.3; extra == "testing"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment