From 883b05a5a863facba35d8de3a2514124368bdf85 Mon Sep 17 00:00:00 2001 From: Massimo Candela Date: Sat, 18 Jan 2020 19:48:33 +0100 Subject: [PATCH] sentry moved as module --- config.yml.example | 5 +- docs/process-monitors.md | 21 +++++ package-lock.json | 130 ++++++++++++++++++++++++++++ package.json | 4 +- src/processMonitors/sentryModule.js | 47 ++++++++++ 5 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 src/processMonitors/sentryModule.js diff --git a/config.yml.example b/config.yml.example index 80e7a96..ae16c4d 100644 --- a/config.yml.example +++ b/config.yml.example @@ -190,7 +190,10 @@ checkForUpdatesAtBoot: true # url: url_to_poll # intervalSeconds: 300 # method: get - +# +# - file: sentryModule +# params: +# dsn: https://@sentry.io/ ############################ diff --git a/docs/process-monitors.md b/docs/process-monitors.md index 6a19ff7..45e88af 100644 --- a/docs/process-monitors.md +++ b/docs/process-monitors.md @@ -18,6 +18,10 @@ processMonitors: url: url_to_poll intervalSeconds: 300 method: get + + - file: sentryModule + params: + dsn: https://@sentry.io/ ``` @@ -98,8 +102,25 @@ Parameters for this module are: |method| The method used for the HTTP request. It can be `get` or `post`. | +## sentryModule +The sentryModule is a component that allows the monitoring of the BGPalerter process for runtime exceptions. +Useful especially for testing new experimental modules. +To enable this feature, create a new project on your Sentry server and grab the generated DSN. +In `config.yml` the sentryModule is declared as: +```yaml +processMonitors: + - file: sentryModule + params: + dsn: https://@sentry.io/ +``` + +Parameters for this module are: + +|Parameter| Description| +|---|---| +|dsn| The DSN where the logs will be sent. | diff --git a/package-lock.json b/package-lock.json index 8b3047c..416a400 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1981,6 +1981,92 @@ "fastq": "^1.6.0" } }, + "@sentry/apm": { + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@sentry/apm/-/apm-5.11.1.tgz", + "integrity": "sha512-4iZH11p/7w9IMLT9hqNY1+EqLESltiIoF6/YsbpK93sXWGEs8VQ83IuvGuKWxajvHgDmj4ND0TxIliTsYqTqFw==", + "requires": { + "@sentry/browser": "5.11.1", + "@sentry/hub": "5.11.1", + "@sentry/minimal": "5.11.1", + "@sentry/types": "5.11.0", + "@sentry/utils": "5.11.1", + "tslib": "^1.9.3" + } + }, + "@sentry/browser": { + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-5.11.1.tgz", + "integrity": "sha512-oqOX/otmuP92DEGRyZeBuQokXdeT9HQRxH73oqIURXXNLMP3PWJALSb4HtT4AftEt/2ROGobZLuA4TaID6My/Q==", + "requires": { + "@sentry/core": "5.11.1", + "@sentry/types": "5.11.0", + "@sentry/utils": "5.11.1", + "tslib": "^1.9.3" + } + }, + "@sentry/core": { + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-5.11.1.tgz", + "integrity": "sha512-BpvPosVNT20Xso4gAV54Lu3KqDmD20vO63HYwbNdST5LUi8oYV4JhvOkoBraPEM2cbBwQvwVcFdeEYKk4tin9A==", + "requires": { + "@sentry/hub": "5.11.1", + "@sentry/minimal": "5.11.1", + "@sentry/types": "5.11.0", + "@sentry/utils": "5.11.1", + "tslib": "^1.9.3" + } + }, + "@sentry/hub": { + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-5.11.1.tgz", + "integrity": "sha512-ucKprYCbGGLLjVz4hWUqHN9KH0WKUkGf5ZYfD8LUhksuobRkYVyig0ZGbshECZxW5jcDTzip4Q9Qimq/PkkXBg==", + "requires": { + "@sentry/types": "5.11.0", + "@sentry/utils": "5.11.1", + "tslib": "^1.9.3" + } + }, + "@sentry/minimal": { + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-5.11.1.tgz", + "integrity": "sha512-HK8zs7Pgdq7DsbZQTThrhQPrJsVWzz7MaluAbQA0rTIAJ3TvHKQpsVRu17xDpjZXypqWcKCRsthDrC4LxDM1Bg==", + "requires": { + "@sentry/hub": "5.11.1", + "@sentry/types": "5.11.0", + "tslib": "^1.9.3" + } + }, + "@sentry/node": { + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@sentry/node/-/node-5.11.1.tgz", + "integrity": "sha512-FbJs0blJ36gEzE0rc2yBfA/KE+kXOLl8MUfFTcyJCBdCGF8XMETDCmgINnJ4TyBUJviwKoPw2TCk9TL2pa/A1w==", + "requires": { + "@sentry/apm": "5.11.1", + "@sentry/core": "5.11.1", + "@sentry/hub": "5.11.1", + "@sentry/types": "5.11.0", + "@sentry/utils": "5.11.1", + "cookie": "^0.3.1", + "https-proxy-agent": "^4.0.0", + "lru_map": "^0.3.3", + "tslib": "^1.9.3" + } + }, + "@sentry/types": { + "version": "5.11.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.11.0.tgz", + "integrity": "sha512-1Uhycpmeo1ZK2GLvrtwZhTwIodJHcyIS6bn+t4IMkN9MFoo6ktbAfhvexBDW/IDtdLlCGJbfm8nIZerxy0QUpg==" + }, + "@sentry/utils": { + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.11.1.tgz", + "integrity": "sha512-O0Zl4R2JJh8cTkQ8ZL2cDqGCmQdpA5VeXpuBbEl1v78LQPkBDISi35wH4mKmLwMsLBtTVpx2UeUHBj0KO5aLlA==", + "requires": { + "@sentry/types": "5.11.0", + "tslib": "^1.9.3" + } + }, "@types/color-name": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", @@ -2017,6 +2103,11 @@ "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true }, + "agent-base": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-5.1.1.tgz", + "integrity": "sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g==" + }, "ajv": { "version": "6.10.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", @@ -3069,6 +3160,11 @@ } } }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", @@ -4724,6 +4820,30 @@ "sshpk": "^1.7.0" } }, + "https-proxy-agent": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz", + "integrity": "sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg==", + "requires": { + "agent-base": "5", + "debug": "4" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "ignore": { "version": "5.1.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.4.tgz", @@ -5321,6 +5441,11 @@ "yallist": "^3.0.2" } }, + "lru_map": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz", + "integrity": "sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0=" + }, "make-dir": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", @@ -7702,6 +7827,11 @@ "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", "integrity": "sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=" }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", diff --git a/package.json b/package.json index 075f629..5928838 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "read-last-lines": "^1.7.2" }, "dependencies": { + "@sentry/node": "^5.11.1", "axios": "^0.19.1", "batch-promises": "^0.0.3", "brembo": "^2.0.3", @@ -44,8 +45,7 @@ "rpki-validator": "^1.0.9", "syslog-client": "^1.1.1", "ws": "^7.2.1", - "yargs": "^15.1.0", - "@sentry/node": "^5.10.2" + "yargs": "^15.1.0" }, "pkg": { "scripts": [ diff --git a/src/processMonitors/sentryModule.js b/src/processMonitors/sentryModule.js new file mode 100644 index 0000000..643b4ad --- /dev/null +++ b/src/processMonitors/sentryModule.js @@ -0,0 +1,47 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2019, NTT Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import * as Sentry from '@sentry/node'; + +export default class SentryModule { + + constructor(connectors, params){ + + if (params.dsn){ + Sentry.init({ dsn: params.dsn }); + } + + }; + +} + +