Skip to content

Commit

Permalink
feat: Added prometheus metrics endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Maelstromeous committed May 26, 2024
1 parent 7c7631c commit 1189d0e
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@
"@nestjs/terminus": "^9.2.1",
"@nestjs/typeorm": "^9.0.1",
"@nestjs/websockets": "^9.3.12",
"@sentry/browser": "^8.4.0",
"@sentry/node": "^8.4.0",
"@sentry/profiling-node": "^8.4.0",
"@types/cache-manager-ioredis": "^2.0.3",
"@types/cron": "^2.0.1",
"@willsoto/nestjs-prometheus": "^6.0.0",
"amqp-connection-manager": "^4.1.11",
"amqplib": "^0.10.3",
"axios": "^1.3.4",
Expand All @@ -63,6 +65,7 @@
"nestjs-swagger-api-implicit-queries-decorator": "^1.0.0",
"passport": "^0.6.0",
"passport-http": "^0.3.0",
"prom-client": "^15.1.2",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.0",
"typeorm": "^0.3.20"
Expand Down
3 changes: 3 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {MongoConfig} from './services/databases/mongo.config';
import {ScheduleModule} from '@nestjs/schedule';
import {CronModule} from './modules/cron/CronModule';
import {HealthCheckModule} from './modules/healthcheck/HealthCheckModule';
import {PrometheusModule} from '@willsoto/nestjs-prometheus';

const metadata = {
imports: [
Expand All @@ -17,6 +18,8 @@ const metadata = {
useClass: MongoConfig,
}),
HealthCheckModule,
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
PrometheusModule.register(),
],
controllers: [DefaultController],
providers: [],
Expand Down
4 changes: 4 additions & 0 deletions src/instrument.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
// Import with `const Sentry = require("@sentry/node");` if you are using CJS
import * as Sentry from '@sentry/node';
import {nodeProfilingIntegration} from '@sentry/profiling-node';
import {browserTracingIntegration} from '@sentry/browser';

