Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example of moving over to the monitoring library #479

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,26 @@ jobs:
name: node build
uses: ministryofjustice/hmpps-github-actions/.github/workflows/node_build.yml@v1 # WORKFLOW_VERSION
secrets: inherit
with:
node_version: 22.11
ushkarev marked this conversation as resolved.
Show resolved Hide resolved
# generic node unit tests - feel free to override with local tests if required
node_unit_tests:
name: node unit tests
uses: ministryofjustice/hmpps-github-actions/.github/workflows/node_unit_tests.yml@v1 # WORKFLOW_VERSION
with:
node_version: 22.11
needs: [node_build]
secrets: inherit

# generic node integration tests using wiremock - feel free to override with local tests if required
node_integration_tests:
name: node integration tests
uses: ministryofjustice/hmpps-github-actions/.github/workflows/node_integration_tests.yml@v1 # WORKFLOW_VERSION
needs: [node_build]
secrets: inherit
with:
node_version: 22.11

helm_lint:
strategy:
matrix:
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"dependencies": {
"@aws-sdk/client-sqs": "^3.682.0",
"@ministryofjustice/frontend": "^3.0.1",
"@ministryofjustice/hmpps-monitoring": "^0.0.1-alpha.6",
"agentkeepalive": "^4.5.0",
"applicationinsights": "^2.9.6",
"body-parser": "^1.20.3",
Expand Down
2 changes: 1 addition & 1 deletion server/applicationInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type ApplicationInfo = {
buildNumber: string
gitRef: string
gitShortHash: string
productId?: string
productId: string
branchName: string
}

Expand Down
2 changes: 2 additions & 0 deletions server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default {
apis: {
hmppsAuth: {
url: get('HMPPS_AUTH_URL', 'http://localhost:9090/auth', requiredInProduction),
healthPath: '/health/ping`',
externalUrl: get('HMPPS_AUTH_EXTERNAL_URL', get('HMPPS_AUTH_URL', 'http://localhost:9090/auth')),
timeout: {
response: Number(get('HMPPS_AUTH_TIMEOUT_RESPONSE', 10000)),
Expand All @@ -83,6 +84,7 @@ export default {
},
tokenVerification: {
url: get('TOKEN_VERIFICATION_API_URL', 'http://localhost:8100', requiredInProduction),
healthPath: '/health/ping`',
timeout: {
response: Number(get('TOKEN_VERIFICATION_API_TIMEOUT_RESPONSE', 5000)),
deadline: Number(get('TOKEN_VERIFICATION_API_TIMEOUT_DEADLINE', 5000)),
Expand Down
83 changes: 0 additions & 83 deletions server/data/healthCheck.test.ts

This file was deleted.

43 changes: 0 additions & 43 deletions server/data/healthCheck.ts

This file was deleted.

36 changes: 10 additions & 26 deletions server/middleware/setUpHealthChecks.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
import express, { Router } from 'express'

import healthcheck from '../services/healthCheck'
import { monitoringMiddleware, endpointHealthComponent } from '@ministryofjustice/hmpps-monitoring'
import type { ApplicationInfo } from '../applicationInfo'
import logger from '../../logger'
import config from '../config'

export default function setUpHealthChecks(applicationInfo: ApplicationInfo): Router {
const router = express.Router()

router.get('/health', (req, res, next) => {
healthcheck(applicationInfo, result => {
if (result.status !== 'UP') {
res.status(503)
}
res.json(result)
})
})
const apiConfig = Object.entries(config.apis)

router.get('/ping', (req, res) => {
res.send({
status: 'UP',
})
const middleware = monitoringMiddleware({
applicationInfo,
healthComponents: apiConfig.map(([name, options]) => endpointHealthComponent(logger, name, options)),
})

router.get('/info', (req, res) => {
res.json({
git: {
branch: applicationInfo.branchName,
},
build: {
artifact: applicationInfo.applicationName,
version: applicationInfo.buildNumber,
name: applicationInfo.applicationName,
},
productId: applicationInfo.productId,
})
})
router.get('/health', middleware.health)
router.get('/info', middleware.info)
router.get('/ping', middleware.ping)

return router
}
81 changes: 0 additions & 81 deletions server/services/healthCheck.test.ts

This file was deleted.

Loading
Loading