mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #15553 from mvdbeek/use_sentry_fastapi_integration
[23.0] Use sentry-fastapi integration, expose sampling rate
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -202,6 +202,7 @@ class SentryClientMixin:
|
||||
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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
psycopg2-binary==2.9.5
|
||||
mysqlclient
|
||||
fluent-logger
|
||||
sentry-sdk
|
||||
sentry-sdk[fastapi]
|
||||
pbs_python
|
||||
drmaa
|
||||
statsd
|
||||
|
||||
@@ -61,7 +61,7 @@ ecdsa==0.18.0 ; python_version >= "3.7" and python_version < "3.12"
|
||||
edam-ontology==1.25.2 ; python_version >= "3.7" and python_version < "3.12"
|
||||
email-validator==1.3.0 ; python_version >= "3.7" and python_version < "3.12"
|
||||
fastapi-utils==0.2.1 ; python_version >= "3.7" and python_version < "3.12"
|
||||
fastapi==0.89.1 ; python_version >= "3.7" and python_version < "3.12"
|
||||
fastapi==0.91.0 ; python_version >= "3.7" and python_version < "3.12"
|
||||
flupy==1.2.0 ; python_version >= "3.7" and python_version < "3.12"
|
||||
frozenlist==1.3.3 ; python_version >= "3.7" and python_version < "3.12"
|
||||
fs==2.4.16 ; python_version >= "3.7" and python_version < "3.12"
|
||||
@@ -171,7 +171,7 @@ sqlalchemy==1.4.46 ; python_version >= "3.7" and python_version < "3.12"
|
||||
sqlitedict==2.1.0 ; python_version >= "3.7" and python_version < "3.12"
|
||||
sqlparse==0.4.3 ; python_version >= "3.7" and python_version < "3.12"
|
||||
starlette-context==0.3.5 ; python_version >= "3.7" and python_version < "3.12"
|
||||
starlette==0.22.0 ; python_version >= "3.7" and python_version < "3.12"
|
||||
starlette==0.24.0 ; python_version >= "3.7" and python_version < "3.12"
|
||||
supervisor==4.2.5 ; python_version >= "3.7" and python_version < "3.12"
|
||||
svgwrite==1.4.3 ; python_version >= "3.7" and python_version < "3.12"
|
||||
tempita==0.5.2 ; python_version >= "3.7" and python_version < "3.12"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -107,11 +107,6 @@ def add_galaxy_middleware(app: FastAPI, gx_app):
|
||||
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,
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ from galaxy.app_unittest_utils.galaxy_mock import MockApp
|
||||
from galaxy.webapps.base.api import add_request_id_middleware
|
||||
|
||||
app = FastAPI()
|
||||
add_request_id_middleware(app)
|
||||
GX_APP = None
|
||||
|
||||
|
||||
@@ -95,7 +96,6 @@ def assert_scoped_session_is_thread_local(gx_app):
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_request_scoped_sa_session_single_request():
|
||||
add_request_id_middleware(app)
|
||||
async with AsyncClient(app=app, base_url="http://test") as client:
|
||||
response = await client.get("/")
|
||||
assert response.status_code == 200
|
||||
@@ -106,7 +106,6 @@ async def test_request_scoped_sa_session_single_request():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_request_scoped_sa_session_exception():
|
||||
add_request_id_middleware(app)
|
||||
async with AsyncClient(app=app, base_url="http://test") as client:
|
||||
with pytest.raises(UnexpectedException):
|
||||
await client.get("/internal_server_error")
|
||||
@@ -116,7 +115,6 @@ async def test_request_scoped_sa_session_exception():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_request_scoped_sa_session_concurrent_requests_sync():
|
||||
add_request_id_middleware(app)
|
||||
async with AsyncClient(app=app, base_url="http://test") as client:
|
||||
awaitables = (client.get("/sync_wait") for _ in range(10))
|
||||
result = await asyncio.gather(*awaitables)
|
||||
@@ -131,7 +129,6 @@ async def test_request_scoped_sa_session_concurrent_requests_sync():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_request_scoped_sa_session_concurrent_requests_async():
|
||||
add_request_id_middleware(app)
|
||||
async with AsyncClient(app=app, base_url="http://test") as client:
|
||||
awaitables = (client.get("/async_wait") for _ in range(10))
|
||||
result = await asyncio.gather(*awaitables)
|
||||
@@ -146,7 +143,6 @@ async def test_request_scoped_sa_session_concurrent_requests_async():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_request_scoped_sa_session_concurrent_requests_and_background_thread():
|
||||
add_request_id_middleware(app)
|
||||
loop = asyncio.get_running_loop()
|
||||
target = functools.partial(assert_scoped_session_is_thread_local, GX_APP)
|
||||
with concurrent.futures.ThreadPoolExecutor() as pool:
|
||||
|
||||
Reference in New Issue
Block a user