diff --git a/doc/source/admin/galaxy_options.rst b/doc/source/admin/galaxy_options.rst index f36e31624291..b6fa3a4ed942 100644 --- a/doc/source/admin/galaxy_options.rst +++ b/doc/source/admin/galaxy_options.rst @@ -2914,6 +2914,19 @@ :Type: str +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``sentry_traces_sample_rate`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Description: + Set to a number between 0 and 1. With this option set, every + transaction created will have that percentage chance of being sent + to Sentry. A value higher than 0 is required to analyze + performance. +:Default: ``0.0`` +:Type: float + + ~~~~~~~~~~~~~~~ ``statsd_host`` ~~~~~~~~~~~~~~~ @@ -5076,14 +5089,15 @@ :Type: str - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``enable_beacon_integration`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Description: - Enables user preferences and api endpoint for the beacon integration. + Enables user preferences and api endpoint for the beacon + integration. :Default: ``false`` :Type: bool + diff --git a/lib/galaxy/app.py b/lib/galaxy/app.py index a4b504201852..e2d61248aa8d 100644 --- a/lib/galaxy/app.py +++ b/lib/galaxy/app.py @@ -202,6 +202,7 @@ def postfork_sentry_client(): self.config.sentry_dsn, release=f"{self.config.version_major}.{self.config.version_minor}", integrations=[sentry_logging], + traces_sample_rate=self.config.sentry_traces_sample_rate, ) self.application_stack.register_postfork_function(postfork_sentry_client) diff --git a/lib/galaxy/config/sample/galaxy.yml.sample b/lib/galaxy/config/sample/galaxy.yml.sample index 21b7e5872068..d4579e56adbc 100644 --- a/lib/galaxy/config/sample/galaxy.yml.sample +++ b/lib/galaxy/config/sample/galaxy.yml.sample @@ -1667,6 +1667,11 @@ galaxy: # Sentry. Possible values are DEBUG, INFO, WARNING, ERROR or CRITICAL. #sentry_event_level: ERROR + # Set to a number between 0 and 1. With this option set, every + # transaction created will have that percentage chance of being sent + # to Sentry. A value higher than 0 is required to analyze performance. + #sentry_traces_sample_rate: 0.0 + # Log to statsd Statsd is an external statistics aggregator # (https://github.com/etsy/statsd) Enabling the following options will # cause galaxy to log request timing and other statistics to the diff --git a/lib/galaxy/config/sample/tool_shed.yml.sample b/lib/galaxy/config/sample/tool_shed.yml.sample index fe8883a5a808..6be4f308e56c 100644 --- a/lib/galaxy/config/sample/tool_shed.yml.sample +++ b/lib/galaxy/config/sample/tool_shed.yml.sample @@ -311,6 +311,11 @@ tool_shed: # Sentry. Possible values are DEBUG, INFO, WARNING, ERROR or CRITICAL. #sentry_event_level: ERROR + # Set to a number between 0 and 1. With this option set, every + # transaction created will have that percentage chance of being sent + # to Sentry. A value higher than 0 is required to analyze performance. + #sentry_traces_sample_rate: 0.0 + # Galaxy Session Timeout This provides a timeout (in minutes) after # which a user will have to log back in. A duration of 0 disables this # feature. diff --git a/lib/galaxy/config/schemas/config_schema.yml b/lib/galaxy/config/schemas/config_schema.yml index 11a58011dec3..f0c16d6ebc68 100644 --- a/lib/galaxy/config/schemas/config_schema.yml +++ b/lib/galaxy/config/schemas/config_schema.yml @@ -2108,6 +2108,15 @@ mapping: Determines the minimum log level that will be sent as an event to Sentry. Possible values are DEBUG, INFO, WARNING, ERROR or CRITICAL. + sentry_traces_sample_rate: + type: float + default: 0.0 + required: false + desc: | + Set to a number between 0 and 1. With this option set, every transaction created + will have that percentage chance of being sent to Sentry. A value higher than 0 + is required to analyze performance. + statsd_host: type: str required: false diff --git a/lib/galaxy/config/schemas/tool_shed_config_schema.yml b/lib/galaxy/config/schemas/tool_shed_config_schema.yml index 39b5079221a6..7b2f5bcfc581 100644 --- a/lib/galaxy/config/schemas/tool_shed_config_schema.yml +++ b/lib/galaxy/config/schemas/tool_shed_config_schema.yml @@ -557,6 +557,15 @@ mapping: Determines the minimum log level that will be sent as an event to Sentry. Possible values are DEBUG, INFO, WARNING, ERROR or CRITICAL. + sentry_traces_sample_rate: + type: float + default: 0.0 + required: false + desc: | + Set to a number between 0 and 1. With this option set, every transaction created + will have that percentage chance of being sent to Sentry. A value higher than 0 + is required to analyze performance. + session_duration: type: int default: 0 diff --git a/lib/galaxy/dependencies/conditional-requirements.txt b/lib/galaxy/dependencies/conditional-requirements.txt index 0c2e60d96b03..24a076a389a1 100644 --- a/lib/galaxy/dependencies/conditional-requirements.txt +++ b/lib/galaxy/dependencies/conditional-requirements.txt @@ -2,7 +2,7 @@ psycopg2-binary==2.9.5 mysqlclient fluent-logger -sentry-sdk +sentry-sdk[fastapi] pbs_python drmaa statsd diff --git a/lib/galaxy/webapps/galaxy/buildapp.py b/lib/galaxy/webapps/galaxy/buildapp.py index 46ca9c587795..a9bcaba11314 100644 --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -66,6 +66,7 @@ def app_pair(global_conf, load_app_kwds=None, wsgi_preflight=True, **kwargs): # Call app's shutdown method when the interpeter exits, this cleanly stops # the various Galaxy application daemon threads app.application_stack.register_postfork_function(atexit.register, app.shutdown) + # Create the universe WSGI application webapp = GalaxyWebApplication(app, session_cookie="galaxysession", name="galaxy") @@ -1304,13 +1305,7 @@ def wrap_in_middleware(app, global_conf, application_stack, **local_conf): from paste import recursive app = wrap_if_allowed(app, stack, recursive.RecursiveMiddleware, args=(conf,)) - # If sentry logging is enabled, log here before propogating up to - # the error middleware - sentry_dsn = conf.get("sentry_dsn", None) - if sentry_dsn: - from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware - app = wrap_if_allowed(app, stack, SentryWsgiMiddleware) # Error middleware app = wrap_if_allowed(app, stack, ErrorMiddleware, args=(conf,)) # Transaction logging (apache access.log style) diff --git a/lib/galaxy/webapps/galaxy/fast_app.py b/lib/galaxy/webapps/galaxy/fast_app.py index be97aa4beafc..49ccdb718685 100644 --- a/lib/galaxy/webapps/galaxy/fast_app.py +++ b/lib/galaxy/webapps/galaxy/fast_app.py @@ -107,11 +107,6 @@ async def add_x_frame_options(request: Request, call_next): GalaxyFileResponse.nginx_x_accel_redirect_base = gx_app.config.nginx_x_accel_redirect_base GalaxyFileResponse.apache_xsendfile = gx_app.config.apache_xsendfile - if gx_app.config.sentry_dsn: - from sentry_sdk.integrations.asgi import SentryAsgiMiddleware - - app.add_middleware(SentryAsgiMiddleware) - if gx_app.config.get("allowed_origin_hostnames", None): app.add_middleware( GalaxyCORSMiddleware, diff --git a/lib/tool_shed/webapp/buildapp.py b/lib/tool_shed/webapp/buildapp.py index c69599a3da3d..3e754af348d1 100644 --- a/lib/tool_shed/webapp/buildapp.py +++ b/lib/tool_shed/webapp/buildapp.py @@ -267,14 +267,7 @@ def wrap_in_middleware(app, global_conf, application_stack, **local_conf): from paste.translogger import TransLogger app = wrap_if_allowed(app, stack, TransLogger) - # If sentry logging is enabled, log here before propogating up to - # the error middleware - # TODO sentry config is duplicated between tool_shed/galaxy, refactor this. - sentry_dsn = conf.get("sentry_dsn", None) - if sentry_dsn: - from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware - app = wrap_if_allowed(app, stack, SentryWsgiMiddleware) # X-Forwarded-Host handling from galaxy.web.framework.middleware.xforwardedhost import XForwardedHostMiddleware