From bfeb65c9149387787c23c76e55c1847dfbbf4544 Mon Sep 17 00:00:00 2001 From: Ryan Ahearn Date: Tue, 17 Jan 2023 14:08:17 -0500 Subject: [PATCH 1/6] Install newrelic and enable in development --- Makefile | 7 +- Pipfile | 1 + Pipfile.lock | 225 ++++++++++++--------- app/notifications/process_notifications.py | 10 +- newrelic.ini | 219 ++++++++++++++++++++ sample.env | 5 + 6 files changed, 358 insertions(+), 109 deletions(-) create mode 100644 newrelic.ini diff --git a/Makefile b/Makefile index 9b22547bc..d041013e0 100644 --- a/Makefile +++ b/Makefile @@ -26,12 +26,12 @@ run-procfile: .PHONY: run-flask run-flask: ## Run flask - pipenv run flask run -p 6011 --host=0.0.0.0 + pipenv run newrelic-admin run-program flask run -p 6011 --host=0.0.0.0 .PHONY: run-celery run-celery: ## Run celery, TODO remove purge for staging/prod pipenv run celery -A run_celery.notify_celery purge -f - pipenv run celery \ + pipenv run newrelic-admin run-program celery \ -A run_celery.notify_celery worker \ --pidfile="/tmp/celery.pid" \ --loglevel=INFO \ @@ -39,7 +39,7 @@ run-celery: ## Run celery, TODO remove purge for staging/prod .PHONY: run-celery-beat run-celery-beat: ## Run celery beat - pipenv run celery \ + pipenv run newrelic-admin run-program celery \ -A run_celery.notify_celery beat \ --loglevel=INFO @@ -52,6 +52,7 @@ generate-version-file: ## Generates the app version file @echo -e "__git_commit__ = \"${GIT_COMMIT}\"\n__time__ = \"${DATE}\"" > ${APP_VERSION_FILE} .PHONY: test +test: export NEW_RELIC_ENVIRONMENT=test test: ## Run tests pipenv run flake8 . pipenv run isort --check-only ./app ./tests diff --git a/Pipfile b/Pipfile index 1b9ef1a27..eee14c122 100644 --- a/Pipfile +++ b/Pipfile @@ -60,6 +60,7 @@ prometheus-client = "==0.14.1" gds-metrics = {version = "==0.2.4", ref = "6f1840a57b6fb1ee40b7e84f2f18ec229de8aa72", git = "https://github.com/alphagov/gds_metrics_python.git"} packaging = "==21.3" notifications-utils = {editable = true, ref = "main", git = "https://github.com/GSA/notifications-utils.git"} +newrelic = "*" [dev-packages] flake8 = "==4.0.1" diff --git a/Pipfile.lock b/Pipfile.lock index e392dd9ea..004a17eb8 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "d0a90dd082bf51ae47e04412c0848f00bc5e4b538804d1333e9264ca0ad2d4e9" + "sha256": "ad2dc506d24393f641531ca9d6de586ee5593ec895ad674578e48d718897eff0" }, "pipfile-spec": 6, "requires": { @@ -417,10 +417,11 @@ }, "govuk-bank-holidays": { "hashes": [ - "sha256:32694697e1d9795d133cf8e39a1dd69baa23bda4a72b76f476dd4ee3df7d9b13", - "sha256:4cf28203b96c8ac07065538a0e49f44e4f0c6553ad418600b275f5ab60d23c68" + "sha256:2b91901be492235c4160a64d56d4d1945f6ca7f11c1ea4277395981866c35bef", + "sha256:ffb6ac050701cb850fd2f08eb9c7c91753090f00525e69cebec4f869f6f0de41" ], - "version": "==0.12" + "markers": "python_version >= '3.6'", + "version": "==0.13" }, "greenlet": { "hashes": [ @@ -729,6 +730,27 @@ ], "version": "==0.8.4" }, + "newrelic": { + "hashes": [ + "sha256:05ceedb760a2f76fc8477f969520426656f6949d5b5bb5634a430a9d9d5c18fb", + "sha256:2d12c4c96187c7a51958d3145dcbfebcbb6fe48d9d3219804e558da3769992a3", + "sha256:37821d6d47288605ed9de138b8ec5498bd597dd91bc296af7733e5b864c40cc1", + "sha256:6a13e6956042eeb8cf013a219f936c88293b8d6460234c5d772fd53640264d3a", + "sha256:720929793f4e17838b354fa997caa0d6474710149ac68c3aea23c29ba9123d1c", + "sha256:8810ea27ae22c7621caf61971f3b3ab1356d237317c2cffe80f605b73f5bcb37", + "sha256:9571efebcc330c157cab9a8d0c6d55f6d7ec146370c59423716534e9989d880d", + "sha256:a5650024071525256df7d74a9bc887840889c35d1e7ade51eda8eedb25d85e95", + "sha256:a8aeae34a518ac961e6c972f9d9479a008925faa585c9a89a9307c79927d92e4", + "sha256:b425ec7653bc7e6e73f2a7f55e707cd9341ac90696c0f3dcafc3ac6776aec959", + "sha256:c006ff70fbc87fe1f201cec0d22b5d209a58bbe31a2530fefe457f051ce44b86", + "sha256:d529e272cb433cee50bab89e2f01ec57ac1b8511845f9b777dfadd3eab3842dd", + "sha256:d79df5fb486ca2a0997f4f9cda9a7e8de39ae07df8161b5ab2742f22bcf50974", + "sha256:f3f66de81c4cce20474017397f372ef11cb52a629c97c2e1fe5c445e31c2bf07", + "sha256:fd33ec7e227701ceafb8e3894dcc3dafae5dbffc4a43814ad9e7976fdb418696" + ], + "index": "pypi", + "version": "==8.5.0" + }, "notifications-python-client": { "hashes": [ "sha256:47c803fcc8b4098d069b92547bb52607b558cec25c19e2697a74faab2e5ef4c0" @@ -799,10 +821,10 @@ }, "phonenumbers": { "hashes": [ - "sha256:14f5a639eb47548595bb2baeff7bb63b32c95a4f79eed4dc7529afa2a65002d1", - "sha256:7d0c45c154013970b78b86f4188e0e00a8e77d6bebef7c81efdc038db876eeba" + "sha256:6d63455012fc9431105ffc7739befca61c3efc551b287dca58d2be2e745475a9", + "sha256:a577a46c069ad889c7b7cf4dd978751d059edeab28b97acead4775d2ea1fc70a" ], - "version": "==8.13.3" + "version": "==8.13.4" }, "prometheus-client": { "hashes": [ @@ -1034,10 +1056,10 @@ }, "pytz": { "hashes": [ - "sha256:7ccfae7b4b2c067464a6733c6261673fdb8fd1be905460396b97a073e9fa683a", - "sha256:93007def75ae22f7cd991c84e02d434876818661f8df9ad5df9e950ff4e52cfd" + "sha256:01a0681c4b9684a28304615eba55d1ab31ae00bf68ec157ec3708a8182dbbcd0", + "sha256:78f4f37d8198e0627c5f1143240bb0206b8691d8d7ac6d78fee88b78733f8c4a" ], - "version": "==2022.7" + "version": "==2022.7.1" }, "pyyaml": { "hashes": [ @@ -1076,18 +1098,18 @@ }, "redis": { "hashes": [ - "sha256:7b8c87d19c45d3f1271b124858d2a5c13160c4e74d4835e28273400fa34d5228", - "sha256:cae3ee5d1f57d8caf534cd8764edf3163c77e073bdd74b6f54a87ffafdc5e7d9" + "sha256:a010f6cb7378065040a02839c3f75c7e0fb37a87116fb4a95be82a95552776c7", + "sha256:e6206448e2f8a432871d07d432c13ed6c2abcf6b74edb436c99752b1371be387" ], - "version": "==4.4.0" + "version": "==4.4.2" }, "requests": { "hashes": [ - "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983", - "sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349" + "sha256:64299f4909223da747622c030b781c0d7811e359c37124b4bd368fb8c6518baa", + "sha256:98b1b2782e3c6c4904938b84c0eb932721069dfdb9134313beff7c83c2df24bf" ], "markers": "python_version >= '3.7' and python_version < '4'", - "version": "==2.28.1" + "version": "==2.28.2" }, "rfc3339-validator": { "hashes": [ @@ -1121,11 +1143,11 @@ }, "setuptools": { "hashes": [ - "sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54", - "sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75" + "sha256:a78d01d1e2c175c474884671dde039962c9d74c7223db7369771fcf6e29ceeab", + "sha256:bd6eb2d6722568de6d14b87c44a96fac54b2a45ff5e940e639979a3d1792adb6" ], "markers": "python_version >= '3.7'", - "version": "==65.6.3" + "version": "==66.0.0" }, "shapely": { "hashes": [ @@ -1259,11 +1281,11 @@ }, "urllib3": { "hashes": [ - "sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc", - "sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8" + "sha256:076907bf8fd355cde77728471316625a4d2f7e713c125f51953bb5b3eecf4f72", + "sha256:75edcdc2f7d85b137124a6c3c9fc3933cdeaa12ecb9a6a959f22797a0feca7e1" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'", - "version": "==1.26.13" + "version": "==1.26.14" }, "vine": { "hashes": [ @@ -1275,10 +1297,10 @@ }, "wcwidth": { "hashes": [ - "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784", - "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83" + "sha256:795b138f6875577cd91bba52baf9e445cd5118fd32723b460e30a0af30ea230e", + "sha256:a5220780a404dbe3353789870978e472cfe477761f06ee55077256e509b156d0" ], - "version": "==0.2.5" + "version": "==0.2.6" }, "webcolors": { "hashes": [ @@ -1509,60 +1531,60 @@ "toml" ], "hashes": [ - "sha256:037b51ee86bc600f99b3b957c20a172431c35c2ef9c1ca34bc813ab5b51fd9f5", - "sha256:0bce4ad5bdd0b02e177a085d28d2cea5fc57bb4ba2cead395e763e34cf934eb1", - "sha256:112cfead1bd22eada8a8db9ed387bd3e8be5528debc42b5d3c1f7da4ffaf9fb5", - "sha256:13121fa22dcd2c7b19c5161e3fd725692448f05377b788da4502a383573227b3", - "sha256:18b09811f849cc958d23f733a350a66b54a8de3fed1e6128ba55a5c97ffb6f65", - "sha256:25fde928306034e8deecd5fc91a07432dcc282c8acb76749581a28963c9f4f3f", - "sha256:2b865aa679bee7fbd1c55960940dbd3252621dd81468268786c67122bbd15343", - "sha256:2f7c51b6074a8a3063c341953dffe48fd6674f8e4b1d3c8aa8a91f58d6e716a8", - "sha256:349d0b545520e8516f7b4f12373afc705d17d901e1de6a37a20e4ec9332b61f7", - "sha256:44d6a556de4418f1f3bfd57094b8c49f0408df5a433cf0d253eeb3075261c762", - "sha256:4959dc506be74e4963bd2c42f7b87d8e4b289891201e19ec551e64c6aa5441f8", - "sha256:49da0ff241827ebb52d5d6d5a36d33b455fa5e721d44689c95df99fd8db82437", - "sha256:55e46fa4168ccb7497c9be78627fcb147e06f474f846a10d55feeb5108a24ef0", - "sha256:5722269ed05fbdb94eef431787c66b66260ff3125d1a9afcc00facff8c45adf9", - "sha256:628f47eaf66727fc986d3b190d6fa32f5e6b7754a243919d28bc0fd7974c449f", - "sha256:62ef3800c4058844e2e3fa35faa9dd0ccde8a8aba6c763aae50342e00d4479d4", - "sha256:75e43c6f4ea4d122dac389aabdf9d4f0e160770a75e63372f88005d90f5bcc80", - "sha256:7e8b0642c38b3d3b3c01417643ccc645345b03c32a2e84ef93cdd6844d6fe530", - "sha256:88834e5d56d01c141c29deedacba5773fe0bed900b1edc957595a8a6c0da1c3c", - "sha256:985ad2af5ec3dbb4fd75d5b0735752c527ad183455520055a08cf8d6794cabfc", - "sha256:a530663a361eb27375cec28aea5cd282089b5e4b022ae451c4c3493b026a68a5", - "sha256:acef7f3a3825a2d218a03dd02f5f3cc7f27aa31d882dd780191d1ad101120d74", - "sha256:ae871d09901911eedda1981ea6fd0f62a999107293cdc4c4fd612321c5b34745", - "sha256:af6cef3796b8068713a48dd67d258dc9a6e2ebc3bd4645bfac03a09672fa5d20", - "sha256:af87e906355fa42447be5c08c5d44e6e1c005bf142f303f726ddf5ed6e0c8a4d", - "sha256:b07651e3b9af8f1a092861d88b4c74d913634a7f1f2280fca0ad041ad84e9e96", - "sha256:b1ffc8f58b81baed3f8962e28c30d99442079b82ce1ec836a1f67c0accad91c1", - "sha256:b5b38813eee5b4739f505d94247604c72eae626d5088a16dd77b08b8b1724ab3", - "sha256:b791beb17b32ac019a78cfbe6184f992b6273fdca31145b928ad2099435e2fcb", - "sha256:b82343a5bc51627b9d606f0b6b6b9551db7b6311a5dd920fa52a94beae2e8959", - "sha256:ba9af1218fa01b1f11c72271bc7290b701d11ad4dbc2ae97c445ecacf6858dba", - "sha256:bdbda870e0fda7dd0fe7db7135ca226ec4c1ade8aa76e96614829b56ca491012", - "sha256:bf76d79dfaea802f0f28f50153ffbc1a74ae1ee73e480baeda410b4f3e7ab25f", - "sha256:c1cee10662c25c94415bbb987f2ec0e6ba9e8fce786334b10be7e6a7ab958f69", - "sha256:c5648c7eec5cf1ba5db1cf2d6c10036a582d7f09e172990474a122e30c841361", - "sha256:c58cd6bb46dcb922e0d5792850aab5964433d511b3a020867650f8d930dde4f4", - "sha256:c5d9b480ebae60fc2cbc8d6865194136bc690538fa542ba58726433bed6e04cc", - "sha256:ca15308ef722f120967af7474ba6a453e0f5b6f331251e20b8145497cf1bc14a", - "sha256:d0df04495b76a885bfef009f45eebe8fe2fbf815ad7a83dabcf5aced62f33162", - "sha256:d5be4e93acce64f516bf4fd239c0e6118fc913c93fa1a3f52d15bdcc60d97b2d", - "sha256:d8249666c23683f74f8f93aeaa8794ac87cc61c40ff70374a825f3352a4371dc", - "sha256:e3f1cd1cd65695b1540b3cf7828d05b3515974a9d7c7530f762ac40f58a18161", - "sha256:e56fae4292e216b8deeee38ace84557b9fa85b52db005368a275427cdabb8192", - "sha256:e6dcc70a25cb95df0ae33dfc701de9b09c37f7dd9f00394d684a5b57257f8246", - "sha256:e89d5abf86c104de808108a25d171ad646c07eda96ca76c8b237b94b9c71e518", - "sha256:ed7c9debf7bfc63c9b9f8b595409237774ff4b061bf29fba6f53b287a2fdeab9", - "sha256:ef001a60e888f8741e42e5aa79ae55c91be73761e4df5e806efca1ddd62fd400", - "sha256:f30090e22a301952c5abd0e493a1c8358b4f0b368b49fa3e4568ed3ed68b8d1f", - "sha256:f79691335257d60951638dd43576b9bcd6f52baa5c1c2cd07a509bb003238372", - "sha256:f918e9ef4c98f477a5458238dde2a1643aed956c7213873ab6b6b82e32b8ef61", - "sha256:fd0a8aa431f9b7ad9eb8264f55ef83cbb254962af3775092fb6e93890dea9ca2" + "sha256:051afcbd6d2ac39298d62d340f94dbb6a1f31de06dfaf6fcef7b759dd3860c45", + "sha256:0a1890fca2962c4f1ad16551d660b46ea77291fba2cc21c024cd527b9d9c8809", + "sha256:0ee30375b409d9a7ea0f30c50645d436b6f5dfee254edffd27e45a980ad2c7f4", + "sha256:13250b1f0bd023e0c9f11838bdeb60214dd5b6aaf8e8d2f110c7e232a1bff83b", + "sha256:17e01dd8666c445025c29684d4aabf5a90dc6ef1ab25328aa52bedaa95b65ad7", + "sha256:19245c249aa711d954623d94f23cc94c0fd65865661f20b7781210cb97c471c0", + "sha256:1caed2367b32cc80a2b7f58a9f46658218a19c6cfe5bc234021966dc3daa01f0", + "sha256:1f66862d3a41674ebd8d1a7b6f5387fe5ce353f8719040a986551a545d7d83ea", + "sha256:220e3fa77d14c8a507b2d951e463b57a1f7810a6443a26f9b7591ef39047b1b2", + "sha256:276f4cd0001cd83b00817c8db76730938b1ee40f4993b6a905f40a7278103b3a", + "sha256:29de916ba1099ba2aab76aca101580006adfac5646de9b7c010a0f13867cba45", + "sha256:2a7f23bbaeb2a87f90f607730b45564076d870f1fb07b9318d0c21f36871932b", + "sha256:2c407b1950b2d2ffa091f4e225ca19a66a9bd81222f27c56bd12658fc5ca1209", + "sha256:30b5fec1d34cc932c1bc04017b538ce16bf84e239378b8f75220478645d11fca", + "sha256:3c2155943896ac78b9b0fd910fb381186d0c345911f5333ee46ac44c8f0e43ab", + "sha256:411d4ff9d041be08fdfc02adf62e89c735b9468f6d8f6427f8a14b6bb0a85095", + "sha256:436e103950d05b7d7f55e39beeb4d5be298ca3e119e0589c0227e6d0b01ee8c7", + "sha256:49640bda9bda35b057b0e65b7c43ba706fa2335c9a9896652aebe0fa399e80e6", + "sha256:4a950f83fd3f9bca23b77442f3a2b2ea4ac900944d8af9993743774c4fdc57af", + "sha256:50a6adc2be8edd7ee67d1abc3cd20678987c7b9d79cd265de55941e3d0d56499", + "sha256:52ab14b9e09ce052237dfe12d6892dd39b0401690856bcfe75d5baba4bfe2831", + "sha256:54f7e9705e14b2c9f6abdeb127c390f679f6dbe64ba732788d3015f7f76ef637", + "sha256:66e50680e888840c0995f2ad766e726ce71ca682e3c5f4eee82272c7671d38a2", + "sha256:790e4433962c9f454e213b21b0fd4b42310ade9c077e8edcb5113db0818450cb", + "sha256:7a38362528a9115a4e276e65eeabf67dcfaf57698e17ae388599568a78dcb029", + "sha256:7b05ed4b35bf6ee790832f68932baf1f00caa32283d66cc4d455c9e9d115aafc", + "sha256:7e109f1c9a3ece676597831874126555997c48f62bddbcace6ed17be3e372de8", + "sha256:949844af60ee96a376aac1ded2a27e134b8c8d35cc006a52903fc06c24a3296f", + "sha256:95304068686545aa368b35dfda1cdfbbdbe2f6fe43de4a2e9baa8ebd71be46e2", + "sha256:9e662e6fc4f513b79da5d10a23edd2b87685815b337b1a30cd11307a6679148d", + "sha256:a9fed35ca8c6e946e877893bbac022e8563b94404a605af1d1e6accc7eb73289", + "sha256:b69522b168a6b64edf0c33ba53eac491c0a8f5cc94fa4337f9c6f4c8f2f5296c", + "sha256:b78729038abea6a5df0d2708dce21e82073463b2d79d10884d7d591e0f385ded", + "sha256:b8c56bec53d6e3154eaff6ea941226e7bd7cc0d99f9b3756c2520fc7a94e6d96", + "sha256:b9727ac4f5cf2cbf87880a63870b5b9730a8ae3a4a360241a0fdaa2f71240ff0", + "sha256:ba3027deb7abf02859aca49c865ece538aee56dcb4871b4cced23ba4d5088904", + "sha256:be9fcf32c010da0ba40bf4ee01889d6c737658f4ddff160bd7eb9cac8f094b21", + "sha256:c18d47f314b950dbf24a41787ced1474e01ca816011925976d90a88b27c22b89", + "sha256:c76a3075e96b9c9ff00df8b5f7f560f5634dffd1658bafb79eb2682867e94f78", + "sha256:cbfcba14a3225b055a28b3199c3d81cd0ab37d2353ffd7f6fd64844cebab31ad", + "sha256:d254666d29540a72d17cc0175746cfb03d5123db33e67d1020e42dae611dc196", + "sha256:d66187792bfe56f8c18ba986a0e4ae44856b1c645336bd2c776e3386da91e1dd", + "sha256:d8d04e755934195bdc1db45ba9e040b8d20d046d04d6d77e71b3b34a8cc002d0", + "sha256:d8f3e2e0a1d6777e58e834fd5a04657f66affa615dae61dd67c35d1568c38882", + "sha256:e057e74e53db78122a3979f908973e171909a58ac20df05c33998d52e6d35757", + "sha256:e4ce984133b888cc3a46867c8b4372c7dee9cee300335e2925e197bcd45b9e16", + "sha256:ea76dbcad0b7b0deb265d8c36e0801abcddf6cc1395940a24e3595288b405ca0", + "sha256:ecb0f73954892f98611e183f50acdc9e21a4653f294dfbe079da73c6378a6f47", + "sha256:ef14d75d86f104f03dea66c13188487151760ef25dd6b2dbd541885185f05f40", + "sha256:f26648e1b3b03b6022b48a9b910d0ae209e2d51f50441db5dce5b530fad6d9b1", + "sha256:f67472c09a0c7486e27f3275f617c964d25e35727af952869dd496b9b5b7f6a3" ], "markers": "python_version >= '3.7'", - "version": "==7.0.3" + "version": "==7.0.5" }, "cryptography": { "hashes": [ @@ -1595,11 +1617,11 @@ }, "cyclonedx-python-lib": { "hashes": [ - "sha256:48ae942a892e8385f4e0193d2e295a338df9ab864652081406c26f58085d2b35", - "sha256:a03b8f79f23aa95d37180b5d7bca81ef393b569e2d29e02f4817cfe4488e1ba2" + "sha256:1ccd482024a30b95c4fffb3fe567a9df97b705f34c1075f8abde8537867600c3", + "sha256:8981ca462fba91469c268d684a03f72c89c7a807674d884f83a28d8c2822a9b6" ], "markers": "python_version >= '3.6' and python_version < '4.0'", - "version": "==3.1.1" + "version": "==3.1.5" }, "execnet": { "hashes": [ @@ -1674,10 +1696,11 @@ }, "iniconfig": { "hashes": [ - "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", - "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" + "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", + "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374" ], - "version": "==1.1.1" + "markers": "python_version >= '3.7'", + "version": "==2.0.0" }, "isort": { "hashes": [ @@ -1857,11 +1880,11 @@ }, "pbr": { "hashes": [ - "sha256:b97bc6695b2aff02144133c2e7399d5885223d42b7912ffaec2ca3898e673bfe", - "sha256:db2317ff07c84c4c63648c9064a79fe9d9f5c7ce85a9099d4b6258b3db83225a" + "sha256:567f09558bae2b3ab53cb3c1e2e33e726ff3338e7bae3db5dc954b3a44eef12b", + "sha256:aefc51675b0b533d56bb5fd1c8c6c0522fe31896679882e1c4c63d5e4a0fccb3" ], "markers": "python_version >= '2.6'", - "version": "==5.11.0" + "version": "==5.11.1" }, "pip": { "hashes": [ @@ -2007,10 +2030,10 @@ }, "pytz": { "hashes": [ - "sha256:7ccfae7b4b2c067464a6733c6261673fdb8fd1be905460396b97a073e9fa683a", - "sha256:93007def75ae22f7cd991c84e02d434876818661f8df9ad5df9e950ff4e52cfd" + "sha256:01a0681c4b9684a28304615eba55d1ab31ae00bf68ec157ec3708a8182dbbcd0", + "sha256:78f4f37d8198e0627c5f1143240bb0206b8691d8d7ac6d78fee88b78733f8c4a" ], - "version": "==2022.7" + "version": "==2022.7.1" }, "pyyaml": { "hashes": [ @@ -2049,11 +2072,11 @@ }, "requests": { "hashes": [ - "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983", - "sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349" + "sha256:64299f4909223da747622c030b781c0d7811e359c37124b4bd368fb8c6518baa", + "sha256:98b1b2782e3c6c4904938b84c0eb932721069dfdb9134313beff7c83c2df24bf" ], "markers": "python_version >= '3.7' and python_version < '4'", - "version": "==2.28.1" + "version": "==2.28.2" }, "requests-mock": { "hashes": [ @@ -2080,11 +2103,11 @@ }, "rich": { "hashes": [ - "sha256:25f83363f636995627a99f6e4abc52ed0970ebbd544960cc63cbb43aaac3d6f0", - "sha256:41fe1d05f433b0f4724cda8345219213d2bfa472ef56b2f64f415b5b94d51b04" + "sha256:81c73a30b144bbcdedc13f4ea0b6ffd7fdc3b0d3cc259a9402309c8e4aee1964", + "sha256:f846bff22a43e8508aebf3f0f2410ce1c6f4cde429098bd58d91fde038c57299" ], "markers": "python_full_version >= '3.7.0'", - "version": "==13.0.1" + "version": "==13.1.0" }, "s3transfer": { "hashes": [ @@ -2096,11 +2119,11 @@ }, "setuptools": { "hashes": [ - "sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54", - "sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75" + "sha256:a78d01d1e2c175c474884671dde039962c9d74c7223db7369771fcf6e29ceeab", + "sha256:bd6eb2d6722568de6d14b87c44a96fac54b2a45ff5e940e639979a3d1792adb6" ], "markers": "python_version >= '3.7'", - "version": "==65.6.3" + "version": "==66.0.0" }, "six": { "hashes": [ @@ -2158,11 +2181,11 @@ }, "urllib3": { "hashes": [ - "sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc", - "sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8" + "sha256:076907bf8fd355cde77728471316625a4d2f7e713c125f51953bb5b3eecf4f72", + "sha256:75edcdc2f7d85b137124a6c3c9fc3933cdeaa12ecb9a6a959f22797a0feca7e1" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'", - "version": "==1.26.13" + "version": "==1.26.14" }, "webencodings": { "hashes": [ diff --git a/app/notifications/process_notifications.py b/app/notifications/process_notifications.py index 1c8d090e0..4abda5acd 100644 --- a/app/notifications/process_notifications.py +++ b/app/notifications/process_notifications.py @@ -105,13 +105,13 @@ def persist_notification( document_download_count=None, updated_at=None ): - current_app.logger.info('Presisting notification') + current_app.logger.info('Persisting notification') notification_created_at = created_at or datetime.utcnow() if not notification_id: notification_id = uuid.uuid4() - current_app.logger.info('Presisting notification with id {}'.format(notification_id)) + current_app.logger.info('Persisting notification with id {}'.format(notification_id)) notification = Notification( id=notification_id, @@ -136,7 +136,7 @@ def persist_notification( updated_at=updated_at ) - current_app.logger.info('Presisting notification with to address: {}'.format(notification.to)) + current_app.logger.info('Persisting notification with to address: {}'.format(notification.to)) if notification_type == SMS_TYPE: formatted_recipient = validate_and_format_phone_number(recipient, international=True) @@ -146,9 +146,9 @@ def persist_notification( notification.phone_prefix = recipient_info.country_prefix notification.rate_multiplier = recipient_info.billable_units elif notification_type == EMAIL_TYPE: - current_app.logger.info('Presisting notification with type: {}'.format(EMAIL_TYPE)) + current_app.logger.info('Persisting notification with type: {}'.format(EMAIL_TYPE)) notification.normalised_to = format_email_address(notification.to) - current_app.logger.info('Presisting notification to formatted email: {}'.format(notification.normalised_to)) + current_app.logger.info('Persisting notification to formatted email: {}'.format(notification.normalised_to)) elif notification_type == LETTER_TYPE: notification.postage = postage notification.international = postage in INTERNATIONAL_POSTAGE_TYPES diff --git a/newrelic.ini b/newrelic.ini new file mode 100644 index 000000000..0ecb31567 --- /dev/null +++ b/newrelic.ini @@ -0,0 +1,219 @@ +# --------------------------------------------------------------------------- + +# +# This file configures the New Relic Python Agent. +# +# The path to the configuration file should be supplied to the function +# newrelic.agent.initialize() when the agent is being initialized. +# +# The configuration file follows a structure similar to what you would +# find for Microsoft Windows INI files. For further information on the +# configuration file format see the Python ConfigParser documentation at: +# +# http://docs.python.org/library/configparser.html +# +# For further discussion on the behaviour of the Python agent that can +# be configured via this configuration file see: +# +# http://newrelic.com/docs/python/python-agent-configuration +# + +# --------------------------------------------------------------------------- + +# Here are the settings that are common to all environments. + +[newrelic] + +# You must specify the license key associated with your New +# Relic account. This key binds the Python Agent's data to your +# account in the New Relic service. +license_key = 88822380cb0c943af94c03098042a78b53d1NRAL + +host = gov-collector.newrelic.com + +# The application name. Set this to be the name of your +# application as you would like it to show up in New Relic UI. +# The UI will then auto-map instances of your application into a +# entry on your home dashboard page. +app_name = us-notify-api (Development) + +# New Relic offers distributed tracing for monitoring and analyzing modern +# distributed systems.Enable distributed tracing. +distributed_tracing.enabled = true + +# When "true", the agent collects performance data about your +# application and reports this data to the New Relic UI at +# newrelic.com. This global switch is normally overridden for +# each environment below. +monitor_mode = true + +# Sets the name of a file to log agent messages to. Useful for +# debugging any issues with the agent. This is not set by +# default as it is not known in advance what user your web +# application processes will run as and where they have +# permission to write to. Whatever you set this to you must +# ensure that the permissions for the containing directory and +# the file itself are correct, and that the user that your web +# application runs as can write to the file. If not able to +# write out a log file, it is also possible to say "stderr" and +# output to standard error output. This would normally result in +# output appearing in your web server log. +#log_file = /tmp/newrelic-python-agent.log + +# Sets the level of detail of messages sent to the log file, if +# a log file location has been provided. Possible values, in +# increasing order of detail, are: "critical", "error", "warning", +# "info" and "debug". When reporting any agent issues to New +# Relic technical support, the most useful setting for the +# support engineers is "debug". However, this can generate a lot +# of information very quickly, so it is best not to keep the +# agent at this level for longer than it takes to reproduce the +# problem you are experiencing. +log_level = info + +# The Python Agent communicates with the New Relic service using +# SSL by default. Note that this does result in an increase in +# CPU overhead, over and above what would occur for a non SSL +# connection, to perform the encryption involved in the SSL +# communication. This work is though done in a distinct thread +# to those handling your web requests, so it should not impact +# response times. You can if you wish revert to using a non SSL +# connection, but this will result in information being sent +# over a plain socket connection and will not be as secure. +ssl = true + +# High Security Mode enforces certain security settings, and +# prevents them from being overridden, so that no sensitive data +# is sent to New Relic. Enabling High Security Mode means that +# SSL is turned on, request parameters are not collected, and SQL +# can not be sent to New Relic in its raw form. To activate High +# Security Mode, it must be set to 'true' in this local .ini +# configuration file AND be set to 'true' in the server-side +# configuration in the New Relic user interface. For details, see +# https://docs.newrelic.com/docs/subscriptions/high-security +high_security = false + +# The Python Agent will attempt to connect directly to the New +# Relic service. If there is an intermediate firewall between +# your host and the New Relic service that requires you to use a +# HTTP proxy, then you should set both the "proxy_host" and +# "proxy_port" settings to the required values for the HTTP +# proxy. The "proxy_user" and "proxy_pass" settings should +# additionally be set if proxy authentication is implemented by +# the HTTP proxy. The "proxy_scheme" setting dictates what +# protocol scheme is used in talking to the HTTP proxy. This +# would normally always be set as "http" which will result in the +# agent then using a SSL tunnel through the HTTP proxy for end to +# end encryption. +# proxy_scheme = http +# proxy_host = hostname +# proxy_port = 8080 +# proxy_user = +# proxy_pass = + +# Capturing request parameters is off by default. To enable the +# capturing of request parameters, first ensure that the setting +# "attributes.enabled" is set to "true" (the default value), and +# then add "request.parameters.*" to the "attributes.include" +# setting. For details about attributes configuration, please +# consult the documentation. +# attributes.include = request.parameters.* + +# The transaction tracer captures deep information about slow +# transactions and sends this to the UI on a periodic basis. The +# transaction tracer is enabled by default. Set this to "false" +# to turn it off. +transaction_tracer.enabled = true + +# Threshold in seconds for when to collect a transaction trace. +# When the response time of a controller action exceeds this +# threshold, a transaction trace will be recorded and sent to +# the UI. Valid values are any positive float value, or (default) +# "apdex_f", which will use the threshold for a dissatisfying +# Apdex controller action - four times the Apdex T value. +transaction_tracer.transaction_threshold = apdex_f + +# When the transaction tracer is on, SQL statements can +# optionally be recorded. The recorder has three modes, "off" +# which sends no SQL, "raw" which sends the SQL statement in its +# original form, and "obfuscated", which strips out numeric and +# string literals. +transaction_tracer.record_sql = obfuscated + +# Threshold in seconds for when to collect stack trace for a SQL +# call. In other words, when SQL statements exceed this +# threshold, then capture and send to the UI the current stack +# trace. This is helpful for pinpointing where long SQL calls +# originate from in an application. +transaction_tracer.stack_trace_threshold = 0.5 + +# Determines whether the agent will capture query plans for slow +# SQL queries. Only supported in MySQL and PostgreSQL. Set this +# to "false" to turn it off. +transaction_tracer.explain_enabled = true + +# Threshold for query execution time below which query plans +# will not not be captured. Relevant only when "explain_enabled" +# is true. +transaction_tracer.explain_threshold = 0.5 + +# Space separated list of function or method names in form +# 'module:function' or 'module:class.function' for which +# additional function timing instrumentation will be added. +transaction_tracer.function_trace = + +# The error collector captures information about uncaught +# exceptions or logged exceptions and sends them to UI for +# viewing. The error collector is enabled by default. Set this +# to "false" to turn it off. +error_collector.enabled = true + +# To stop specific errors from reporting to the UI, set this to +# a space separated list of the Python exception type names to +# ignore. The exception name should be of the form 'module:class'. +error_collector.ignore_errors = + +# Browser monitoring is the Real User Monitoring feature of the UI. +# For those Python web frameworks that are supported, this +# setting enables the auto-insertion of the browser monitoring +# JavaScript fragments. +browser_monitoring.auto_instrument = false + +# A thread profiling session can be scheduled via the UI when +# this option is enabled. The thread profiler will periodically +# capture a snapshot of the call stack for each active thread in +# the application to construct a statistically representative +# call tree. +thread_profiler.enabled = true + +# --------------------------------------------------------------------------- + +# +# The application environments. These are specific settings which +# override the common environment settings. The settings related to a +# specific environment will be used when the environment argument to the +# newrelic.agent.initialize() function has been defined to be either +# "development", "test", "staging" or "production". +# + +[newrelic:development] +app_name = us-notify-api (Development) +monitor_mode = true + +[newrelic:test] +app_name = us-notify-api (Test) +monitor_mode = false + +[newrelic:staging] +app_name = us-notify-api (Staging) +monitor_mode = true + +[newrelic:demo] +app_name = us-notify-api (Demo) +monitor_mode = true + +[newrelic:production] +app_name = us-notify-api +monitor_mode = true + +# --------------------------------------------------------------------------- diff --git a/sample.env b/sample.env index a38f29e2a..8e02bbc3d 100644 --- a/sample.env +++ b/sample.env @@ -56,3 +56,8 @@ NOTIFY_APP_NAME=api FLASK_APP=application.py FLASK_ENV=development WERKZEUG_DEBUG_PIN=off + +############################################################# + +# New Relic +NEW_RELIC_CONFIG_FILE=newrelic.ini From bec3c531287b29532785e9ccf403635399822c90 Mon Sep 17 00:00:00 2001 From: Ryan Ahearn Date: Wed, 18 Jan 2023 09:20:22 -0500 Subject: [PATCH 2/6] Setup newrelic for cloud.gov environments --- .github/workflows/checks.yml | 1 + .github/workflows/daily_checks.yml | 1 + .profile | 1 + deploy-config/egress_proxy/notify-api-demo.allow.acl | 1 + deploy-config/egress_proxy/notify-api-staging.allow.acl | 1 + manifest.yml | 4 +++- newrelic.ini | 4 ++++ scripts/migrate_and_run_web.sh | 2 +- 8 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 70fd96b2d..e5eb879b9 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -8,6 +8,7 @@ permissions: env: DEBUG: True NOTIFY_ENVIRONMENT: test + NEW_RELIC_ENVIRONMENT: test FLASK_APP: application.py FLASK_ENV: development WERKZEUG_DEBUG_PIN: off diff --git a/.github/workflows/daily_checks.yml b/.github/workflows/daily_checks.yml index 34cef2173..2fec03578 100644 --- a/.github/workflows/daily_checks.yml +++ b/.github/workflows/daily_checks.yml @@ -12,6 +12,7 @@ permissions: env: DEBUG: True NOTIFY_ENVIRONMENT: test + NEW_RELIC_ENVIRONMENT: test FLASK_APP: application.py FLASK_ENV: development WERKZEUG_DEBUG_PIN: off diff --git a/.profile b/.profile index 9960f33a2..1c1f98b4b 100644 --- a/.profile +++ b/.profile @@ -4,3 +4,4 @@ ## export https_proxy=$egress_proxy +export NEW_RELIC_PROXY_HOST=$egress_proxy diff --git a/deploy-config/egress_proxy/notify-api-demo.allow.acl b/deploy-config/egress_proxy/notify-api-demo.allow.acl index 711a1adfd..13db9062b 100644 --- a/deploy-config/egress_proxy/notify-api-demo.allow.acl +++ b/deploy-config/egress_proxy/notify-api-demo.allow.acl @@ -1,2 +1,3 @@ email.us-west-2.amazonaws.com sns.us-west-2.amazonaws.com +gov-collector.newrelic.com diff --git a/deploy-config/egress_proxy/notify-api-staging.allow.acl b/deploy-config/egress_proxy/notify-api-staging.allow.acl index 711a1adfd..13db9062b 100644 --- a/deploy-config/egress_proxy/notify-api-staging.allow.acl +++ b/deploy-config/egress_proxy/notify-api-staging.allow.acl @@ -1,2 +1,3 @@ email.us-west-2.amazonaws.com sns.us-west-2.amazonaws.com +gov-collector.newrelic.com diff --git a/manifest.yml b/manifest.yml index 3a75d8c29..29a5c092a 100644 --- a/manifest.yml +++ b/manifest.yml @@ -22,7 +22,7 @@ applications: - type: worker instances: ((worker_instances)) memory: ((worker_memory)) - command: celery -A run_celery.notify_celery worker --loglevel=INFO --concurrency=4 + command: newrelic-admin run-program celery -A run_celery.notify_celery worker --loglevel=INFO --concurrency=4 - type: scheduler instances: 1 memory: ((scheduler_memory)) @@ -32,6 +32,8 @@ applications: NOTIFY_APP_NAME: api FLASK_APP: application.py FLASK_ENV: production + NEW_RELIC_CONFIG_FILE: newrelic.ini + NEW_RELIC_ENVIRONMENT: ((env)) NOTIFY_ENVIRONMENT: ((env)) API_HOST_NAME: https://((public_api_route)) diff --git a/newrelic.ini b/newrelic.ini index 0ecb31567..81762387c 100644 --- a/newrelic.ini +++ b/newrelic.ini @@ -204,6 +204,10 @@ monitor_mode = true app_name = us-notify-api (Test) monitor_mode = false +[newrelic:sandbox] +app_name = us-notify-api (Sandbox) +monitor_mode = false + [newrelic:staging] app_name = us-notify-api (Staging) monitor_mode = true diff --git a/scripts/migrate_and_run_web.sh b/scripts/migrate_and_run_web.sh index 89a4dd5ea..3e39dceb6 100755 --- a/scripts/migrate_and_run_web.sh +++ b/scripts/migrate_and_run_web.sh @@ -4,4 +4,4 @@ if [[ $CF_INSTANCE_INDEX -eq 0 ]]; then flask db upgrade fi -exec gunicorn -c ${HOME}/gunicorn_config.py application +exec newrelic-admin run-program gunicorn -c ${HOME}/gunicorn_config.py application From 50bc1532a348e6cbed00bbb57efdb4edff2df4ae Mon Sep 17 00:00:00 2001 From: Ryan Ahearn Date: Wed, 18 Jan 2023 10:03:45 -0500 Subject: [PATCH 3/6] Turn off newrelic for celery-beat --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d041013e0..e09fba6e9 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ run-celery: ## Run celery, TODO remove purge for staging/prod .PHONY: run-celery-beat run-celery-beat: ## Run celery beat - pipenv run newrelic-admin run-program celery \ + pipenv run celery \ -A run_celery.notify_celery beat \ --loglevel=INFO From 0652b215219e5c3d33c7badf65444b3640597243 Mon Sep 17 00:00:00 2001 From: Ryan Ahearn Date: Wed, 18 Jan 2023 10:49:39 -0500 Subject: [PATCH 4/6] Set new relic license key via env var --- .github/workflows/deploy-demo.yml | 2 ++ .github/workflows/deploy.yml | 2 ++ manifest.yml | 1 + newrelic.ini | 4 ++-- sample.env | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-demo.yml b/.github/workflows/deploy-demo.yml index ac800562b..a474ed8be 100644 --- a/.github/workflows/deploy-demo.yml +++ b/.github/workflows/deploy-demo.yml @@ -53,6 +53,7 @@ jobs: ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} with: cf_username: ${{ secrets.CLOUDGOV_USERNAME }} cf_password: ${{ secrets.CLOUDGOV_PASSWORD }} @@ -65,6 +66,7 @@ jobs: --var ADMIN_CLIENT_SECRET="$ADMIN_CLIENT_SECRET" --var AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" --var AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" + --var NEW_RELIC_LICENSE_KEY="$NEW_RELIC_LICENSE_KEY" - name: Check for changes to egress config id: changed-egress-config diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9349850df..70a1c5c2c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -58,6 +58,7 @@ jobs: ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} with: cf_username: ${{ secrets.CLOUDGOV_USERNAME }} cf_password: ${{ secrets.CLOUDGOV_PASSWORD }} @@ -70,6 +71,7 @@ jobs: --var ADMIN_CLIENT_SECRET="$ADMIN_CLIENT_SECRET" --var AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" --var AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" + --var NEW_RELIC_LICENSE_KEY="$NEW_RELIC_LICENSE_KEY" - name: Check for changes to egress config id: changed-egress-config diff --git a/manifest.yml b/manifest.yml index 29a5c092a..130b2ff2e 100644 --- a/manifest.yml +++ b/manifest.yml @@ -34,6 +34,7 @@ applications: FLASK_ENV: production NEW_RELIC_CONFIG_FILE: newrelic.ini NEW_RELIC_ENVIRONMENT: ((env)) + NEW_RELIC_LICENSE_KEY: ((NEW_RELIC_LICENSE_KEY)) NOTIFY_ENVIRONMENT: ((env)) API_HOST_NAME: https://((public_api_route)) diff --git a/newrelic.ini b/newrelic.ini index 81762387c..996fa6ed5 100644 --- a/newrelic.ini +++ b/newrelic.ini @@ -27,7 +27,7 @@ # You must specify the license key associated with your New # Relic account. This key binds the Python Agent's data to your # account in the New Relic service. -license_key = 88822380cb0c943af94c03098042a78b53d1NRAL +# license_key is set via NEW_RELIC_LICENSE_KEY env var host = gov-collector.newrelic.com @@ -45,7 +45,7 @@ distributed_tracing.enabled = true # application and reports this data to the New Relic UI at # newrelic.com. This global switch is normally overridden for # each environment below. -monitor_mode = true +monitor_mode = false # Sets the name of a file to log agent messages to. Useful for # debugging any issues with the agent. This is not set by diff --git a/sample.env b/sample.env index 8e02bbc3d..70d1fa779 100644 --- a/sample.env +++ b/sample.env @@ -61,3 +61,4 @@ WERKZEUG_DEBUG_PIN=off # New Relic NEW_RELIC_CONFIG_FILE=newrelic.ini +NEW_RELIC_LICENSE_KEY="don't write secrets to the sample file" From b9a53b7b54248b61ba17042e61e4483ea4ff31b5 Mon Sep 17 00:00:00 2001 From: Ryan Ahearn Date: Thu, 19 Jan 2023 09:33:33 -0500 Subject: [PATCH 5/6] Validate new relic config in github actions --- .github/workflows/checks.yml | 14 ++++++++++++++ .github/workflows/daily_checks.yml | 1 + newrelic.ini | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index e5eb879b9..146abfaf6 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -8,6 +8,7 @@ permissions: env: DEBUG: True NOTIFY_ENVIRONMENT: test + NEW_RELIC_CONFIG_FILE: newrelic.ini NEW_RELIC_ENVIRONMENT: test FLASK_APP: application.py FLASK_ENV: development @@ -53,6 +54,19 @@ jobs: env: SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + validate-new-relic-config: + runs-on: ubuntu-latest + environment: staging + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-project + - name: Validate NewRelic config + env: + NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} + # Need to set a NEW_RELIC_ENVIRONMENT with monitor_mode: true + NEW_RELIC_ENVIRONMENT: staging + run: pipenv run newrelic-admin validate-config $NEW_RELIC_CONFIG_FILE + pip-audit: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/daily_checks.yml b/.github/workflows/daily_checks.yml index 2fec03578..e4968f723 100644 --- a/.github/workflows/daily_checks.yml +++ b/.github/workflows/daily_checks.yml @@ -12,6 +12,7 @@ permissions: env: DEBUG: True NOTIFY_ENVIRONMENT: test + NEW_RELIC_CONFIG_FILE: newrelic.ini NEW_RELIC_ENVIRONMENT: test FLASK_APP: application.py FLASK_ENV: development diff --git a/newrelic.ini b/newrelic.ini index 996fa6ed5..ee0d090dc 100644 --- a/newrelic.ini +++ b/newrelic.ini @@ -171,7 +171,7 @@ error_collector.enabled = true # To stop specific errors from reporting to the UI, set this to # a space separated list of the Python exception type names to # ignore. The exception name should be of the form 'module:class'. -error_collector.ignore_errors = +error_collector.ignore_classes = # Browser monitoring is the Real User Monitoring feature of the UI. # For those Python web frameworks that are supported, this From c3faf3df4d4f3b0f11a9eac26d828e80bbe6b29f Mon Sep 17 00:00:00 2001 From: Ryan Ahearn Date: Thu, 19 Jan 2023 09:38:18 -0500 Subject: [PATCH 6/6] Install newrelic before attempting to validate config --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 146abfaf6..c5f2a3d0c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -60,6 +60,8 @@ jobs: steps: - uses: actions/checkout@v3 - uses: ./.github/actions/setup-project + - name: Install pipenv packages + run: pipenv install --dev - name: Validate NewRelic config env: NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }}