@tryghost/metrics 3.3.5 → 3.4.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/index.d.ts +3 -0
- package/lib/GhostMetrics.d.ts +80 -0
- package/lib/metrics.d.ts +18 -0
- package/package.json +6 -4
package/index.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Elasticsearch transport configuration.
|
|
3
|
+
*/
|
|
4
|
+
interface ElasticsearchOptions {
|
|
5
|
+
/** Elasticsearch node URL (maps to the client `node` option). */
|
|
6
|
+
host?: string;
|
|
7
|
+
/** Basic-auth username. */
|
|
8
|
+
username?: string;
|
|
9
|
+
/** Basic-auth password. */
|
|
10
|
+
password?: string;
|
|
11
|
+
/** Optional proxy URL; when absent no proxy is used. */
|
|
12
|
+
proxy?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Metrics-specific configuration, piggy-backed on the logging config.
|
|
17
|
+
*/
|
|
18
|
+
interface MetricsOptions {
|
|
19
|
+
/** Transports to ship metrics through (e.g. `['stdout', 'elasticsearch']`). */
|
|
20
|
+
transports?: string[];
|
|
21
|
+
/** Property bag of metadata values shipped alongside each metric value. */
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Options bag accepted by the {@link GhostMetrics} constructor.
|
|
27
|
+
*/
|
|
28
|
+
interface GhostMetricsOptions {
|
|
29
|
+
/** Metadata for metrics in shared databases. @default 'localhost' */
|
|
30
|
+
domain?: string;
|
|
31
|
+
/** Print short or long log form for the stdout shipper. @default 'short' */
|
|
32
|
+
mode?: string;
|
|
33
|
+
/** Elasticsearch transport configuration. */
|
|
34
|
+
elasticsearch?: ElasticsearchOptions;
|
|
35
|
+
/** Metric transport/metadata configuration. */
|
|
36
|
+
metrics?: MetricsOptions;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A single metric shipper function keyed by transport name.
|
|
41
|
+
*/
|
|
42
|
+
type MetricShipper = (name: string, value: unknown) => Promise<unknown>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Metric shipper class built on the loggingrc config used in Ghost projects.
|
|
46
|
+
*/
|
|
47
|
+
declare class GhostMetrics {
|
|
48
|
+
domain: string;
|
|
49
|
+
elasticsearch: ElasticsearchOptions;
|
|
50
|
+
mode: string;
|
|
51
|
+
transports: string[];
|
|
52
|
+
metadata: Record<string, unknown>;
|
|
53
|
+
shippers: Record<string, MetricShipper>;
|
|
54
|
+
|
|
55
|
+
constructor(options?: GhostMetricsOptions);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Setup stdout stream shipper.
|
|
59
|
+
*/
|
|
60
|
+
setupStdoutShipper(): void;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Setup ElasticSearch metric shipper. Metrics are shipped to a per-metric
|
|
64
|
+
* index named `metrics-<name>`; the metric name should be sluggified.
|
|
65
|
+
*/
|
|
66
|
+
setupElasticsearchShipper(): void;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Ship a metric through every configured transport.
|
|
70
|
+
* @param name Metric name, should be slugified for back-end compatibility (e.g. `"memory-usage"`).
|
|
71
|
+
* @param value Metric value; coerced to an object before being shipped.
|
|
72
|
+
*/
|
|
73
|
+
metric(name: string, value: unknown): Promise<null>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare namespace GhostMetrics {
|
|
77
|
+
export { ElasticsearchOptions, MetricsOptions, GhostMetricsOptions, MetricShipper };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export = GhostMetrics;
|
package/lib/metrics.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import GhostMetrics = require('./GhostMetrics');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A pre-configured `GhostMetrics` instance (built from `loggingrc` if present),
|
|
5
|
+
* with the `GhostMetrics` class attached for creating additional instances.
|
|
6
|
+
*/
|
|
7
|
+
declare const metrics: GhostMetrics & {
|
|
8
|
+
GhostMetrics: typeof GhostMetrics;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
declare namespace metrics {
|
|
12
|
+
export type ElasticsearchOptions = GhostMetrics.ElasticsearchOptions;
|
|
13
|
+
export type MetricsOptions = GhostMetrics.MetricsOptions;
|
|
14
|
+
export type GhostMetricsOptions = GhostMetrics.GhostMetricsOptions;
|
|
15
|
+
export type MetricShipper = GhostMetrics.MetricShipper;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export = metrics;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/metrics",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"repository": {
|
|
@@ -10,17 +10,19 @@
|
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"index.js",
|
|
13
|
+
"index.d.ts",
|
|
13
14
|
"lib"
|
|
14
15
|
],
|
|
15
16
|
"main": "index.js",
|
|
17
|
+
"types": "index.d.ts",
|
|
16
18
|
"publishConfig": {
|
|
17
19
|
"access": "public"
|
|
18
20
|
},
|
|
19
21
|
"dependencies": {
|
|
20
22
|
"json-stringify-safe": "5.0.1",
|
|
21
|
-
"@tryghost/elasticsearch": "5.4.
|
|
22
|
-
"@tryghost/pretty-stream": "2.3.
|
|
23
|
-
"@tryghost/root-utils": "2.3.
|
|
23
|
+
"@tryghost/elasticsearch": "5.4.4",
|
|
24
|
+
"@tryghost/pretty-stream": "2.3.7",
|
|
25
|
+
"@tryghost/root-utils": "2.3.7"
|
|
24
26
|
},
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"rewire": "9.0.1",
|