@tryghost/metrics 3.0.3 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -15
- package/lib/GhostMetrics.js +6 -6
- package/lib/metrics.js +2 -2
- package/package.json +17 -17
package/README.md
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
or
|
|
8
8
|
|
|
9
|
-
`
|
|
10
|
-
|
|
9
|
+
`pnpm add @tryghost/metrics`
|
|
11
10
|
|
|
12
11
|
## Purpose
|
|
13
12
|
|
|
@@ -15,29 +14,24 @@ Ghost metrics facade for collecting and emitting operational metrics across serv
|
|
|
15
14
|
|
|
16
15
|
## Usage
|
|
17
16
|
|
|
18
|
-
|
|
19
17
|
## Develop
|
|
20
18
|
|
|
21
|
-
This is a mono repository, managed with [
|
|
19
|
+
This is a mono repository, managed with [Nx](https://nx.dev).
|
|
22
20
|
|
|
23
21
|
Follow the instructions for the top-level repo.
|
|
24
|
-
1. `git clone` this repo & `cd` into it as usual
|
|
25
|
-
2. Run `yarn` to install top-level dependencies.
|
|
26
22
|
|
|
23
|
+
1. `git clone` this repo & `cd` into it as usual
|
|
24
|
+
2. Run `pnpm install` to install top-level dependencies.
|
|
27
25
|
|
|
28
26
|
## Run
|
|
29
27
|
|
|
30
|
-
- `
|
|
31
|
-
|
|
28
|
+
- `pnpm dev`
|
|
32
29
|
|
|
33
30
|
## Test
|
|
34
31
|
|
|
35
|
-
- `
|
|
36
|
-
- `
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
- `pnpm lint` runs oxlint
|
|
33
|
+
- `pnpm test` runs lint and tests
|
|
40
34
|
|
|
41
|
-
# Copyright & License
|
|
35
|
+
# Copyright & License
|
|
42
36
|
|
|
43
|
-
Copyright (c) 2013-2026 Ghost Foundation - Released under the [MIT license](LICENSE).
|
|
37
|
+
Copyright (c) 2013-2026 Ghost Foundation - Released under the [MIT license](LICENSE).
|
package/lib/GhostMetrics.js
CHANGED
|
@@ -39,7 +39,7 @@ class GhostMetrics {
|
|
|
39
39
|
let transportFn = `setup${transport[0].toUpperCase()}${transport.substr(1)}Shipper`;
|
|
40
40
|
|
|
41
41
|
if (!this[transportFn]) {
|
|
42
|
-
throw new Error(`${transport} is an invalid transport`);
|
|
42
|
+
throw new Error(`${transport} is an invalid transport`);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
this[transportFn]();
|
|
@@ -52,7 +52,7 @@ class GhostMetrics {
|
|
|
52
52
|
setupStdoutShipper() {
|
|
53
53
|
const GhostPrettyStream = require('@tryghost/pretty-stream');
|
|
54
54
|
const prettyStdOut = new GhostPrettyStream({
|
|
55
|
-
mode: this.mode
|
|
55
|
+
mode: this.mode,
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
prettyStdOut.pipe(process.stdout);
|
|
@@ -60,7 +60,7 @@ class GhostMetrics {
|
|
|
60
60
|
this.shippers.stdout = (name, value) => {
|
|
61
61
|
prettyStdOut.write({
|
|
62
62
|
msg: `Metric ${name}: ${jsonStringifySafe(value)}`,
|
|
63
|
-
level: 30 // Magic number, log level for info
|
|
63
|
+
level: 30, // Magic number, log level for info
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
return Promise.resolve();
|
|
@@ -79,15 +79,15 @@ class GhostMetrics {
|
|
|
79
79
|
node: this.elasticsearch.host,
|
|
80
80
|
auth: {
|
|
81
81
|
username: this.elasticsearch.username,
|
|
82
|
-
password: this.elasticsearch.password
|
|
82
|
+
password: this.elasticsearch.password,
|
|
83
83
|
},
|
|
84
84
|
requestTimeout: 5000,
|
|
85
|
-
proxy: 'proxy' in this.elasticsearch ? this.elasticsearch.proxy : null
|
|
85
|
+
proxy: 'proxy' in this.elasticsearch ? this.elasticsearch.proxy : null,
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
this.shippers.elasticsearch = (name, value) => {
|
|
89
89
|
if (typeof value !== 'object') {
|
|
90
|
-
value = {value};
|
|
90
|
+
value = { value };
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
if (!('@timestamp' in value)) {
|
package/lib/metrics.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const {getProcessRoot} = require('@tryghost/root-utils');
|
|
2
|
+
const { getProcessRoot } = require('@tryghost/root-utils');
|
|
3
3
|
const GhostMetrics = require('./GhostMetrics');
|
|
4
4
|
|
|
5
5
|
// Metrics piggy-backs on logging config for transport configuration
|
|
6
6
|
let loggingConfig;
|
|
7
7
|
try {
|
|
8
8
|
loggingConfig = require(path.join(getProcessRoot(), 'loggingrc'));
|
|
9
|
-
} catch
|
|
9
|
+
} catch {
|
|
10
10
|
loggingConfig = {};
|
|
11
11
|
}
|
|
12
12
|
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/metrics",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Ghost Foundation",
|
|
4
6
|
"repository": {
|
|
5
7
|
"type": "git",
|
|
6
8
|
"url": "git+https://github.com/TryGhost/framework.git",
|
|
7
9
|
"directory": "packages/metrics"
|
|
8
10
|
},
|
|
9
|
-
"author": "Ghost Foundation",
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"main": "index.js",
|
|
12
|
-
"scripts": {
|
|
13
|
-
"dev": "echo \"Implement me!\"",
|
|
14
|
-
"test": "NODE_ENV=testing vitest run --coverage",
|
|
15
|
-
"lint": "eslint . --ext .js --cache",
|
|
16
|
-
"posttest": "yarn lint"
|
|
17
|
-
},
|
|
18
11
|
"files": [
|
|
19
12
|
"index.js",
|
|
20
13
|
"lib"
|
|
21
14
|
],
|
|
15
|
+
"main": "index.js",
|
|
22
16
|
"publishConfig": {
|
|
23
17
|
"access": "public"
|
|
24
18
|
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"json-stringify-safe": "5.0.1",
|
|
21
|
+
"@tryghost/elasticsearch": "5.2.0",
|
|
22
|
+
"@tryghost/pretty-stream": "2.2.0",
|
|
23
|
+
"@tryghost/root-utils": "2.2.0"
|
|
24
|
+
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"rewire": "9.0.1",
|
|
27
|
-
"sinon": "21.
|
|
27
|
+
"sinon": "21.1.2"
|
|
28
28
|
},
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
29
|
+
"scripts": {
|
|
30
|
+
"dev": "echo \"Implement me!\"",
|
|
31
|
+
"test": "NODE_ENV=testing vitest run --coverage",
|
|
32
|
+
"lint": "oxlint -c ../../.oxlintrc.json .",
|
|
33
|
+
"posttest": "pnpm run lint"
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
}
|