@tryghost/metrics 3.6.2 → 3.7.1
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 +13 -0
- package/lib/GhostMetrics.d.ts +10 -1
- package/lib/GhostMetrics.js +10 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -29,6 +29,19 @@ const custom = new metrics.GhostMetrics({
|
|
|
29
29
|
});
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
### Elasticsearch client implementation
|
|
33
|
+
|
|
34
|
+
`elasticsearch.implementation` picks how the Elasticsearch transport talks to
|
|
35
|
+
the cluster. `legacy` (the default) uses the official `@elastic/elasticsearch`
|
|
36
|
+
client; `fetch` uses Node's built-in `fetch`. The `fetch` implementation will
|
|
37
|
+
become the only one in the next major version.
|
|
38
|
+
|
|
39
|
+
`elasticsearch.proxy` only works with `legacy`. With `fetch`, it's ignored with
|
|
40
|
+
a warning: set `HTTP_PROXY` or `HTTPS_PROXY` to match the Elasticsearch URL's
|
|
41
|
+
scheme (and `NO_PROXY` as needed), and enable them with `NODE_USE_ENV_PROXY=1`
|
|
42
|
+
or `--use-env-proxy`. This needs Node 22.21.0+ on the 22.x line, or Node 24+,
|
|
43
|
+
and applies to every request the process makes.
|
|
44
|
+
|
|
32
45
|
### Sampling
|
|
33
46
|
|
|
34
47
|
High-volume metrics can be sampled so only a proportion of them are shipped.
|
package/lib/GhostMetrics.d.ts
CHANGED
|
@@ -10,8 +10,17 @@ interface ElasticsearchOptions {
|
|
|
10
10
|
username?: string;
|
|
11
11
|
/** Basic-auth password. */
|
|
12
12
|
password?: string;
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Optional proxy URL; when absent no proxy is used. Only supported by the
|
|
15
|
+
* `legacy` implementation; with `fetch`, set `HTTP_PROXY`/`HTTPS_PROXY` and
|
|
16
|
+
* `NODE_USE_ENV_PROXY=1` (Node 22.21.0+ or 24+) instead.
|
|
17
|
+
*/
|
|
14
18
|
proxy?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Client implementation: `legacy` uses the official Elasticsearch client,
|
|
21
|
+
* `fetch` uses Node's built-in fetch. @default 'legacy'
|
|
22
|
+
*/
|
|
23
|
+
implementation?: 'legacy' | 'fetch';
|
|
15
24
|
}
|
|
16
25
|
|
|
17
26
|
/**
|
package/lib/GhostMetrics.js
CHANGED
|
@@ -277,7 +277,17 @@ class GhostMetrics {
|
|
|
277
277
|
setupElasticsearchShipper() {
|
|
278
278
|
const ElasticSearch = require('@tryghost/elasticsearch');
|
|
279
279
|
|
|
280
|
+
const implementation = this.elasticsearch.implementation;
|
|
281
|
+
|
|
282
|
+
if (implementation === 'fetch' && this.elasticsearch.proxy) {
|
|
283
|
+
process.emitWarning(
|
|
284
|
+
'elasticsearch.proxy is not supported by the fetch implementation and is ignored. Set HTTP_PROXY/HTTPS_PROXY and NODE_USE_ENV_PROXY=1 (Node 22.21.0+ or 24+) to proxy Elasticsearch requests.',
|
|
285
|
+
{ code: 'GHOST_METRICS_ELASTICSEARCH_PROXY' },
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
280
289
|
const elasticSearch = new ElasticSearch({
|
|
290
|
+
implementation,
|
|
281
291
|
node: this.elasticsearch.host,
|
|
282
292
|
auth: {
|
|
283
293
|
username: this.elasticsearch.username,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/metrics",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"repository": {
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@tryghost/elasticsearch": "^
|
|
23
|
-
"@tryghost/pretty-stream": "^2.3.
|
|
24
|
-
"@tryghost/root-utils": "^2.3.
|
|
22
|
+
"@tryghost/elasticsearch": "^6.0.1",
|
|
23
|
+
"@tryghost/pretty-stream": "^2.3.18",
|
|
24
|
+
"@tryghost/root-utils": "^2.3.18",
|
|
25
25
|
"json-stringify-safe": "^5.0.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"dev": "echo \"Implement me!\"",
|
|
32
|
-
"test": "NODE_ENV=testing vitest run --coverage",
|
|
32
|
+
"test": "NODE_ENV=testing vitest run --config ../../vitest.config.ts --root . --coverage",
|
|
33
33
|
"lint": "oxlint -c ../../.oxlintrc.json .",
|
|
34
34
|
"posttest": "pnpm run lint"
|
|
35
35
|
}
|