Merge branch 'release_21.09' into dev

This commit is contained in:
Nicola Soranzo
2021-12-02 10:03:07 +00:00
6 changed files with 46 additions and 26 deletions
+26 -22
View File
@@ -97,7 +97,31 @@ class HaltableContainer(Container):
raise exception
class MinimalGalaxyApplication(BasicSharedApp, config.ConfiguresGalaxyMixin, HaltableContainer):
class SentryClientMixin:
def configure_sentry_client(self):
self.sentry_client = None
if self.config.sentry_dsn:
event_level = self.config.sentry_event_level.upper()
assert event_level in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], f"Invalid sentry event level '{self.config.sentry.event_level}'"
def postfork_sentry_client():
import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
sentry_logging = LoggingIntegration(
level=logging.INFO, # Capture info and above as breadcrumbs
event_level=getattr(logging, event_level) # Send errors as events
)
self.sentry_client = sentry_sdk.init(
self.config.sentry_dsn,
release=f"{self.config.version_major}.{self.config.version_minor}",
integrations=[sentry_logging]
)
self.application_stack.register_postfork_function(postfork_sentry_client)
class MinimalGalaxyApplication(BasicSharedApp, config.ConfiguresGalaxyMixin, HaltableContainer, SentryClientMixin):
"""Encapsulates the state of a minimal Galaxy application"""
def __init__(self, fsmon=False, configure_logging=True, **kwargs) -> None:
@@ -191,27 +215,7 @@ class GalaxyManagerApplication(MinimalManagerApp, MinimalGalaxyApplication):
self._configure_datatypes_registry(self.installed_repository_manager)
self._register_singleton(Registry, self.datatypes_registry)
galaxy.model.set_datatypes_registry(self.datatypes_registry)
self.sentry_client = None
if self.config.sentry_dsn:
event_level = self.config.sentry_event_level.upper()
assert event_level in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], f"Invalid sentry event level '{self.config.sentry.event_level}'"
def postfork_sentry_client():
import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
sentry_logging = LoggingIntegration(
level=logging.INFO, # Capture info and above as breadcrumbs
event_level=getattr(logging, event_level) # Send errors as events
)
self.sentry_client = sentry_sdk.init(
self.config.sentry_dsn,
release=f"{self.config.version_major}.{self.config.version_minor}",
integrations=[sentry_logging]
)
self.application_stack.register_postfork_function(postfork_sentry_client)
self.configure_sentry_client()
class UniverseApplication(StructuredApp, GalaxyManagerApplication):
@@ -415,6 +415,10 @@ tool_shed:
# <project_name> -> Settings -> API Keys.
#sentry_dsn: null
# Determines the minimum log level that will be sent as an event to
# Sentry. Possible values are DEBUG, INFO, WARNING, ERROR or CRITICAL.
#sentry_event_level: ERROR
# 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.
+4 -1
View File
@@ -11,6 +11,7 @@ import tool_shed.repository_registry
import tool_shed.repository_types.registry
import tool_shed.webapp.model
from galaxy import auth
from galaxy.app import SentryClientMixin
from galaxy.config import configure_logging
from galaxy.managers.citations import CitationsManager
from galaxy.managers.users import UserManager
@@ -28,7 +29,7 @@ from . import config
log = logging.getLogger(__name__)
class UniverseApplication(BasicSharedApp):
class UniverseApplication(BasicSharedApp, SentryClientMixin):
"""Encapsulates the state of a Universe application"""
def __init__(self, **kwd) -> None:
@@ -93,6 +94,8 @@ class UniverseApplication(BasicSharedApp):
self.hgweb_config_manager.hgweb_config_dir = self.config.hgweb_config_dir
# Initialize the repository registry.
self.repository_registry = tool_shed.repository_registry.Registry(self)
# Configure Sentry client if configured
self.configure_sentry_client()
# used for cachebusting -- refactor this into a *SINGLE* UniverseApplication base.
self.server_starttime = int(time.time())
log.debug("Tool shed hgweb.config file is: %s", self.hgweb_config_manager.hgweb_config)
+2 -2
View File
@@ -248,8 +248,8 @@ def wrap_in_middleware(app, global_conf, application_stack, **local_conf):
# TODO sentry config is duplicated between tool_shed/galaxy, refactor this.
sentry_dsn = conf.get('sentry_dsn', None)
if sentry_dsn:
from galaxy.web.framework.middleware.sentry import Sentry
app = wrap_if_allowed(app, stack, Sentry, args=(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
app = wrap_if_allowed(app, stack, XForwardedHostMiddleware)
+2 -1
View File
@@ -15,7 +15,7 @@ from galaxy.config import (
from galaxy.config.schema import AppSchema
from galaxy.exceptions import ConfigurationError
from galaxy.util import string_as_bool
from galaxy.version import VERSION, VERSION_MAJOR
from galaxy.version import VERSION, VERSION_MAJOR, VERSION_MINOR
from galaxy.web.formatting import expand_pretty_datetime_format
log = logging.getLogger(__name__)
@@ -67,6 +67,7 @@ class ToolShedAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin):
os.umask(self.umask) # can't get w/o set, so set it back
self.gid = os.getgid() # if running under newgrp(1) we'll need to fix the group of data created on the cluster
self.version_major = VERSION_MAJOR
self.version_minor = VERSION_MINOR
self.version = VERSION
# Database related configuration
if not self.database_connection: # Provide default if not supplied by user
+8
View File
@@ -578,6 +578,14 @@ mapping:
indicated sentry instance. This connection string is available in your
sentry instance under <project_name> -> Settings -> API Keys.
sentry_event_level:
type: str
default: ERROR
required: false
desc: |
Determines the minimum log level that will be sent as an event to Sentry.
Possible values are DEBUG, INFO, WARNING, ERROR or CRITICAL.
session_duration:
type: int
default: 0