From d6329175b6cd8ed021f4bc2c0da4d74fdadb94e5 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 24 Apr 2026 13:25:01 -0400 Subject: [PATCH] Add `enable_statsd_middleware` option so that backend execution timing can be sent to statsd without enabling web request timing. --- doc/source/admin/galaxy_options.rst | 14 ++++++++++++++ lib/galaxy/config/sample/galaxy.yml.sample | 6 ++++++ lib/galaxy/config/schemas/config_schema.yml | 11 +++++++++++ lib/galaxy/webapps/galaxy/buildapp.py | 3 ++- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/doc/source/admin/galaxy_options.rst b/doc/source/admin/galaxy_options.rst index 24c23d5055e..d09e19d20bc 100644 --- a/doc/source/admin/galaxy_options.rst +++ b/doc/source/admin/galaxy_options.rst @@ -3325,6 +3325,20 @@ :Type: str +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``enable_statsd_middleware`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Description: + Default is true if statsd_host is set. Enable the statsd + middleware. If false and statsd_host is also set, only timing of + certain performance-critical backend tasks (e.g. the job handler + monitor loop time) data will be sent to statsd, but not web + request timing. +:Default: ``false`` +:Type: bool + + ~~~~~~~~~~~~~~~ ``statsd_host`` ~~~~~~~~~~~~~~~ diff --git a/lib/galaxy/config/sample/galaxy.yml.sample b/lib/galaxy/config/sample/galaxy.yml.sample index d4b19c9fb76..318041185a4 100644 --- a/lib/galaxy/config/sample/galaxy.yml.sample +++ b/lib/galaxy/config/sample/galaxy.yml.sample @@ -1922,6 +1922,12 @@ galaxy: # self-signed certificate. #sentry_ca_certs: null + # Default is true if statsd_host is set. Enable the statsd middleware. + # If false and statsd_host is also set, only timing of certain + # performance-critical backend tasks (e.g. the job handler monitor + # loop time) data will be sent to statsd, but not web request timing. + #enable_statsd_middleware: false + # 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/schemas/config_schema.yml b/lib/galaxy/config/schemas/config_schema.yml index 731b35c7840..acc1d9e4fae 100644 --- a/lib/galaxy/config/schemas/config_schema.yml +++ b/lib/galaxy/config/schemas/config_schema.yml @@ -2448,6 +2448,17 @@ mapping: Use this option to provide the path to location of the CA (Certificate Authority) certificate file if the sentry server uses a self-signed certificate. + enable_statsd_middleware: + type: bool + default: false + required: false + desc: | + Default is true if statsd_host is set. + Enable the statsd middleware. If false and statsd_host is also set, + only timing of certain performance-critical backend tasks (e.g. the + job handler monitor loop time) data will be sent to statsd, but not + web request timing. + statsd_host: type: str required: false diff --git a/lib/galaxy/webapps/galaxy/buildapp.py b/lib/galaxy/webapps/galaxy/buildapp.py index 8b0dc558554..79f5f029573 100644 --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -1023,7 +1023,8 @@ def wrap_in_middleware(app, global_conf, application_stack, **local_conf): # other middleware): app = wrap_if_allowed(app, stack, httpexceptions.make_middleware, name="paste.httpexceptions", args=(conf,)) # Statsd request timing and profiling - if statsd_host := conf.get("statsd_host", None): + statsd_host = conf.get("statsd_host", None) + if statsd_host and conf.get("enable_statsd_middleware", statsd_host is not None): from galaxy.web.framework.middleware.statsd import StatsdMiddleware app = wrap_if_allowed(