From 3dce598137aa5e6fe2a7f66160454613d4257056 Mon Sep 17 00:00:00 2001 From: okozachenko Date: Fri, 28 Aug 2020 21:06:37 +0300 Subject: [PATCH] Add sentry integrations in services - Django integration for Horizon - Flask integration for keystone - SQLAlchemy for all services except Horizon - Add magnum-conductor Change-Id: I5db366372acfd938bbfda2b69f8023a54c37ea6e --- images/barbican/barbican-wsgi-api | 7 ++++-- images/cinder/cinder-scheduler | 6 ++++- images/cinder/cinder-volume | 6 ++++- images/cinder/cinder-wsgi | 6 ++++- images/glance/glance-wsgi-api | 6 ++++- images/heat/heat-engine | 12 ++++++---- images/heat/heat-wsgi-api | 6 ++++- images/heat/heat-wsgi-api-cfn | 6 ++++- images/horizon/wsgi.py | 6 ++++- images/keystone/keystone-wsgi-public | 7 +++++- images/keystone/requirements.txt | 2 +- images/magnum/Dockerfile | 1 + images/magnum/magnum-api-wsgi | 6 ++++- images/magnum/magnum-conductor | 34 ++++++++++++++++++++++++++++ images/neutron/neutron-api | 7 +++++- images/neutron/neutron-rpc-server | 7 +++++- images/placement/placement-api | 6 +++++ 17 files changed, 113 insertions(+), 18 deletions(-) create mode 100755 images/magnum/magnum-conductor diff --git a/images/barbican/barbican-wsgi-api b/images/barbican/barbican-wsgi-api index 4b5bd2b7..b113398b 100755 --- a/images/barbican/barbican-wsgi-api +++ b/images/barbican/barbican-wsgi-api @@ -1,4 +1,3 @@ - #!/usr/local/bin/python # Copyright (c) 2020 VEXXHOST, Inc. # @@ -18,13 +17,17 @@ import pkg_resources import sentry_sdk +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from barbican.api.app import get_api_wsgi_script from sentry_sdk.integrations import wsgi VERSION = pkg_resources.get_distribution("barbican").version -sentry_sdk.init(release="barbican@%s" % VERSION) +sentry_sdk.init( + release="barbican@%s" % VERSION, + integrations=[SqlalchemyIntegration()] +) application = get_api_wsgi_script() application = wsgi.SentryWsgiMiddleware(application) diff --git a/images/cinder/cinder-scheduler b/images/cinder/cinder-scheduler index e1929669..43d5a514 100755 --- a/images/cinder/cinder-scheduler +++ b/images/cinder/cinder-scheduler @@ -19,12 +19,16 @@ import re import sys import sentry_sdk +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from cinder.cmd.scheduler import main VERSION = pkg_resources.get_distribution("cinder").version -sentry_sdk.init(release="cinder@%s" % VERSION) +sentry_sdk.init( + release="cinder@%s" % VERSION, + integrations=[SqlalchemyIntegration()] +) sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(main()) diff --git a/images/cinder/cinder-volume b/images/cinder/cinder-volume index 84d1998d..7238b40e 100755 --- a/images/cinder/cinder-volume +++ b/images/cinder/cinder-volume @@ -19,12 +19,16 @@ import re import sys import sentry_sdk +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from cinder.cmd.volume import main VERSION = pkg_resources.get_distribution("cinder").version -sentry_sdk.init(release="cinder@%s" % VERSION) +sentry_sdk.init( + release="cinder@%s" % VERSION, + integrations=[SqlalchemyIntegration()] +) sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(main()) diff --git a/images/cinder/cinder-wsgi b/images/cinder/cinder-wsgi index 3f611f03..4e5836cf 100755 --- a/images/cinder/cinder-wsgi +++ b/images/cinder/cinder-wsgi @@ -17,13 +17,17 @@ import pkg_resources import sentry_sdk +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from cinder.wsgi.wsgi import initialize_application from sentry_sdk.integrations import wsgi VERSION = pkg_resources.get_distribution("cinder").version -sentry_sdk.init(release="cinder@%s" % VERSION) +sentry_sdk.init( + release="cinder@%s" % VERSION, + integrations=[SqlalchemyIntegration()] +) application = initialize_application() application = wsgi.SentryWsgiMiddleware(application) diff --git a/images/glance/glance-wsgi-api b/images/glance/glance-wsgi-api index 6c2aa7af..559f9e6e 100644 --- a/images/glance/glance-wsgi-api +++ b/images/glance/glance-wsgi-api @@ -17,13 +17,17 @@ import pkg_resources import sentry_sdk +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from glance.common.wsgi_app import init_app from sentry_sdk.integrations import wsgi VERSION = pkg_resources.get_distribution("glance").version -sentry_sdk.init(release="glance@%s" % VERSION) +sentry_sdk.init( + release="glance@%s" % VERSION, + integrations=[SqlalchemyIntegration()] +) application = init_app() application = wsgi.SentryWsgiMiddleware(application) diff --git a/images/heat/heat-engine b/images/heat/heat-engine index e7fc4515..02f771c6 100755 --- a/images/heat/heat-engine +++ b/images/heat/heat-engine @@ -18,12 +18,16 @@ import pkg_resources import re import sys import sentry_sdk +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration + from heat.cmd.engine import main VERSION = pkg_resources.get_distribution("openstack-heat").version -sentry_sdk.init(release="openstack-heat@%s" % VERSION) +sentry_sdk.init( + release="heat@%s" % VERSION, + integrations=[SqlalchemyIntegration()] +) -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) +sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) +sys.exit(main()) diff --git a/images/heat/heat-wsgi-api b/images/heat/heat-wsgi-api index 82459afc..e8f0391c 100755 --- a/images/heat/heat-wsgi-api +++ b/images/heat/heat-wsgi-api @@ -17,13 +17,17 @@ import pkg_resources import sentry_sdk +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from heat.httpd.heat_api import init_application from sentry_sdk.integrations import wsgi VERSION = pkg_resources.get_distribution("openstack-heat").version -sentry_sdk.init(release="openstack-heat@%s" % VERSION) +sentry_sdk.init( + release="heat@%s" % VERSION, + integrations=[SqlalchemyIntegration()] +) application = init_application() application = wsgi.SentryWsgiMiddleware(application) diff --git a/images/heat/heat-wsgi-api-cfn b/images/heat/heat-wsgi-api-cfn index 1436a5e5..aae8c237 100755 --- a/images/heat/heat-wsgi-api-cfn +++ b/images/heat/heat-wsgi-api-cfn @@ -17,13 +17,17 @@ import pkg_resources import sentry_sdk +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from heat.httpd.heat_api_cfn import init_application from sentry_sdk.integrations import wsgi VERSION = pkg_resources.get_distribution("openstack-heat").version -sentry_sdk.init(release="openstack-heat@%s" % VERSION) +sentry_sdk.init( + release="heat@%s" % VERSION, + integrations=[SqlalchemyIntegration()] +) application = init_application() application = wsgi.SentryWsgiMiddleware(application) diff --git a/images/horizon/wsgi.py b/images/horizon/wsgi.py index 53743a05..7b866645 100644 --- a/images/horizon/wsgi.py +++ b/images/horizon/wsgi.py @@ -26,10 +26,14 @@ import sentry_sdk from django.core.wsgi import get_wsgi_application from sentry_sdk.integrations import wsgi +from sentry_sdk.integrations.django import DjangoIntegration VERSION = pkg_resources.get_distribution("horizon").version -sentry_sdk.init(release="horizon@%s" % VERSION) +sentry_sdk.init( + release="horizon@%s" % VERSION, + integrations=[DjangoIntegration()] +) # Add this file path to sys.path in order to import settings sys.path.insert(0, os.path.normpath(os.path.join( diff --git a/images/keystone/keystone-wsgi-public b/images/keystone/keystone-wsgi-public index d1f9a506..933994a0 100644 --- a/images/keystone/keystone-wsgi-public +++ b/images/keystone/keystone-wsgi-public @@ -17,13 +17,18 @@ import pkg_resources import sentry_sdk +from sentry_sdk.integrations.flask import FlaskIntegration +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from keystone.server.wsgi import initialize_public_application from sentry_sdk.integrations import wsgi VERSION = pkg_resources.get_distribution("keystone").version -sentry_sdk.init(release="keystone@%s" % VERSION) +sentry_sdk.init( + release="keystone@%s" % VERSION, + integrations=[FlaskIntegration(), SqlalchemyIntegration()] +) application = initialize_public_application() application = wsgi.SentryWsgiMiddleware(application) diff --git a/images/keystone/requirements.txt b/images/keystone/requirements.txt index b93d2118..0ffbbe6f 100644 --- a/images/keystone/requirements.txt +++ b/images/keystone/requirements.txt @@ -2,4 +2,4 @@ uWSGI keystone PyMySQL python-memcached -sentry-sdk +sentry-sdk[flask] diff --git a/images/magnum/Dockerfile b/images/magnum/Dockerfile index 3c0ce0f6..83697d4c 100644 --- a/images/magnum/Dockerfile +++ b/images/magnum/Dockerfile @@ -22,4 +22,5 @@ ENV UWSGI_HTTP_SOCKET=:9511 UWSGI_WSGI_FILE=/usr/local/bin/magnum-api-wsgi CMD ["/usr/local/bin/uwsgi","--ini","/etc/uwsgi/uwsgi.ini"] FROM vexxhost/python-base AS magnum-conductor +COPY magnum-conductor /usr/local/bin/magnum-conductor CMD ["/usr/local/bin/magnum-conductor"] diff --git a/images/magnum/magnum-api-wsgi b/images/magnum/magnum-api-wsgi index 081ebd75..1aa2f8fc 100755 --- a/images/magnum/magnum-api-wsgi +++ b/images/magnum/magnum-api-wsgi @@ -17,6 +17,7 @@ import pkg_resources import sentry_sdk +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from magnum.api.app import build_wsgi_app from sentry_sdk.integrations import wsgi @@ -24,7 +25,10 @@ from sentry_sdk.integrations import wsgi VERSION = pkg_resources.get_distribution("magnum").version -sentry_sdk.init(release="magnum@%s" % VERSION) +sentry_sdk.init( + release="magnum@%s" % VERSION, + integrations=[SqlalchemyIntegration()] +) application = build_wsgi_app() application = wsgi.SentryWsgiMiddleware(application) diff --git a/images/magnum/magnum-conductor b/images/magnum/magnum-conductor new file mode 100755 index 00000000..d60c93c6 --- /dev/null +++ b/images/magnum/magnum-conductor @@ -0,0 +1,34 @@ +#!/usr/local/bin/python +# Copyright (c) 2020 VEXXHOST, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pkg_resources +import re +import sys + +import sentry_sdk +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration + +from magnum.cmd.conductor import main + +VERSION = pkg_resources.get_distribution("magnum").version + +sentry_sdk.init( + release="magnum@%s" % VERSION, + integrations=[SqlalchemyIntegration()] +) + +sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) +sys.exit(main()) diff --git a/images/neutron/neutron-api b/images/neutron/neutron-api index 82941f3d..16620d85 100755 --- a/images/neutron/neutron-api +++ b/images/neutron/neutron-api @@ -17,12 +17,17 @@ import pkg_resources import sentry_sdk +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from neutron.server import get_application from sentry_sdk.integrations import wsgi VERSION = pkg_resources.get_distribution("neutron").version -sentry_sdk.init(release="neutron@%s" % VERSION) + +sentry_sdk.init( + release="neutron@%s" % VERSION, + integrations=[SqlalchemyIntegration()] +) application = get_application() application = wsgi.SentryWsgiMiddleware(application) diff --git a/images/neutron/neutron-rpc-server b/images/neutron/neutron-rpc-server index 0cf23067..0ea357b2 100755 --- a/images/neutron/neutron-rpc-server +++ b/images/neutron/neutron-rpc-server @@ -19,11 +19,16 @@ import re import sys import sentry_sdk +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from neutron.cmd.eventlet.server import main_rpc_eventlet VERSION = pkg_resources.get_distribution("neutron").version -sentry_sdk.init(release="neutron@%s" % VERSION) + +sentry_sdk.init( + release="neutron@%s" % VERSION, + integrations=[SqlalchemyIntegration()] +) sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(main_rpc_eventlet()) diff --git a/images/placement/placement-api b/images/placement/placement-api index 8e835e0f..927b4839 100755 --- a/images/placement/placement-api +++ b/images/placement/placement-api @@ -17,12 +17,18 @@ import pkg_resources import sentry_sdk +from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from placement.wsgi import init_application from sentry_sdk.integrations import wsgi VERSION = pkg_resources.get_distribution("openstack-placement").version +sentry_sdk.init( + release="placement@%s" % VERSION, + integrations=[SqlalchemyIntegration()] +) + sentry_sdk.init(release="placement@%s" % VERSION) application = init_application()