Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Commit e737428

Browse files
authored
Set payid metrics protocol version and server agent (#653)
* set new metrics properties for serverAgent and protocolVersion * fix merge booboo with package.json * change how package version is determined so that it works with docker container * include package.json in the build so that config.ts can read the package version * update server-metrics version add test for new metrics
1 parent ba51ad9 commit e737428

File tree

4 files changed

+60
-47
lines changed

4 files changed

+60
-47
lines changed

package-lock.json

Lines changed: 43 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
"main": "./build/src/index.js",
1717
"scripts": {
1818
"build": "run-script-os",
19-
"build:default": "rm -rf build && tsc --project . && npm run copySQL && npm run copyHTML && npm run copyJSON",
20-
"build:win32": "del /q /f build && tsc --project . && npm run copySQL && npm run copyHTML && npm run copyJSON",
19+
"build:default": "rm -rf build && tsc --project . && npm run copySQL && npm run copyHTML && npm run copyJSON && npm run copyPackageJSON",
20+
"build:win32": "del /q /f build && tsc --project . && npm run copySQL && npm run copyHTML && npm run copyJSON && npm run copyPackageJSON",
2121
"buildWatch": "tsc --watch --project .",
2222
"copyHTML": "copyfiles -u 1 src/html/* build/src",
2323
"copySQL": "copyfiles -u 1 **/*.sql build/src",
2424
"copyJSON": "copyfiles -u 1 src/**/*.json build/src",
25+
"copyPackageJSON": "copyfiles package.json build",
2526
"lint": "eslint . --ext .ts --fix --max-warnings 0 && prettier --write '**/*.{md,json}'",
2627
"lintNoFix": "eslint . --ext .ts --max-warnings 0 && prettier --check '**/*.{md,json}'",
2728
"lintWatch": "chokidar src/**/*.ts -c \"npm run lint\" --initial --verbose",
@@ -40,7 +41,7 @@
4041
},
4142
"dependencies": {
4243
"@hapi/boom": "^9.1.0",
43-
"@payid-org/server-metrics": "^1.0.0",
44+
"@payid-org/server-metrics": "^1.1.0",
4445
"@xpring-eng/http-status": "^1.0.0",
4546
"@xpring-eng/logger": "^1.0.0",
4647
"express": "^4.17.1",

src/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { version as packageVersion } from '../package.json'
2+
13
export const payIdServerVersions: readonly string[] = ['1.0', '1.1']
24
export const adminApiVersions: readonly string[] = ['2020-05-28']
35

@@ -59,6 +61,10 @@ const config = {
5961
/** How frequently (in seconds) to refresh the PayID Count report data from the database. */
6062
payIdCountRefreshIntervalInSeconds:
6163
Number(process.env.PAYID_COUNT_REFRESH_INTERVAL) || 60,
64+
65+
payIdProtocolVersion: payIdServerVersions[payIdServerVersions.length - 1],
66+
67+
serverAgent: `@payid-org/payid:${packageVersion}`,
6268
},
6369
}
6470

test/integration/e2e/admin-api/metrics.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ describe('E2E - adminApiRouter - GET /metrics', function (): void {
103103
await assertMetrics(/actual_payid_count\{org="127.0.0.1"\} 18/u)
104104
})
105105

106+
it('Includes server version info', async function () {
107+
await metrics.generatePayIdCountMetrics()
108+
await assertMetrics(
109+
/org="127.0.0.1",serverAgent="@payid-org\/payid:1.*.*",protocolVersion="1.*"\}/u,
110+
)
111+
})
112+
106113
/**
107114
* A helper function that fetches PayID metrics and matches them against
108115
* expected metrics.

0 commit comments

Comments
 (0)