From a3c3252b8f26ccb7976463e602ec57efa74dea33 Mon Sep 17 00:00:00 2001
From: Mohammed Naser <mnaser@vexxhost.com>
Date: Thu, 6 Aug 2020 19:58:47 -0400
Subject: [PATCH] Added support for Sentry

Change-Id: I410e54e2f729d1bb9fdc056ea2527b8c7d73b631
---
 chart/templates/deployment.yaml | 4 ++++
 openstack_operator/operator.py  | 7 +++++++
 requirements.txt                | 1 +
 3 files changed, 12 insertions(+)

diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml
index d2bd2d20..f25c3cf5 100644
--- a/chart/templates/deployment.yaml
+++ b/chart/templates/deployment.yaml
@@ -22,6 +22,10 @@ spec:
         image: vexxhost/openstack-operator:latest
         command: ["/usr/local/bin/kopf"]
         env:
+{{- with .Values.sentryDSN }}
+        - name: SENTRY_DSN
+          value: {{ .Values.sentryDSN }}
+{{- end }}
         - name: OPERATOR_NAMESPACE
           valueFrom:
             fieldRef:
diff --git a/openstack_operator/operator.py b/openstack_operator/operator.py
index a99c2066..981a361c 100644
--- a/openstack_operator/operator.py
+++ b/openstack_operator/operator.py
@@ -21,6 +21,8 @@ the appropriate deployments, an instance of Keystone, Heat and Horizon
 
 import os
 import kopf
+import sentry_sdk
+from sentry_sdk.integrations import aiohttp
 
 from openstack_operator import ceilometer
 from openstack_operator import chronyd
@@ -35,6 +37,11 @@ from openstack_operator import utils
 
 OPERATOR_CONFIGMAP = "operator-config"
 
+sentry_sdk.init(
+    integrations=[aiohttp.AioHttpIntegration()],
+    traces_sample_rate=1.0
+)
+
 
 def operator_configmap(namespace, name, **_):
     """Filter on the operator's ConfigMap."""
diff --git a/requirements.txt b/requirements.txt
index bc612753..f52fe204 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,4 @@
 kopf==0.27rc6
 Jinja2
+sentry-sdk==0.16.3
 openstacksdk