Sentry.init({
dsn: 'https://09b6521e230a7a987e3ca046f774760c@o4507319323262976.ingest.de.sentry.io/4507319628922960',
environment: process.env.NODE_ENV,
release: process.env.VERSION,
autoSessionTracking: true,
integrations: [
nodeProfilingIntegration(),
browserTracingIntegration(),
],
// Performance Monitoring
tracesSampleRate: 1.0, // Capture 100% of the transactions
tracePropagationTargets: ['localhost', /^https:\/\/api.ps2alerts\.com\/.*/],

// Set sampling rate for profiling - this is relative to tracesSampleRate
profilesSampleRate: 1.0,
Expand Down
78 changes: 77 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@
dependencies:
"@opentelemetry/api" "^1.0.0"

"@opentelemetry/api@^1.0.0", "@opentelemetry/api@^1.6.0", "@opentelemetry/api@^1.8", "@opentelemetry/api@^1.8.0":
"@opentelemetry/api@^1.0.0", "@opentelemetry/api@^1.4.0", "@opentelemetry/api@^1.6.0", "@opentelemetry/api@^1.8", "@opentelemetry/api@^1.8.0":
version "1.8.0"
resolved "https://registry.yarnpkg.com/@opentelemetry/api/-/api-1.8.0.tgz#5aa7abb48f23f693068ed2999ae627d2f7d902ec"
integrity sha512-I/s6F7yKUDdtMsoBWXJe8Qz40Tui5vsuKCWJEWVL+5q9sSWRzzx6v2KeNsOBEwd94j0eWkpWCH4yB6rZg9Mf0w==
Expand Down Expand Up @@ -1518,6 +1518,57 @@
"@opentelemetry/instrumentation" "^0.49 || ^0.50 || ^0.51"
"@opentelemetry/sdk-trace-base" "^1.22"

"@sentry-internal/[email protected]":
version "8.4.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/browser-utils/-/browser-utils-8.4.0.tgz#5b108878e93713757d75e7e8ae7780297d36ad17"
integrity sha512-Mfm3TK3KUlghhuKM3rjTeD4D5kAiB7iVNFoaDJIJBVKa67M9BvlNTnNJMDi7+9rV4RuLQYxXn0p5HEZJFYp3Zw==
dependencies:
"@sentry/core" "8.4.0"
"@sentry/types" "8.4.0"
"@sentry/utils" "8.4.0"

"@sentry-internal/[email protected]":
version "8.4.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-8.4.0.tgz#81067dadda249b354b72f5adba20374dea43fdf4"
integrity sha512-1/WshI2X9seZAQXrOiv6/LU08fbSSvJU0b1ZWMhn+onb/FWPomsL/UN0WufCYA65S5JZGdaWC8fUcJxWC8PATQ==
dependencies:
"@sentry/core" "8.4.0"
"@sentry/types" "8.4.0"
"@sentry/utils" "8.4.0"

"@sentry-internal/[email protected]":
version "8.4.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-8.4.0.tgz#cf5e903d8935ba6b60a5027d0055902987353920"
integrity sha512-g+U4IPQdODCg7fQQVNvH6ix05Tl1mOQXXRexgtp+tXdys4sHQSBUYraJYZy+mY3OGnLRgKFqELM0fnffJSpuyQ==
dependencies:
"@sentry-internal/replay" "8.4.0"
"@sentry/core" "8.4.0"
"@sentry/types" "8.4.0"
"@sentry/utils" "8.4.0"

"@sentry-internal/[email protected]":
version "8.4.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/replay/-/replay-8.4.0.tgz#8fc4a6bf1d5f480fcde2d56cd75042953e44efda"
integrity sha512-RSzQwCF/QTi5/5XAuj0VJImAhu4MheeHYvAbr/PuMSF4o1j89gBA7e3boA4u8633IqUeu5w3S5sb6jVrKaVifg==
dependencies:
"@sentry-internal/browser-utils" "8.4.0"
"@sentry/core" "8.4.0"
"@sentry/types" "8.4.0"
"@sentry/utils" "8.4.0"

"@sentry/browser@^8.4.0":
version "8.4.0"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-8.4.0.tgz#f4aa381eab212432d71366884693a36c2e3a1675"
integrity sha512-hmXeIZBdN0A6yCuoMTcigGxLl42nbeb205fXtouwE7Maa0qM2HM+Ijq0sHzbhxR3zU0JXDtcJh1k6wtJOREJ3g==
dependencies:
"@sentry-internal/browser-utils" "8.4.0"
"@sentry-internal/feedback" "8.4.0"
"@sentry-internal/replay" "8.4.0"
"@sentry-internal/replay-canvas" "8.4.0"
"@sentry/core" "8.4.0"
"@sentry/types" "8.4.0"
"@sentry/utils" "8.4.0"

"@sentry/[email protected]":
version "8.4.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-8.4.0.tgz#ab3f7202f3cae82daf4c3c408f50d2c6fb913620"
Expand Down Expand Up @@ -2152,6 +2203,11 @@
"@webassemblyjs/ast" "1.11.6"
"@xtuc/long" "4.2.2"

"@willsoto/nestjs-prometheus@^6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@willsoto/nestjs-prometheus/-/nestjs-prometheus-6.0.0.tgz#6ef4d5d5dfb04ebe982aab6f3a7893974e89a669"
integrity sha512-Krmda5CT9xDPjab8Eqdqiwi7xkZSX60A5rEGVLEDjUG6J6Rw5SCZ/BPaRk+MxNGWzUrRkM7K5FtTg38vWIOt1Q==

"@xtuc/ieee754@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790"
Expand Down Expand Up @@ -2482,6 +2538,11 @@ binary-extensions@^2.0.0:
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==

[email protected]:
version "1.0.2"
resolved "https://registry.yarnpkg.com/bintrees/-/bintrees-1.0.2.tgz#49f896d6e858a4a499df85c38fb399b9aff840f8"
integrity sha512-VOMgTMwjAaUG580SXn3LacVgjurrbMme7ZZNYGSSV7mmtY6QQRh0Eg3pwIcntQ77DErK1L0NxkbetjcoXzVwKw==

bl@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a"
Expand Down Expand Up @@ -5569,6 +5630,14 @@ process@^0.11.10:
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==

prom-client@^15.1.2:
version "15.1.2"
resolved "https://registry.yarnpkg.com/prom-client/-/prom-client-15.1.2.tgz#78d79f12c35d395ca97edf7111c18210cf07f815"
integrity sha512-on3h1iXb04QFLLThrmVYg1SChBQ9N1c+nKAjebBjokBqipddH3uxmOUcEkTnzmJ8Jh/5TSUnUqS40i2QB2dJHQ==
dependencies:
"@opentelemetry/api" "^1.4.0"
tdigest "^0.1.1"

promise-breaker@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/promise-breaker/-/promise-breaker-6.0.0.tgz#107d2b70f161236abdb4ac5a736c7eb8df489d0f"
Expand Down Expand Up @@ -6325,6 +6394,13 @@ tapable@^2.1.1, tapable@^2.2.0, tapable@^2.2.1:
resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0"
integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==

tdigest@^0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/tdigest/-/tdigest-0.1.2.tgz#96c64bac4ff10746b910b0e23b515794e12faced"
integrity sha512-+G0LLgjjo9BZX2MfdvPfH+MKLCrxlXSYec5DaPYP1fe6Iyhf0/fSmJ0bFiZ1F8BT6cGXl2LpltQptzjXKWEkKA==
dependencies:
bintrees "1.0.2"

terser-webpack-plugin@^5.3.7:
version "5.3.8"
resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.8.tgz#415e03d2508f7de63d59eca85c5d102838f06610"
Expand Down

0 comments on commit 1189d0e

Please sign in to comment.