@xyo-network/prometheus-node-plugin 2.96.1 → 2.96.2
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/dist/neutral/Plugin.d.cts +8 -8
- package/dist/neutral/Plugin.d.mts +8 -8
- package/dist/neutral/Plugin.d.ts +8 -8
- package/dist/neutral/Witness.d.cts +0 -1
- package/dist/neutral/Witness.d.cts.map +1 -1
- package/dist/neutral/Witness.d.mts +0 -1
- package/dist/neutral/Witness.d.mts.map +1 -1
- package/dist/neutral/Witness.d.ts +0 -1
- package/dist/neutral/Witness.d.ts.map +1 -1
- package/dist/neutral/index.cjs +1 -93
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +1 -70
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/Plugin.d.cts +8 -8
- package/dist/node/Plugin.d.mts +8 -8
- package/dist/node/Plugin.d.ts +8 -8
- package/dist/node/Witness.d.cts +0 -1
- package/dist/node/Witness.d.cts.map +1 -1
- package/dist/node/Witness.d.mts +0 -1
- package/dist/node/Witness.d.mts.map +1 -1
- package/dist/node/Witness.d.ts +0 -1
- package/dist/node/Witness.d.ts.map +1 -1
- package/dist/node/index.cjs +1 -101
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +1 -71
- package/dist/node/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { PrometheusNodeWitness } from './Witness';
|
|
2
2
|
export declare const PrometheusNodePlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<PrometheusNodeWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
|
-
account?: import("@xyo-network/account-model").AccountInstance | "random"
|
|
4
|
-
addToResolvers?: boolean
|
|
5
|
-
additionalSigners?: import("@xyo-network/account-model").AccountInstance[]
|
|
6
|
-
allowNameResolution?: boolean
|
|
3
|
+
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
|
+
addToResolvers?: boolean;
|
|
5
|
+
additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
|
|
6
|
+
allowNameResolution?: boolean;
|
|
7
7
|
config: import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & {
|
|
8
8
|
schema: "network.xyo.prometheus.node.witness.config";
|
|
9
9
|
} & {
|
|
10
|
-
port?: number
|
|
11
|
-
schema: "
|
|
10
|
+
port?: number;
|
|
11
|
+
schema: import("./Witness").PrometheusNodeWitnessConfigSchema;
|
|
12
12
|
}, "schema"> & {
|
|
13
13
|
schema: "network.xyo.prometheus.node.witness.config";
|
|
14
14
|
}, "schema"> & {
|
|
15
15
|
schema: string;
|
|
16
16
|
};
|
|
17
|
-
ephemeralQueryAccountEnabled?: boolean
|
|
18
|
-
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[]
|
|
17
|
+
ephemeralQueryAccountEnabled?: boolean;
|
|
18
|
+
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
19
19
|
}>>;
|
|
20
20
|
//# sourceMappingURL=Plugin.d.ts.map
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { PrometheusNodeWitness } from './Witness';
|
|
2
2
|
export declare const PrometheusNodePlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<PrometheusNodeWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
|
-
account?: import("@xyo-network/account-model").AccountInstance | "random"
|
|
4
|
-
addToResolvers?: boolean
|
|
5
|
-
additionalSigners?: import("@xyo-network/account-model").AccountInstance[]
|
|
6
|
-
allowNameResolution?: boolean
|
|
3
|
+
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
|
+
addToResolvers?: boolean;
|
|
5
|
+
additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
|
|
6
|
+
allowNameResolution?: boolean;
|
|
7
7
|
config: import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & {
|
|
8
8
|
schema: "network.xyo.prometheus.node.witness.config";
|
|
9
9
|
} & {
|
|
10
|
-
port?: number
|
|
11
|
-
schema: "
|
|
10
|
+
port?: number;
|
|
11
|
+
schema: import("./Witness").PrometheusNodeWitnessConfigSchema;
|
|
12
12
|
}, "schema"> & {
|
|
13
13
|
schema: "network.xyo.prometheus.node.witness.config";
|
|
14
14
|
}, "schema"> & {
|
|
15
15
|
schema: string;
|
|
16
16
|
};
|
|
17
|
-
ephemeralQueryAccountEnabled?: boolean
|
|
18
|
-
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[]
|
|
17
|
+
ephemeralQueryAccountEnabled?: boolean;
|
|
18
|
+
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
19
19
|
}>>;
|
|
20
20
|
//# sourceMappingURL=Plugin.d.ts.map
|
package/dist/neutral/Plugin.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { PrometheusNodeWitness } from './Witness';
|
|
2
2
|
export declare const PrometheusNodePlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<PrometheusNodeWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
|
-
account?: import("@xyo-network/account-model").AccountInstance | "random"
|
|
4
|
-
addToResolvers?: boolean
|
|
5
|
-
additionalSigners?: import("@xyo-network/account-model").AccountInstance[]
|
|
6
|
-
allowNameResolution?: boolean
|
|
3
|
+
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
|
+
addToResolvers?: boolean;
|
|
5
|
+
additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
|
|
6
|
+
allowNameResolution?: boolean;
|
|
7
7
|
config: import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & {
|
|
8
8
|
schema: "network.xyo.prometheus.node.witness.config";
|
|
9
9
|
} & {
|
|
10
|
-
port?: number
|
|
11
|
-
schema: "
|
|
10
|
+
port?: number;
|
|
11
|
+
schema: import("./Witness").PrometheusNodeWitnessConfigSchema;
|
|
12
12
|
}, "schema"> & {
|
|
13
13
|
schema: "network.xyo.prometheus.node.witness.config";
|
|
14
14
|
}, "schema"> & {
|
|
15
15
|
schema: string;
|
|
16
16
|
};
|
|
17
|
-
ephemeralQueryAccountEnabled?: boolean
|
|
18
|
-
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[]
|
|
17
|
+
ephemeralQueryAccountEnabled?: boolean;
|
|
18
|
+
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
19
19
|
}>>;
|
|
20
20
|
//# sourceMappingURL=Plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,WAAW,CAAA;AAGhD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAmB,MAAM,2BAA2B,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACzE,OAAO,EAAyB,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK7D,MAAM,MAAM,iCAAiC,GAAG,4CAA4C,CAAA;AAC5F,eAAO,MAAM,iCAAiC,EAAE,iCAAgF,CAAA;AAEhI,MAAM,MAAM,2BAA2B,GAAG,aAAa,CAAC;IACtD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,iCAAiC,CAAA;CAC1C,CAAC,CAAA;AAEF,MAAM,MAAM,2BAA2B,GAAG,aAAa,CAAC,eAAe,CAAC,2BAA2B,CAAC,CAAC,CAAA;AAGrG,qBAAa,qBAAqB,CAAC,OAAO,SAAS,2BAA2B,GAAG,2BAA2B,CAAE,SAAQ,eAAe,CAAC,OAAO,CAAC;IAC5I,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA8D;IAC9G,gBAAyB,mBAAmB,EAAE,MAAM,CAAoC;IACxF,SAAS,CAAC,SAAS,uDAAiB;IACpC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IAEzB,IAAI,QAAQ,IAAI,QAAQ,CAEvB;cAEwB,cAAc,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;cAIlE,YAAY;cAcZ,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;YAK1C,oBAAoB;CAUnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,WAAW,CAAA;AAGhD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAmB,MAAM,2BAA2B,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACzE,OAAO,EAAyB,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK7D,MAAM,MAAM,iCAAiC,GAAG,4CAA4C,CAAA;AAC5F,eAAO,MAAM,iCAAiC,EAAE,iCAAgF,CAAA;AAEhI,MAAM,MAAM,2BAA2B,GAAG,aAAa,CAAC;IACtD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,iCAAiC,CAAA;CAC1C,CAAC,CAAA;AAEF,MAAM,MAAM,2BAA2B,GAAG,aAAa,CAAC,eAAe,CAAC,2BAA2B,CAAC,CAAC,CAAA;AAGrG,qBAAa,qBAAqB,CAAC,OAAO,SAAS,2BAA2B,GAAG,2BAA2B,CAAE,SAAQ,eAAe,CAAC,OAAO,CAAC;IAC5I,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA8D;IAC9G,gBAAyB,mBAAmB,EAAE,MAAM,CAAoC;IACxF,SAAS,CAAC,SAAS,uDAAiB;IACpC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IAEzB,IAAI,QAAQ,IAAI,QAAQ,CAEvB;cAEwB,cAAc,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;cAIlE,YAAY;cAcZ,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;YAK1C,oBAAoB;CAUnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,WAAW,CAAA;AAGhD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAmB,MAAM,2BAA2B,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACzE,OAAO,EAAyB,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK7D,MAAM,MAAM,iCAAiC,GAAG,4CAA4C,CAAA;AAC5F,eAAO,MAAM,iCAAiC,EAAE,iCAAgF,CAAA;AAEhI,MAAM,MAAM,2BAA2B,GAAG,aAAa,CAAC;IACtD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,iCAAiC,CAAA;CAC1C,CAAC,CAAA;AAEF,MAAM,MAAM,2BAA2B,GAAG,aAAa,CAAC,eAAe,CAAC,2BAA2B,CAAC,CAAC,CAAA;AAGrG,qBAAa,qBAAqB,CAAC,OAAO,SAAS,2BAA2B,GAAG,2BAA2B,CAAE,SAAQ,eAAe,CAAC,OAAO,CAAC;IAC5I,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA8D;IAC9G,gBAAyB,mBAAmB,EAAE,MAAM,CAAoC;IACxF,SAAS,CAAC,SAAS,uDAAiB;IACpC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IAEzB,IAAI,QAAQ,IAAI,QAAQ,CAEvB;cAEwB,cAAc,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;cAIlE,YAAY;cAcZ,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;YAK1C,oBAAoB;CAUnC"}
|
package/dist/neutral/index.cjs
CHANGED
|
@@ -1,94 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
PrometheusMetricValueSchema: () => PrometheusMetricValueSchema,
|
|
24
|
-
PrometheusNodePlugin: () => PrometheusNodePlugin,
|
|
25
|
-
PrometheusNodeWitness: () => PrometheusNodeWitness,
|
|
26
|
-
PrometheusNodeWitnessConfigSchema: () => PrometheusNodeWitnessConfigSchema,
|
|
27
|
-
default: () => PrometheusNodePlugin
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(src_exports);
|
|
30
|
-
|
|
31
|
-
// src/Plugin.ts
|
|
32
|
-
var import_payload_model = require("@xyo-network/payload-model");
|
|
33
|
-
var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
|
|
34
|
-
|
|
35
|
-
// src/Schema.ts
|
|
36
|
-
var PrometheusMetricValueSchema = "network.xyo.prometheus.metric.value";
|
|
37
|
-
|
|
38
|
-
// src/Witness.ts
|
|
39
|
-
var import_node_http = require("http");
|
|
40
|
-
var import_lodash = require("@xylabs/lodash");
|
|
41
|
-
var import_abstract_witness = require("@xyo-network/abstract-witness");
|
|
42
|
-
var import_module_model = require("@xyo-network/module-model");
|
|
43
|
-
var import_prom_client = require("prom-client");
|
|
44
|
-
var PrometheusNodeWitnessConfigSchema = "network.xyo.prometheus.node.witness.config";
|
|
45
|
-
(0, import_module_model.creatableModule)();
|
|
46
|
-
var PrometheusNodeWitness = class extends import_abstract_witness.AbstractWitness {
|
|
47
|
-
static configSchemas = [...super.configSchemas, PrometheusNodeWitnessConfigSchema];
|
|
48
|
-
static defaultConfigSchema = PrometheusNodeWitnessConfigSchema;
|
|
49
|
-
_registry = new import_prom_client.Registry();
|
|
50
|
-
server;
|
|
51
|
-
get registry() {
|
|
52
|
-
return this._registry;
|
|
53
|
-
}
|
|
54
|
-
async observeHandler(_payloads) {
|
|
55
|
-
return await this.generateMetricValues();
|
|
56
|
-
}
|
|
57
|
-
async startHandler() {
|
|
58
|
-
(0, import_prom_client.collectDefaultMetrics)({ register: this._registry });
|
|
59
|
-
if (this.config.port) {
|
|
60
|
-
this.server = (0, import_node_http.createServer)(async (_request, response) => {
|
|
61
|
-
response.writeHead(200);
|
|
62
|
-
response.end(await this._registry.metrics());
|
|
63
|
-
});
|
|
64
|
-
this.server.listen(this.config.port);
|
|
65
|
-
}
|
|
66
|
-
return await super.startHandler();
|
|
67
|
-
}
|
|
68
|
-
async stopHandler() {
|
|
69
|
-
this.server?.close();
|
|
70
|
-
return await super.stopHandler();
|
|
71
|
-
}
|
|
72
|
-
async generateMetricValues() {
|
|
73
|
-
return (0, import_lodash.compact)(
|
|
74
|
-
(await this._registry.getMetricsAsJSON()).map((metric) => {
|
|
75
|
-
const values = metric.values;
|
|
76
|
-
if (values) {
|
|
77
|
-
return { aggregator: metric.aggregator, name: metric.name, schema: PrometheusMetricValueSchema, type: metric.type, values };
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// src/Plugin.ts
|
|
85
|
-
var PrometheusNodePlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)(
|
|
86
|
-
{ required: { [PrometheusMetricValueSchema]: 1 }, schema: import_payload_model.PayloadSetSchema },
|
|
87
|
-
{
|
|
88
|
-
witness: async (params) => {
|
|
89
|
-
const result = await PrometheusNodeWitness.create(params);
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
);
|
|
1
|
+
"use strict";var m=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var v=(r,e)=>{for(var t in e)m(r,t,{get:e[t],enumerable:!0})},x=(r,e,t,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of y(e))!S.call(r,o)&&o!==t&&m(r,o,{get:()=>e[o],enumerable:!(u=f(e,o))||u.enumerable});return r};var W=r=>x(m({},"__esModule",{value:!0}),r);var w={};v(w,{PrometheusMetricValueSchema:()=>s,PrometheusNodePlugin:()=>c,PrometheusNodeWitness:()=>a,PrometheusNodeWitnessConfigSchema:()=>n,default:()=>c});module.exports=W(w);var P=require("@xyo-network/payload-model"),g=require("@xyo-network/payloadset-plugin");var s="network.xyo.prometheus.metric.value";var h=require("http"),p=require("@xylabs/lodash"),d=require("@xyo-network/abstract-witness"),l=require("@xyo-network/module-model"),i=require("prom-client");var n="network.xyo.prometheus.node.witness.config";(0,l.creatableModule)();var a=class extends d.AbstractWitness{static configSchemas=[...super.configSchemas,n];static defaultConfigSchema=n;_registry=new i.Registry;server;get registry(){return this._registry}async observeHandler(e){return await this.generateMetricValues()}async startHandler(){return(0,i.collectDefaultMetrics)({register:this._registry}),this.config.port&&(this.server=(0,h.createServer)(async(e,t)=>{t.writeHead(200),t.end(await this._registry.metrics())}),this.server.listen(this.config.port)),await super.startHandler()}async stopHandler(){return this.server?.close(),await super.stopHandler()}async generateMetricValues(){return(0,p.compact)((await this._registry.getMetricsAsJSON()).map(e=>{let t=e.values;if(t)return{aggregator:e.aggregator,name:e.name,schema:s,type:e.type,values:t}}))}};var c=()=>(0,g.createPayloadSetWitnessPlugin)({required:{[s]:1},schema:P.PayloadSetSchema},{witness:async r=>await a.create(r)});
|
|
94
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Schema.ts","../../src/Witness.ts"],"sourcesContent":["export * from './Payload'\nexport { PrometheusNodePlugin as default, PrometheusNodePlugin } from './Plugin'\nexport * from './Schema'\nexport * from './Witness'\n","import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { PrometheusMetricValueSchema } from './Schema'\nimport { PrometheusNodeWitness } from './Witness'\n\nexport const PrometheusNodePlugin = () =>\n createPayloadSetWitnessPlugin<PrometheusNodeWitness>(\n { required: { [PrometheusMetricValueSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await PrometheusNodeWitness.create(params)\n return result\n },\n },\n )\n","export type PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\nexport const PrometheusMetricValueSchema: PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\n","import { createServer, Server } from 'node:http'\n\nimport { compact } from '@xylabs/lodash'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { AnyConfigSchema, creatableModule } from '@xyo-network/module-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\nimport { WitnessConfig, WitnessParams } from '@xyo-network/witness-model'\nimport { collectDefaultMetrics, Registry } from 'prom-client'\n\nimport { PrometheusMetricValuePayload } from './Payload'\nimport { PrometheusMetricValueSchema } from './Schema'\n\nexport type PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\nexport const PrometheusNodeWitnessConfigSchema: PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\n\nexport type PrometheusNodeWitnessConfig = WitnessConfig<{\n port?: number\n schema: PrometheusNodeWitnessConfigSchema\n}>\n\nexport type PrometheusNodeWitnessParams = WitnessParams<AnyConfigSchema<PrometheusNodeWitnessConfig>>\n\ncreatableModule()\nexport class PrometheusNodeWitness<TParams extends PrometheusNodeWitnessParams = PrometheusNodeWitnessParams> extends AbstractWitness<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, PrometheusNodeWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = PrometheusNodeWitnessConfigSchema\n protected _registry = new Registry()\n protected server?: Server\n\n get registry(): Registry {\n return this._registry\n }\n\n protected override async observeHandler(_payloads?: Partial<Payload>[]): Promise<Payload[]> {\n return await this.generateMetricValues()\n }\n\n protected override async startHandler() {\n collectDefaultMetrics({ register: this._registry })\n if (this.config.port) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.server = createServer(async (_request, response) => {\n response.writeHead(200)\n\n response.end(await this._registry.metrics())\n })\n this.server.listen(this.config.port)\n }\n return await super.startHandler()\n }\n\n protected override async stopHandler(): Promise<boolean> {\n this.server?.close()\n return await super.stopHandler()\n }\n\n private async generateMetricValues(): Promise<PrometheusMetricValuePayload[]> {\n return compact(\n (await this._registry.getMetricsAsJSON()).map((metric) => {\n const values = metric.values\n if (values) {\n return { aggregator: metric.aggregator, name: metric.name, schema: PrometheusMetricValueSchema, type: metric.type, values }\n }\n }),\n )\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Schema.ts","../../src/Witness.ts"],"sourcesContent":["export * from './Payload'\nexport { PrometheusNodePlugin as default, PrometheusNodePlugin } from './Plugin'\nexport * from './Schema'\nexport * from './Witness'\n","import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { PrometheusMetricValueSchema } from './Schema'\nimport { PrometheusNodeWitness } from './Witness'\n\nexport const PrometheusNodePlugin = () =>\n createPayloadSetWitnessPlugin<PrometheusNodeWitness>(\n { required: { [PrometheusMetricValueSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await PrometheusNodeWitness.create(params)\n return result\n },\n },\n )\n","export type PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\nexport const PrometheusMetricValueSchema: PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\n","import { createServer, Server } from 'node:http'\n\nimport { compact } from '@xylabs/lodash'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { AnyConfigSchema, creatableModule } from '@xyo-network/module-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\nimport { WitnessConfig, WitnessParams } from '@xyo-network/witness-model'\nimport { collectDefaultMetrics, Registry } from 'prom-client'\n\nimport { PrometheusMetricValuePayload } from './Payload'\nimport { PrometheusMetricValueSchema } from './Schema'\n\nexport type PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\nexport const PrometheusNodeWitnessConfigSchema: PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\n\nexport type PrometheusNodeWitnessConfig = WitnessConfig<{\n port?: number\n schema: PrometheusNodeWitnessConfigSchema\n}>\n\nexport type PrometheusNodeWitnessParams = WitnessParams<AnyConfigSchema<PrometheusNodeWitnessConfig>>\n\ncreatableModule()\nexport class PrometheusNodeWitness<TParams extends PrometheusNodeWitnessParams = PrometheusNodeWitnessParams> extends AbstractWitness<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, PrometheusNodeWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = PrometheusNodeWitnessConfigSchema\n protected _registry = new Registry()\n protected server?: Server\n\n get registry(): Registry {\n return this._registry\n }\n\n protected override async observeHandler(_payloads?: Partial<Payload>[]): Promise<Payload[]> {\n return await this.generateMetricValues()\n }\n\n protected override async startHandler() {\n collectDefaultMetrics({ register: this._registry })\n if (this.config.port) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.server = createServer(async (_request, response) => {\n response.writeHead(200)\n\n response.end(await this._registry.metrics())\n })\n this.server.listen(this.config.port)\n }\n return await super.startHandler()\n }\n\n protected override async stopHandler(): Promise<boolean> {\n this.server?.close()\n return await super.stopHandler()\n }\n\n private async generateMetricValues(): Promise<PrometheusMetricValuePayload[]> {\n return compact(\n (await this._registry.getMetricsAsJSON()).map((metric) => {\n const values = metric.values\n if (values) {\n return { aggregator: metric.aggregator, name: metric.name, schema: PrometheusMetricValueSchema, type: metric.type, values }\n }\n }),\n )\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,EAAA,yBAAAC,EAAA,0BAAAC,EAAA,sCAAAC,EAAA,YAAAF,IAAA,eAAAG,EAAAN,GCAA,IAAAO,EAAiC,sCACjCC,EAA8C,0CCAvC,IAAMC,EAA2D,sCCDxE,IAAAC,EAAqC,gBAErCC,EAAwB,0BACxBC,EAAgC,yCAChCC,EAAiD,qCAGjDC,EAAgD,uBAMzC,IAAMC,EAAuE,gDASpF,mBAAgB,EACT,IAAMC,EAAN,cAA+G,iBAAyB,CAC7I,OAAyB,cAA0B,CAAC,GAAG,MAAM,cAAeD,CAAiC,EAC7G,OAAyB,oBAA8BA,EAC7C,UAAY,IAAI,WAChB,OAEV,IAAI,UAAqB,CACvB,OAAO,KAAK,SACd,CAEA,MAAyB,eAAeE,EAAoD,CAC1F,OAAO,MAAM,KAAK,qBAAqB,CACzC,CAEA,MAAyB,cAAe,CACtC,kCAAsB,CAAE,SAAU,KAAK,SAAU,CAAC,EAC9C,KAAK,OAAO,OAEd,KAAK,UAAS,gBAAa,MAAOC,EAAUC,IAAa,CACvDA,EAAS,UAAU,GAAG,EAEtBA,EAAS,IAAI,MAAM,KAAK,UAAU,QAAQ,CAAC,CAC7C,CAAC,EACD,KAAK,OAAO,OAAO,KAAK,OAAO,IAAI,GAE9B,MAAM,MAAM,aAAa,CAClC,CAEA,MAAyB,aAAgC,CACvD,YAAK,QAAQ,MAAM,EACZ,MAAM,MAAM,YAAY,CACjC,CAEA,MAAc,sBAAgE,CAC5E,SAAO,YACJ,MAAM,KAAK,UAAU,iBAAiB,GAAG,IAAKC,GAAW,CACxD,IAAMC,EAASD,EAAO,OACtB,GAAIC,EACF,MAAO,CAAE,WAAYD,EAAO,WAAY,KAAMA,EAAO,KAAM,OAAQE,EAA6B,KAAMF,EAAO,KAAM,OAAAC,CAAO,CAE9H,CAAC,CACH,CACF,CACF,EF5DO,IAAME,EAAuB,OAClC,iCACE,CAAE,SAAU,CAAE,CAACC,CAA2B,EAAG,CAAE,EAAG,OAAQ,kBAAiB,EAC3E,CACE,QAAS,MAAOC,GACC,MAAMC,EAAsB,OAAOD,CAAM,CAG5D,CACF","names":["src_exports","__export","PrometheusMetricValueSchema","PrometheusNodePlugin","PrometheusNodeWitness","PrometheusNodeWitnessConfigSchema","__toCommonJS","import_payload_model","import_payloadset_plugin","PrometheusMetricValueSchema","import_node_http","import_lodash","import_abstract_witness","import_module_model","import_prom_client","PrometheusNodeWitnessConfigSchema","PrometheusNodeWitness","_payloads","_request","response","metric","values","PrometheusMetricValueSchema","PrometheusNodePlugin","PrometheusMetricValueSchema","params","PrometheusNodeWitness"]}
|
package/dist/neutral/index.js
CHANGED
|
@@ -1,71 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
3
|
-
import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
|
|
4
|
-
|
|
5
|
-
// src/Schema.ts
|
|
6
|
-
var PrometheusMetricValueSchema = "network.xyo.prometheus.metric.value";
|
|
7
|
-
|
|
8
|
-
// src/Witness.ts
|
|
9
|
-
import { createServer } from "node:http";
|
|
10
|
-
import { compact } from "@xylabs/lodash";
|
|
11
|
-
import { AbstractWitness } from "@xyo-network/abstract-witness";
|
|
12
|
-
import { creatableModule } from "@xyo-network/module-model";
|
|
13
|
-
import { collectDefaultMetrics, Registry } from "prom-client";
|
|
14
|
-
var PrometheusNodeWitnessConfigSchema = "network.xyo.prometheus.node.witness.config";
|
|
15
|
-
creatableModule();
|
|
16
|
-
var PrometheusNodeWitness = class extends AbstractWitness {
|
|
17
|
-
static configSchemas = [...super.configSchemas, PrometheusNodeWitnessConfigSchema];
|
|
18
|
-
static defaultConfigSchema = PrometheusNodeWitnessConfigSchema;
|
|
19
|
-
_registry = new Registry();
|
|
20
|
-
server;
|
|
21
|
-
get registry() {
|
|
22
|
-
return this._registry;
|
|
23
|
-
}
|
|
24
|
-
async observeHandler(_payloads) {
|
|
25
|
-
return await this.generateMetricValues();
|
|
26
|
-
}
|
|
27
|
-
async startHandler() {
|
|
28
|
-
collectDefaultMetrics({ register: this._registry });
|
|
29
|
-
if (this.config.port) {
|
|
30
|
-
this.server = createServer(async (_request, response) => {
|
|
31
|
-
response.writeHead(200);
|
|
32
|
-
response.end(await this._registry.metrics());
|
|
33
|
-
});
|
|
34
|
-
this.server.listen(this.config.port);
|
|
35
|
-
}
|
|
36
|
-
return await super.startHandler();
|
|
37
|
-
}
|
|
38
|
-
async stopHandler() {
|
|
39
|
-
this.server?.close();
|
|
40
|
-
return await super.stopHandler();
|
|
41
|
-
}
|
|
42
|
-
async generateMetricValues() {
|
|
43
|
-
return compact(
|
|
44
|
-
(await this._registry.getMetricsAsJSON()).map((metric) => {
|
|
45
|
-
const values = metric.values;
|
|
46
|
-
if (values) {
|
|
47
|
-
return { aggregator: metric.aggregator, name: metric.name, schema: PrometheusMetricValueSchema, type: metric.type, values };
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// src/Plugin.ts
|
|
55
|
-
var PrometheusNodePlugin = () => createPayloadSetWitnessPlugin(
|
|
56
|
-
{ required: { [PrometheusMetricValueSchema]: 1 }, schema: PayloadSetSchema },
|
|
57
|
-
{
|
|
58
|
-
witness: async (params) => {
|
|
59
|
-
const result = await PrometheusNodeWitness.create(params);
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
export {
|
|
65
|
-
PrometheusMetricValueSchema,
|
|
66
|
-
PrometheusNodePlugin,
|
|
67
|
-
PrometheusNodeWitness,
|
|
68
|
-
PrometheusNodeWitnessConfigSchema,
|
|
69
|
-
PrometheusNodePlugin as default
|
|
70
|
-
};
|
|
1
|
+
import{PayloadSetSchema as d}from"@xyo-network/payload-model";import{createPayloadSetWitnessPlugin as l}from"@xyo-network/payloadset-plugin";var t="network.xyo.prometheus.metric.value";import{createServer as m}from"node:http";import{compact as n}from"@xylabs/lodash";import{AbstractWitness as c}from"@xyo-network/abstract-witness";import{creatableModule as u}from"@xyo-network/module-model";import{collectDefaultMetrics as h,Registry as p}from"prom-client";var a="network.xyo.prometheus.node.witness.config";u();var o=class extends c{static configSchemas=[...super.configSchemas,a];static defaultConfigSchema=a;_registry=new p;server;get registry(){return this._registry}async observeHandler(e){return await this.generateMetricValues()}async startHandler(){return h({register:this._registry}),this.config.port&&(this.server=m(async(e,r)=>{r.writeHead(200),r.end(await this._registry.metrics())}),this.server.listen(this.config.port)),await super.startHandler()}async stopHandler(){return this.server?.close(),await super.stopHandler()}async generateMetricValues(){return n((await this._registry.getMetricsAsJSON()).map(e=>{let r=e.values;if(r)return{aggregator:e.aggregator,name:e.name,schema:t,type:e.type,values:r}}))}};var i=()=>l({required:{[t]:1},schema:d},{witness:async s=>await o.create(s)});export{t as PrometheusMetricValueSchema,i as PrometheusNodePlugin,o as PrometheusNodeWitness,a as PrometheusNodeWitnessConfigSchema,i as default};
|
|
71
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Plugin.ts","../../src/Schema.ts","../../src/Witness.ts"],"sourcesContent":["import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { PrometheusMetricValueSchema } from './Schema'\nimport { PrometheusNodeWitness } from './Witness'\n\nexport const PrometheusNodePlugin = () =>\n createPayloadSetWitnessPlugin<PrometheusNodeWitness>(\n { required: { [PrometheusMetricValueSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await PrometheusNodeWitness.create(params)\n return result\n },\n },\n )\n","export type PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\nexport const PrometheusMetricValueSchema: PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\n","import { createServer, Server } from 'node:http'\n\nimport { compact } from '@xylabs/lodash'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { AnyConfigSchema, creatableModule } from '@xyo-network/module-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\nimport { WitnessConfig, WitnessParams } from '@xyo-network/witness-model'\nimport { collectDefaultMetrics, Registry } from 'prom-client'\n\nimport { PrometheusMetricValuePayload } from './Payload'\nimport { PrometheusMetricValueSchema } from './Schema'\n\nexport type PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\nexport const PrometheusNodeWitnessConfigSchema: PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\n\nexport type PrometheusNodeWitnessConfig = WitnessConfig<{\n port?: number\n schema: PrometheusNodeWitnessConfigSchema\n}>\n\nexport type PrometheusNodeWitnessParams = WitnessParams<AnyConfigSchema<PrometheusNodeWitnessConfig>>\n\ncreatableModule()\nexport class PrometheusNodeWitness<TParams extends PrometheusNodeWitnessParams = PrometheusNodeWitnessParams> extends AbstractWitness<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, PrometheusNodeWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = PrometheusNodeWitnessConfigSchema\n protected _registry = new Registry()\n protected server?: Server\n\n get registry(): Registry {\n return this._registry\n }\n\n protected override async observeHandler(_payloads?: Partial<Payload>[]): Promise<Payload[]> {\n return await this.generateMetricValues()\n }\n\n protected override async startHandler() {\n collectDefaultMetrics({ register: this._registry })\n if (this.config.port) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.server = createServer(async (_request, response) => {\n response.writeHead(200)\n\n response.end(await this._registry.metrics())\n })\n this.server.listen(this.config.port)\n }\n return await super.startHandler()\n }\n\n protected override async stopHandler(): Promise<boolean> {\n this.server?.close()\n return await super.stopHandler()\n }\n\n private async generateMetricValues(): Promise<PrometheusMetricValuePayload[]> {\n return compact(\n (await this._registry.getMetricsAsJSON()).map((metric) => {\n const values = metric.values\n if (values) {\n return { aggregator: metric.aggregator, name: metric.name, schema: PrometheusMetricValueSchema, type: metric.type, values }\n }\n }),\n )\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/Plugin.ts","../../src/Schema.ts","../../src/Witness.ts"],"sourcesContent":["import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { PrometheusMetricValueSchema } from './Schema'\nimport { PrometheusNodeWitness } from './Witness'\n\nexport const PrometheusNodePlugin = () =>\n createPayloadSetWitnessPlugin<PrometheusNodeWitness>(\n { required: { [PrometheusMetricValueSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await PrometheusNodeWitness.create(params)\n return result\n },\n },\n )\n","export type PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\nexport const PrometheusMetricValueSchema: PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\n","import { createServer, Server } from 'node:http'\n\nimport { compact } from '@xylabs/lodash'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { AnyConfigSchema, creatableModule } from '@xyo-network/module-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\nimport { WitnessConfig, WitnessParams } from '@xyo-network/witness-model'\nimport { collectDefaultMetrics, Registry } from 'prom-client'\n\nimport { PrometheusMetricValuePayload } from './Payload'\nimport { PrometheusMetricValueSchema } from './Schema'\n\nexport type PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\nexport const PrometheusNodeWitnessConfigSchema: PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\n\nexport type PrometheusNodeWitnessConfig = WitnessConfig<{\n port?: number\n schema: PrometheusNodeWitnessConfigSchema\n}>\n\nexport type PrometheusNodeWitnessParams = WitnessParams<AnyConfigSchema<PrometheusNodeWitnessConfig>>\n\ncreatableModule()\nexport class PrometheusNodeWitness<TParams extends PrometheusNodeWitnessParams = PrometheusNodeWitnessParams> extends AbstractWitness<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, PrometheusNodeWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = PrometheusNodeWitnessConfigSchema\n protected _registry = new Registry()\n protected server?: Server\n\n get registry(): Registry {\n return this._registry\n }\n\n protected override async observeHandler(_payloads?: Partial<Payload>[]): Promise<Payload[]> {\n return await this.generateMetricValues()\n }\n\n protected override async startHandler() {\n collectDefaultMetrics({ register: this._registry })\n if (this.config.port) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.server = createServer(async (_request, response) => {\n response.writeHead(200)\n\n response.end(await this._registry.metrics())\n })\n this.server.listen(this.config.port)\n }\n return await super.startHandler()\n }\n\n protected override async stopHandler(): Promise<boolean> {\n this.server?.close()\n return await super.stopHandler()\n }\n\n private async generateMetricValues(): Promise<PrometheusMetricValuePayload[]> {\n return compact(\n (await this._registry.getMetricsAsJSON()).map((metric) => {\n const values = metric.values\n if (values) {\n return { aggregator: metric.aggregator, name: metric.name, schema: PrometheusMetricValueSchema, type: metric.type, values }\n }\n }),\n )\n }\n}\n"],"mappings":"AAAA,OAAS,oBAAAA,MAAwB,6BACjC,OAAS,iCAAAC,MAAqC,iCCAvC,IAAMC,EAA2D,sCCDxE,OAAS,gBAAAC,MAA4B,YAErC,OAAS,WAAAC,MAAe,iBACxB,OAAS,mBAAAC,MAAuB,gCAChC,OAA0B,mBAAAC,MAAuB,4BAGjD,OAAS,yBAAAC,EAAuB,YAAAC,MAAgB,cAMzC,IAAMC,EAAuE,6CASpFC,EAAgB,EACT,IAAMC,EAAN,cAA+GC,CAAyB,CAC7I,OAAyB,cAA0B,CAAC,GAAG,MAAM,cAAeH,CAAiC,EAC7G,OAAyB,oBAA8BA,EAC7C,UAAY,IAAII,EAChB,OAEV,IAAI,UAAqB,CACvB,OAAO,KAAK,SACd,CAEA,MAAyB,eAAeC,EAAoD,CAC1F,OAAO,MAAM,KAAK,qBAAqB,CACzC,CAEA,MAAyB,cAAe,CACtC,OAAAC,EAAsB,CAAE,SAAU,KAAK,SAAU,CAAC,EAC9C,KAAK,OAAO,OAEd,KAAK,OAASC,EAAa,MAAOC,EAAUC,IAAa,CACvDA,EAAS,UAAU,GAAG,EAEtBA,EAAS,IAAI,MAAM,KAAK,UAAU,QAAQ,CAAC,CAC7C,CAAC,EACD,KAAK,OAAO,OAAO,KAAK,OAAO,IAAI,GAE9B,MAAM,MAAM,aAAa,CAClC,CAEA,MAAyB,aAAgC,CACvD,YAAK,QAAQ,MAAM,EACZ,MAAM,MAAM,YAAY,CACjC,CAEA,MAAc,sBAAgE,CAC5E,OAAOC,GACJ,MAAM,KAAK,UAAU,iBAAiB,GAAG,IAAKC,GAAW,CACxD,IAAMC,EAASD,EAAO,OACtB,GAAIC,EACF,MAAO,CAAE,WAAYD,EAAO,WAAY,KAAMA,EAAO,KAAM,OAAQE,EAA6B,KAAMF,EAAO,KAAM,OAAAC,CAAO,CAE9H,CAAC,CACH,CACF,CACF,EF5DO,IAAME,EAAuB,IAClCC,EACE,CAAE,SAAU,CAAE,CAACC,CAA2B,EAAG,CAAE,EAAG,OAAQC,CAAiB,EAC3E,CACE,QAAS,MAAOC,GACC,MAAMC,EAAsB,OAAOD,CAAM,CAG5D,CACF","names":["PayloadSetSchema","createPayloadSetWitnessPlugin","PrometheusMetricValueSchema","createServer","compact","AbstractWitness","creatableModule","collectDefaultMetrics","Registry","PrometheusNodeWitnessConfigSchema","creatableModule","PrometheusNodeWitness","AbstractWitness","Registry","_payloads","collectDefaultMetrics","createServer","_request","response","compact","metric","values","PrometheusMetricValueSchema","PrometheusNodePlugin","createPayloadSetWitnessPlugin","PrometheusMetricValueSchema","PayloadSetSchema","params","PrometheusNodeWitness"]}
|
package/dist/node/Plugin.d.cts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { PrometheusNodeWitness } from './Witness';
|
|
2
2
|
export declare const PrometheusNodePlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<PrometheusNodeWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
|
-
account?: import("@xyo-network/account-model").AccountInstance | "random"
|
|
4
|
-
addToResolvers?: boolean
|
|
5
|
-
additionalSigners?: import("@xyo-network/account-model").AccountInstance[]
|
|
6
|
-
allowNameResolution?: boolean
|
|
3
|
+
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
|
+
addToResolvers?: boolean;
|
|
5
|
+
additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
|
|
6
|
+
allowNameResolution?: boolean;
|
|
7
7
|
config: import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & {
|
|
8
8
|
schema: "network.xyo.prometheus.node.witness.config";
|
|
9
9
|
} & {
|
|
10
|
-
port?: number
|
|
11
|
-
schema: "
|
|
10
|
+
port?: number;
|
|
11
|
+
schema: import("./Witness").PrometheusNodeWitnessConfigSchema;
|
|
12
12
|
}, "schema"> & {
|
|
13
13
|
schema: "network.xyo.prometheus.node.witness.config";
|
|
14
14
|
}, "schema"> & {
|
|
15
15
|
schema: string;
|
|
16
16
|
};
|
|
17
|
-
ephemeralQueryAccountEnabled?: boolean
|
|
18
|
-
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[]
|
|
17
|
+
ephemeralQueryAccountEnabled?: boolean;
|
|
18
|
+
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
19
19
|
}>>;
|
|
20
20
|
//# sourceMappingURL=Plugin.d.ts.map
|
package/dist/node/Plugin.d.mts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { PrometheusNodeWitness } from './Witness';
|
|
2
2
|
export declare const PrometheusNodePlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<PrometheusNodeWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
|
-
account?: import("@xyo-network/account-model").AccountInstance | "random"
|
|
4
|
-
addToResolvers?: boolean
|
|
5
|
-
additionalSigners?: import("@xyo-network/account-model").AccountInstance[]
|
|
6
|
-
allowNameResolution?: boolean
|
|
3
|
+
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
|
+
addToResolvers?: boolean;
|
|
5
|
+
additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
|
|
6
|
+
allowNameResolution?: boolean;
|
|
7
7
|
config: import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & {
|
|
8
8
|
schema: "network.xyo.prometheus.node.witness.config";
|
|
9
9
|
} & {
|
|
10
|
-
port?: number
|
|
11
|
-
schema: "
|
|
10
|
+
port?: number;
|
|
11
|
+
schema: import("./Witness").PrometheusNodeWitnessConfigSchema;
|
|
12
12
|
}, "schema"> & {
|
|
13
13
|
schema: "network.xyo.prometheus.node.witness.config";
|
|
14
14
|
}, "schema"> & {
|
|
15
15
|
schema: string;
|
|
16
16
|
};
|
|
17
|
-
ephemeralQueryAccountEnabled?: boolean
|
|
18
|
-
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[]
|
|
17
|
+
ephemeralQueryAccountEnabled?: boolean;
|
|
18
|
+
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
19
19
|
}>>;
|
|
20
20
|
//# sourceMappingURL=Plugin.d.ts.map
|
package/dist/node/Plugin.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { PrometheusNodeWitness } from './Witness';
|
|
2
2
|
export declare const PrometheusNodePlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<PrometheusNodeWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
|
-
account?: import("@xyo-network/account-model").AccountInstance | "random"
|
|
4
|
-
addToResolvers?: boolean
|
|
5
|
-
additionalSigners?: import("@xyo-network/account-model").AccountInstance[]
|
|
6
|
-
allowNameResolution?: boolean
|
|
3
|
+
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
|
+
addToResolvers?: boolean;
|
|
5
|
+
additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
|
|
6
|
+
allowNameResolution?: boolean;
|
|
7
7
|
config: import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & {
|
|
8
8
|
schema: "network.xyo.prometheus.node.witness.config";
|
|
9
9
|
} & {
|
|
10
|
-
port?: number
|
|
11
|
-
schema: "
|
|
10
|
+
port?: number;
|
|
11
|
+
schema: import("./Witness").PrometheusNodeWitnessConfigSchema;
|
|
12
12
|
}, "schema"> & {
|
|
13
13
|
schema: "network.xyo.prometheus.node.witness.config";
|
|
14
14
|
}, "schema"> & {
|
|
15
15
|
schema: string;
|
|
16
16
|
};
|
|
17
|
-
ephemeralQueryAccountEnabled?: boolean
|
|
18
|
-
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[]
|
|
17
|
+
ephemeralQueryAccountEnabled?: boolean;
|
|
18
|
+
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
19
19
|
}>>;
|
|
20
20
|
//# sourceMappingURL=Plugin.d.ts.map
|
package/dist/node/Witness.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,WAAW,CAAA;AAGhD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAmB,MAAM,2BAA2B,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACzE,OAAO,EAAyB,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK7D,MAAM,MAAM,iCAAiC,GAAG,4CAA4C,CAAA;AAC5F,eAAO,MAAM,iCAAiC,EAAE,iCAAgF,CAAA;AAEhI,MAAM,MAAM,2BAA2B,GAAG,aAAa,CAAC;IACtD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,iCAAiC,CAAA;CAC1C,CAAC,CAAA;AAEF,MAAM,MAAM,2BAA2B,GAAG,aAAa,CAAC,eAAe,CAAC,2BAA2B,CAAC,CAAC,CAAA;AAGrG,qBAAa,qBAAqB,CAAC,OAAO,SAAS,2BAA2B,GAAG,2BAA2B,CAAE,SAAQ,eAAe,CAAC,OAAO,CAAC;IAC5I,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA8D;IAC9G,gBAAyB,mBAAmB,EAAE,MAAM,CAAoC;IACxF,SAAS,CAAC,SAAS,uDAAiB;IACpC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IAEzB,IAAI,QAAQ,IAAI,QAAQ,CAEvB;cAEwB,cAAc,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;cAIlE,YAAY;cAcZ,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;YAK1C,oBAAoB;CAUnC"}
|
package/dist/node/Witness.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,WAAW,CAAA;AAGhD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAmB,MAAM,2BAA2B,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACzE,OAAO,EAAyB,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK7D,MAAM,MAAM,iCAAiC,GAAG,4CAA4C,CAAA;AAC5F,eAAO,MAAM,iCAAiC,EAAE,iCAAgF,CAAA;AAEhI,MAAM,MAAM,2BAA2B,GAAG,aAAa,CAAC;IACtD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,iCAAiC,CAAA;CAC1C,CAAC,CAAA;AAEF,MAAM,MAAM,2BAA2B,GAAG,aAAa,CAAC,eAAe,CAAC,2BAA2B,CAAC,CAAC,CAAA;AAGrG,qBAAa,qBAAqB,CAAC,OAAO,SAAS,2BAA2B,GAAG,2BAA2B,CAAE,SAAQ,eAAe,CAAC,OAAO,CAAC;IAC5I,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA8D;IAC9G,gBAAyB,mBAAmB,EAAE,MAAM,CAAoC;IACxF,SAAS,CAAC,SAAS,uDAAiB;IACpC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IAEzB,IAAI,QAAQ,IAAI,QAAQ,CAEvB;cAEwB,cAAc,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;cAIlE,YAAY;cAcZ,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;YAK1C,oBAAoB;CAUnC"}
|
package/dist/node/Witness.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,WAAW,CAAA;AAGhD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAmB,MAAM,2BAA2B,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACzE,OAAO,EAAyB,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK7D,MAAM,MAAM,iCAAiC,GAAG,4CAA4C,CAAA;AAC5F,eAAO,MAAM,iCAAiC,EAAE,iCAAgF,CAAA;AAEhI,MAAM,MAAM,2BAA2B,GAAG,aAAa,CAAC;IACtD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,iCAAiC,CAAA;CAC1C,CAAC,CAAA;AAEF,MAAM,MAAM,2BAA2B,GAAG,aAAa,CAAC,eAAe,CAAC,2BAA2B,CAAC,CAAC,CAAA;AAGrG,qBAAa,qBAAqB,CAAC,OAAO,SAAS,2BAA2B,GAAG,2BAA2B,CAAE,SAAQ,eAAe,CAAC,OAAO,CAAC;IAC5I,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA8D;IAC9G,gBAAyB,mBAAmB,EAAE,MAAM,CAAoC;IACxF,SAAS,CAAC,SAAS,uDAAiB;IACpC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IAEzB,IAAI,QAAQ,IAAI,QAAQ,CAEvB;cAEwB,cAAc,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;cAIlE,YAAY;cAcZ,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;YAK1C,oBAAoB;CAUnC"}
|
package/dist/node/index.cjs
CHANGED
|
@@ -1,102 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
PrometheusMetricValueSchema: () => PrometheusMetricValueSchema,
|
|
24
|
-
PrometheusNodePlugin: () => PrometheusNodePlugin,
|
|
25
|
-
PrometheusNodeWitness: () => PrometheusNodeWitness,
|
|
26
|
-
PrometheusNodeWitnessConfigSchema: () => PrometheusNodeWitnessConfigSchema,
|
|
27
|
-
default: () => PrometheusNodePlugin
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(src_exports);
|
|
30
|
-
|
|
31
|
-
// src/Plugin.ts
|
|
32
|
-
var import_payload_model = require("@xyo-network/payload-model");
|
|
33
|
-
var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
|
|
34
|
-
|
|
35
|
-
// src/Schema.ts
|
|
36
|
-
var PrometheusMetricValueSchema = "network.xyo.prometheus.metric.value";
|
|
37
|
-
|
|
38
|
-
// src/Witness.ts
|
|
39
|
-
var import_node_http = require("http");
|
|
40
|
-
var import_lodash = require("@xylabs/lodash");
|
|
41
|
-
var import_abstract_witness = require("@xyo-network/abstract-witness");
|
|
42
|
-
var import_module_model = require("@xyo-network/module-model");
|
|
43
|
-
var import_prom_client = require("prom-client");
|
|
44
|
-
var PrometheusNodeWitnessConfigSchema = "network.xyo.prometheus.node.witness.config";
|
|
45
|
-
(0, import_module_model.creatableModule)();
|
|
46
|
-
var PrometheusNodeWitness = class extends import_abstract_witness.AbstractWitness {
|
|
47
|
-
static configSchemas = [...super.configSchemas, PrometheusNodeWitnessConfigSchema];
|
|
48
|
-
static defaultConfigSchema = PrometheusNodeWitnessConfigSchema;
|
|
49
|
-
_registry = new import_prom_client.Registry();
|
|
50
|
-
server;
|
|
51
|
-
get registry() {
|
|
52
|
-
return this._registry;
|
|
53
|
-
}
|
|
54
|
-
async observeHandler(_payloads) {
|
|
55
|
-
return await this.generateMetricValues();
|
|
56
|
-
}
|
|
57
|
-
async startHandler() {
|
|
58
|
-
(0, import_prom_client.collectDefaultMetrics)({ register: this._registry });
|
|
59
|
-
if (this.config.port) {
|
|
60
|
-
this.server = (0, import_node_http.createServer)(async (_request, response) => {
|
|
61
|
-
response.writeHead(200);
|
|
62
|
-
response.end(await this._registry.metrics());
|
|
63
|
-
});
|
|
64
|
-
this.server.listen(this.config.port);
|
|
65
|
-
}
|
|
66
|
-
return await super.startHandler();
|
|
67
|
-
}
|
|
68
|
-
async stopHandler() {
|
|
69
|
-
var _a;
|
|
70
|
-
(_a = this.server) == null ? void 0 : _a.close();
|
|
71
|
-
return await super.stopHandler();
|
|
72
|
-
}
|
|
73
|
-
async generateMetricValues() {
|
|
74
|
-
return (0, import_lodash.compact)(
|
|
75
|
-
(await this._registry.getMetricsAsJSON()).map((metric) => {
|
|
76
|
-
const values = metric.values;
|
|
77
|
-
if (values) {
|
|
78
|
-
return { aggregator: metric.aggregator, name: metric.name, schema: PrometheusMetricValueSchema, type: metric.type, values };
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// src/Plugin.ts
|
|
86
|
-
var PrometheusNodePlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)(
|
|
87
|
-
{ required: { [PrometheusMetricValueSchema]: 1 }, schema: import_payload_model.PayloadSetSchema },
|
|
88
|
-
{
|
|
89
|
-
witness: async (params) => {
|
|
90
|
-
const result = await PrometheusNodeWitness.create(params);
|
|
91
|
-
return result;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
);
|
|
95
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
-
0 && (module.exports = {
|
|
97
|
-
PrometheusMetricValueSchema,
|
|
98
|
-
PrometheusNodePlugin,
|
|
99
|
-
PrometheusNodeWitness,
|
|
100
|
-
PrometheusNodeWitnessConfigSchema
|
|
101
|
-
});
|
|
1
|
+
"use strict";var m=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var v=(r,e)=>{for(var t in e)m(r,t,{get:e[t],enumerable:!0})},x=(r,e,t,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of y(e))!S.call(r,o)&&o!==t&&m(r,o,{get:()=>e[o],enumerable:!(u=f(e,o))||u.enumerable});return r};var W=r=>x(m({},"__esModule",{value:!0}),r);var w={};v(w,{PrometheusMetricValueSchema:()=>s,PrometheusNodePlugin:()=>c,PrometheusNodeWitness:()=>a,PrometheusNodeWitnessConfigSchema:()=>n,default:()=>c});module.exports=W(w);var P=require("@xyo-network/payload-model"),g=require("@xyo-network/payloadset-plugin");var s="network.xyo.prometheus.metric.value";var h=require("http"),p=require("@xylabs/lodash"),d=require("@xyo-network/abstract-witness"),l=require("@xyo-network/module-model"),i=require("prom-client");var n="network.xyo.prometheus.node.witness.config";(0,l.creatableModule)();var a=class extends d.AbstractWitness{static configSchemas=[...super.configSchemas,n];static defaultConfigSchema=n;_registry=new i.Registry;server;get registry(){return this._registry}async observeHandler(e){return await this.generateMetricValues()}async startHandler(){return(0,i.collectDefaultMetrics)({register:this._registry}),this.config.port&&(this.server=(0,h.createServer)(async(e,t)=>{t.writeHead(200),t.end(await this._registry.metrics())}),this.server.listen(this.config.port)),await super.startHandler()}async stopHandler(){var e;return(e=this.server)==null||e.close(),await super.stopHandler()}async generateMetricValues(){return(0,p.compact)((await this._registry.getMetricsAsJSON()).map(e=>{let t=e.values;if(t)return{aggregator:e.aggregator,name:e.name,schema:s,type:e.type,values:t}}))}};var c=()=>(0,g.createPayloadSetWitnessPlugin)({required:{[s]:1},schema:P.PayloadSetSchema},{witness:async r=>await a.create(r)});0&&(module.exports={PrometheusMetricValueSchema,PrometheusNodePlugin,PrometheusNodeWitness,PrometheusNodeWitnessConfigSchema});
|
|
102
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Schema.ts","../../src/Witness.ts"],"sourcesContent":["export * from './Payload'\nexport { PrometheusNodePlugin as default, PrometheusNodePlugin } from './Plugin'\nexport * from './Schema'\nexport * from './Witness'\n","import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { PrometheusMetricValueSchema } from './Schema'\nimport { PrometheusNodeWitness } from './Witness'\n\nexport const PrometheusNodePlugin = () =>\n createPayloadSetWitnessPlugin<PrometheusNodeWitness>(\n { required: { [PrometheusMetricValueSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await PrometheusNodeWitness.create(params)\n return result\n },\n },\n )\n","export type PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\nexport const PrometheusMetricValueSchema: PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\n","import { createServer, Server } from 'node:http'\n\nimport { compact } from '@xylabs/lodash'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { AnyConfigSchema, creatableModule } from '@xyo-network/module-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\nimport { WitnessConfig, WitnessParams } from '@xyo-network/witness-model'\nimport { collectDefaultMetrics, Registry } from 'prom-client'\n\nimport { PrometheusMetricValuePayload } from './Payload'\nimport { PrometheusMetricValueSchema } from './Schema'\n\nexport type PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\nexport const PrometheusNodeWitnessConfigSchema: PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\n\nexport type PrometheusNodeWitnessConfig = WitnessConfig<{\n port?: number\n schema: PrometheusNodeWitnessConfigSchema\n}>\n\nexport type PrometheusNodeWitnessParams = WitnessParams<AnyConfigSchema<PrometheusNodeWitnessConfig>>\n\ncreatableModule()\nexport class PrometheusNodeWitness<TParams extends PrometheusNodeWitnessParams = PrometheusNodeWitnessParams> extends AbstractWitness<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, PrometheusNodeWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = PrometheusNodeWitnessConfigSchema\n protected _registry = new Registry()\n protected server?: Server\n\n get registry(): Registry {\n return this._registry\n }\n\n protected override async observeHandler(_payloads?: Partial<Payload>[]): Promise<Payload[]> {\n return await this.generateMetricValues()\n }\n\n protected override async startHandler() {\n collectDefaultMetrics({ register: this._registry })\n if (this.config.port) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.server = createServer(async (_request, response) => {\n response.writeHead(200)\n\n response.end(await this._registry.metrics())\n })\n this.server.listen(this.config.port)\n }\n return await super.startHandler()\n }\n\n protected override async stopHandler(): Promise<boolean> {\n this.server?.close()\n return await super.stopHandler()\n }\n\n private async generateMetricValues(): Promise<PrometheusMetricValuePayload[]> {\n return compact(\n (await this._registry.getMetricsAsJSON()).map((metric) => {\n const values = metric.values\n if (values) {\n return { aggregator: metric.aggregator, name: metric.name, schema: PrometheusMetricValueSchema, type: metric.type, values }\n }\n }),\n )\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Schema.ts","../../src/Witness.ts"],"sourcesContent":["export * from './Payload'\nexport { PrometheusNodePlugin as default, PrometheusNodePlugin } from './Plugin'\nexport * from './Schema'\nexport * from './Witness'\n","import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { PrometheusMetricValueSchema } from './Schema'\nimport { PrometheusNodeWitness } from './Witness'\n\nexport const PrometheusNodePlugin = () =>\n createPayloadSetWitnessPlugin<PrometheusNodeWitness>(\n { required: { [PrometheusMetricValueSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await PrometheusNodeWitness.create(params)\n return result\n },\n },\n )\n","export type PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\nexport const PrometheusMetricValueSchema: PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\n","import { createServer, Server } from 'node:http'\n\nimport { compact } from '@xylabs/lodash'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { AnyConfigSchema, creatableModule } from '@xyo-network/module-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\nimport { WitnessConfig, WitnessParams } from '@xyo-network/witness-model'\nimport { collectDefaultMetrics, Registry } from 'prom-client'\n\nimport { PrometheusMetricValuePayload } from './Payload'\nimport { PrometheusMetricValueSchema } from './Schema'\n\nexport type PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\nexport const PrometheusNodeWitnessConfigSchema: PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\n\nexport type PrometheusNodeWitnessConfig = WitnessConfig<{\n port?: number\n schema: PrometheusNodeWitnessConfigSchema\n}>\n\nexport type PrometheusNodeWitnessParams = WitnessParams<AnyConfigSchema<PrometheusNodeWitnessConfig>>\n\ncreatableModule()\nexport class PrometheusNodeWitness<TParams extends PrometheusNodeWitnessParams = PrometheusNodeWitnessParams> extends AbstractWitness<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, PrometheusNodeWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = PrometheusNodeWitnessConfigSchema\n protected _registry = new Registry()\n protected server?: Server\n\n get registry(): Registry {\n return this._registry\n }\n\n protected override async observeHandler(_payloads?: Partial<Payload>[]): Promise<Payload[]> {\n return await this.generateMetricValues()\n }\n\n protected override async startHandler() {\n collectDefaultMetrics({ register: this._registry })\n if (this.config.port) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.server = createServer(async (_request, response) => {\n response.writeHead(200)\n\n response.end(await this._registry.metrics())\n })\n this.server.listen(this.config.port)\n }\n return await super.startHandler()\n }\n\n protected override async stopHandler(): Promise<boolean> {\n this.server?.close()\n return await super.stopHandler()\n }\n\n private async generateMetricValues(): Promise<PrometheusMetricValuePayload[]> {\n return compact(\n (await this._registry.getMetricsAsJSON()).map((metric) => {\n const values = metric.values\n if (values) {\n return { aggregator: metric.aggregator, name: metric.name, schema: PrometheusMetricValueSchema, type: metric.type, values }\n }\n }),\n )\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,EAAA,yBAAAC,EAAA,0BAAAC,EAAA,sCAAAC,EAAA,YAAAF,IAAA,eAAAG,EAAAN,GCAA,IAAAO,EAAiC,sCACjCC,EAA8C,0CCAvC,IAAMC,EAA2D,sCCDxE,IAAAC,EAAqC,gBAErCC,EAAwB,0BACxBC,EAAgC,yCAChCC,EAAiD,qCAGjDC,EAAgD,uBAMzC,IAAMC,EAAuE,gDASpF,mBAAgB,EACT,IAAMC,EAAN,cAA+G,iBAAyB,CAC7I,OAAyB,cAA0B,CAAC,GAAG,MAAM,cAAeD,CAAiC,EAC7G,OAAyB,oBAA8BA,EAC7C,UAAY,IAAI,WAChB,OAEV,IAAI,UAAqB,CACvB,OAAO,KAAK,SACd,CAEA,MAAyB,eAAeE,EAAoD,CAC1F,OAAO,MAAM,KAAK,qBAAqB,CACzC,CAEA,MAAyB,cAAe,CACtC,kCAAsB,CAAE,SAAU,KAAK,SAAU,CAAC,EAC9C,KAAK,OAAO,OAEd,KAAK,UAAS,gBAAa,MAAOC,EAAUC,IAAa,CACvDA,EAAS,UAAU,GAAG,EAEtBA,EAAS,IAAI,MAAM,KAAK,UAAU,QAAQ,CAAC,CAC7C,CAAC,EACD,KAAK,OAAO,OAAO,KAAK,OAAO,IAAI,GAE9B,MAAM,MAAM,aAAa,CAClC,CAEA,MAAyB,aAAgC,CAnD3D,IAAAC,EAoDI,OAAAA,EAAA,KAAK,SAAL,MAAAA,EAAa,QACN,MAAM,MAAM,YAAY,CACjC,CAEA,MAAc,sBAAgE,CAC5E,SAAO,YACJ,MAAM,KAAK,UAAU,iBAAiB,GAAG,IAAKC,GAAW,CACxD,IAAMC,EAASD,EAAO,OACtB,GAAIC,EACF,MAAO,CAAE,WAAYD,EAAO,WAAY,KAAMA,EAAO,KAAM,OAAQE,EAA6B,KAAMF,EAAO,KAAM,OAAAC,CAAO,CAE9H,CAAC,CACH,CACF,CACF,EF5DO,IAAME,EAAuB,OAClC,iCACE,CAAE,SAAU,CAAE,CAACC,CAA2B,EAAG,CAAE,EAAG,OAAQ,kBAAiB,EAC3E,CACE,QAAS,MAAOC,GACC,MAAMC,EAAsB,OAAOD,CAAM,CAG5D,CACF","names":["src_exports","__export","PrometheusMetricValueSchema","PrometheusNodePlugin","PrometheusNodeWitness","PrometheusNodeWitnessConfigSchema","__toCommonJS","import_payload_model","import_payloadset_plugin","PrometheusMetricValueSchema","import_node_http","import_lodash","import_abstract_witness","import_module_model","import_prom_client","PrometheusNodeWitnessConfigSchema","PrometheusNodeWitness","_payloads","_request","response","_a","metric","values","PrometheusMetricValueSchema","PrometheusNodePlugin","PrometheusMetricValueSchema","params","PrometheusNodeWitness"]}
|
package/dist/node/index.js
CHANGED
|
@@ -1,72 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
3
|
-
import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
|
|
4
|
-
|
|
5
|
-
// src/Schema.ts
|
|
6
|
-
var PrometheusMetricValueSchema = "network.xyo.prometheus.metric.value";
|
|
7
|
-
|
|
8
|
-
// src/Witness.ts
|
|
9
|
-
import { createServer } from "node:http";
|
|
10
|
-
import { compact } from "@xylabs/lodash";
|
|
11
|
-
import { AbstractWitness } from "@xyo-network/abstract-witness";
|
|
12
|
-
import { creatableModule } from "@xyo-network/module-model";
|
|
13
|
-
import { collectDefaultMetrics, Registry } from "prom-client";
|
|
14
|
-
var PrometheusNodeWitnessConfigSchema = "network.xyo.prometheus.node.witness.config";
|
|
15
|
-
creatableModule();
|
|
16
|
-
var PrometheusNodeWitness = class extends AbstractWitness {
|
|
17
|
-
static configSchemas = [...super.configSchemas, PrometheusNodeWitnessConfigSchema];
|
|
18
|
-
static defaultConfigSchema = PrometheusNodeWitnessConfigSchema;
|
|
19
|
-
_registry = new Registry();
|
|
20
|
-
server;
|
|
21
|
-
get registry() {
|
|
22
|
-
return this._registry;
|
|
23
|
-
}
|
|
24
|
-
async observeHandler(_payloads) {
|
|
25
|
-
return await this.generateMetricValues();
|
|
26
|
-
}
|
|
27
|
-
async startHandler() {
|
|
28
|
-
collectDefaultMetrics({ register: this._registry });
|
|
29
|
-
if (this.config.port) {
|
|
30
|
-
this.server = createServer(async (_request, response) => {
|
|
31
|
-
response.writeHead(200);
|
|
32
|
-
response.end(await this._registry.metrics());
|
|
33
|
-
});
|
|
34
|
-
this.server.listen(this.config.port);
|
|
35
|
-
}
|
|
36
|
-
return await super.startHandler();
|
|
37
|
-
}
|
|
38
|
-
async stopHandler() {
|
|
39
|
-
var _a;
|
|
40
|
-
(_a = this.server) == null ? void 0 : _a.close();
|
|
41
|
-
return await super.stopHandler();
|
|
42
|
-
}
|
|
43
|
-
async generateMetricValues() {
|
|
44
|
-
return compact(
|
|
45
|
-
(await this._registry.getMetricsAsJSON()).map((metric) => {
|
|
46
|
-
const values = metric.values;
|
|
47
|
-
if (values) {
|
|
48
|
-
return { aggregator: metric.aggregator, name: metric.name, schema: PrometheusMetricValueSchema, type: metric.type, values };
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// src/Plugin.ts
|
|
56
|
-
var PrometheusNodePlugin = () => createPayloadSetWitnessPlugin(
|
|
57
|
-
{ required: { [PrometheusMetricValueSchema]: 1 }, schema: PayloadSetSchema },
|
|
58
|
-
{
|
|
59
|
-
witness: async (params) => {
|
|
60
|
-
const result = await PrometheusNodeWitness.create(params);
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
export {
|
|
66
|
-
PrometheusMetricValueSchema,
|
|
67
|
-
PrometheusNodePlugin,
|
|
68
|
-
PrometheusNodeWitness,
|
|
69
|
-
PrometheusNodeWitnessConfigSchema,
|
|
70
|
-
PrometheusNodePlugin as default
|
|
71
|
-
};
|
|
1
|
+
import{PayloadSetSchema as d}from"@xyo-network/payload-model";import{createPayloadSetWitnessPlugin as l}from"@xyo-network/payloadset-plugin";var t="network.xyo.prometheus.metric.value";import{createServer as m}from"node:http";import{compact as n}from"@xylabs/lodash";import{AbstractWitness as c}from"@xyo-network/abstract-witness";import{creatableModule as u}from"@xyo-network/module-model";import{collectDefaultMetrics as h,Registry as p}from"prom-client";var a="network.xyo.prometheus.node.witness.config";u();var o=class extends c{static configSchemas=[...super.configSchemas,a];static defaultConfigSchema=a;_registry=new p;server;get registry(){return this._registry}async observeHandler(e){return await this.generateMetricValues()}async startHandler(){return h({register:this._registry}),this.config.port&&(this.server=m(async(e,r)=>{r.writeHead(200),r.end(await this._registry.metrics())}),this.server.listen(this.config.port)),await super.startHandler()}async stopHandler(){var e;return(e=this.server)==null||e.close(),await super.stopHandler()}async generateMetricValues(){return n((await this._registry.getMetricsAsJSON()).map(e=>{let r=e.values;if(r)return{aggregator:e.aggregator,name:e.name,schema:t,type:e.type,values:r}}))}};var i=()=>l({required:{[t]:1},schema:d},{witness:async s=>await o.create(s)});export{t as PrometheusMetricValueSchema,i as PrometheusNodePlugin,o as PrometheusNodeWitness,a as PrometheusNodeWitnessConfigSchema,i as default};
|
|
72
2
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Plugin.ts","../../src/Schema.ts","../../src/Witness.ts"],"sourcesContent":["import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { PrometheusMetricValueSchema } from './Schema'\nimport { PrometheusNodeWitness } from './Witness'\n\nexport const PrometheusNodePlugin = () =>\n createPayloadSetWitnessPlugin<PrometheusNodeWitness>(\n { required: { [PrometheusMetricValueSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await PrometheusNodeWitness.create(params)\n return result\n },\n },\n )\n","export type PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\nexport const PrometheusMetricValueSchema: PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\n","import { createServer, Server } from 'node:http'\n\nimport { compact } from '@xylabs/lodash'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { AnyConfigSchema, creatableModule } from '@xyo-network/module-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\nimport { WitnessConfig, WitnessParams } from '@xyo-network/witness-model'\nimport { collectDefaultMetrics, Registry } from 'prom-client'\n\nimport { PrometheusMetricValuePayload } from './Payload'\nimport { PrometheusMetricValueSchema } from './Schema'\n\nexport type PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\nexport const PrometheusNodeWitnessConfigSchema: PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\n\nexport type PrometheusNodeWitnessConfig = WitnessConfig<{\n port?: number\n schema: PrometheusNodeWitnessConfigSchema\n}>\n\nexport type PrometheusNodeWitnessParams = WitnessParams<AnyConfigSchema<PrometheusNodeWitnessConfig>>\n\ncreatableModule()\nexport class PrometheusNodeWitness<TParams extends PrometheusNodeWitnessParams = PrometheusNodeWitnessParams> extends AbstractWitness<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, PrometheusNodeWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = PrometheusNodeWitnessConfigSchema\n protected _registry = new Registry()\n protected server?: Server\n\n get registry(): Registry {\n return this._registry\n }\n\n protected override async observeHandler(_payloads?: Partial<Payload>[]): Promise<Payload[]> {\n return await this.generateMetricValues()\n }\n\n protected override async startHandler() {\n collectDefaultMetrics({ register: this._registry })\n if (this.config.port) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.server = createServer(async (_request, response) => {\n response.writeHead(200)\n\n response.end(await this._registry.metrics())\n })\n this.server.listen(this.config.port)\n }\n return await super.startHandler()\n }\n\n protected override async stopHandler(): Promise<boolean> {\n this.server?.close()\n return await super.stopHandler()\n }\n\n private async generateMetricValues(): Promise<PrometheusMetricValuePayload[]> {\n return compact(\n (await this._registry.getMetricsAsJSON()).map((metric) => {\n const values = metric.values\n if (values) {\n return { aggregator: metric.aggregator, name: metric.name, schema: PrometheusMetricValueSchema, type: metric.type, values }\n }\n }),\n )\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/Plugin.ts","../../src/Schema.ts","../../src/Witness.ts"],"sourcesContent":["import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { PrometheusMetricValueSchema } from './Schema'\nimport { PrometheusNodeWitness } from './Witness'\n\nexport const PrometheusNodePlugin = () =>\n createPayloadSetWitnessPlugin<PrometheusNodeWitness>(\n { required: { [PrometheusMetricValueSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await PrometheusNodeWitness.create(params)\n return result\n },\n },\n )\n","export type PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\nexport const PrometheusMetricValueSchema: PrometheusMetricValueSchema = 'network.xyo.prometheus.metric.value'\n","import { createServer, Server } from 'node:http'\n\nimport { compact } from '@xylabs/lodash'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { AnyConfigSchema, creatableModule } from '@xyo-network/module-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\nimport { WitnessConfig, WitnessParams } from '@xyo-network/witness-model'\nimport { collectDefaultMetrics, Registry } from 'prom-client'\n\nimport { PrometheusMetricValuePayload } from './Payload'\nimport { PrometheusMetricValueSchema } from './Schema'\n\nexport type PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\nexport const PrometheusNodeWitnessConfigSchema: PrometheusNodeWitnessConfigSchema = 'network.xyo.prometheus.node.witness.config'\n\nexport type PrometheusNodeWitnessConfig = WitnessConfig<{\n port?: number\n schema: PrometheusNodeWitnessConfigSchema\n}>\n\nexport type PrometheusNodeWitnessParams = WitnessParams<AnyConfigSchema<PrometheusNodeWitnessConfig>>\n\ncreatableModule()\nexport class PrometheusNodeWitness<TParams extends PrometheusNodeWitnessParams = PrometheusNodeWitnessParams> extends AbstractWitness<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, PrometheusNodeWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = PrometheusNodeWitnessConfigSchema\n protected _registry = new Registry()\n protected server?: Server\n\n get registry(): Registry {\n return this._registry\n }\n\n protected override async observeHandler(_payloads?: Partial<Payload>[]): Promise<Payload[]> {\n return await this.generateMetricValues()\n }\n\n protected override async startHandler() {\n collectDefaultMetrics({ register: this._registry })\n if (this.config.port) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.server = createServer(async (_request, response) => {\n response.writeHead(200)\n\n response.end(await this._registry.metrics())\n })\n this.server.listen(this.config.port)\n }\n return await super.startHandler()\n }\n\n protected override async stopHandler(): Promise<boolean> {\n this.server?.close()\n return await super.stopHandler()\n }\n\n private async generateMetricValues(): Promise<PrometheusMetricValuePayload[]> {\n return compact(\n (await this._registry.getMetricsAsJSON()).map((metric) => {\n const values = metric.values\n if (values) {\n return { aggregator: metric.aggregator, name: metric.name, schema: PrometheusMetricValueSchema, type: metric.type, values }\n }\n }),\n )\n }\n}\n"],"mappings":"AAAA,OAAS,oBAAAA,MAAwB,6BACjC,OAAS,iCAAAC,MAAqC,iCCAvC,IAAMC,EAA2D,sCCDxE,OAAS,gBAAAC,MAA4B,YAErC,OAAS,WAAAC,MAAe,iBACxB,OAAS,mBAAAC,MAAuB,gCAChC,OAA0B,mBAAAC,MAAuB,4BAGjD,OAAS,yBAAAC,EAAuB,YAAAC,MAAgB,cAMzC,IAAMC,EAAuE,6CASpFC,EAAgB,EACT,IAAMC,EAAN,cAA+GC,CAAyB,CAC7I,OAAyB,cAA0B,CAAC,GAAG,MAAM,cAAeH,CAAiC,EAC7G,OAAyB,oBAA8BA,EAC7C,UAAY,IAAII,EAChB,OAEV,IAAI,UAAqB,CACvB,OAAO,KAAK,SACd,CAEA,MAAyB,eAAeC,EAAoD,CAC1F,OAAO,MAAM,KAAK,qBAAqB,CACzC,CAEA,MAAyB,cAAe,CACtC,OAAAC,EAAsB,CAAE,SAAU,KAAK,SAAU,CAAC,EAC9C,KAAK,OAAO,OAEd,KAAK,OAASC,EAAa,MAAOC,EAAUC,IAAa,CACvDA,EAAS,UAAU,GAAG,EAEtBA,EAAS,IAAI,MAAM,KAAK,UAAU,QAAQ,CAAC,CAC7C,CAAC,EACD,KAAK,OAAO,OAAO,KAAK,OAAO,IAAI,GAE9B,MAAM,MAAM,aAAa,CAClC,CAEA,MAAyB,aAAgC,CAnD3D,IAAAC,EAoDI,OAAAA,EAAA,KAAK,SAAL,MAAAA,EAAa,QACN,MAAM,MAAM,YAAY,CACjC,CAEA,MAAc,sBAAgE,CAC5E,OAAOC,GACJ,MAAM,KAAK,UAAU,iBAAiB,GAAG,IAAKC,GAAW,CACxD,IAAMC,EAASD,EAAO,OACtB,GAAIC,EACF,MAAO,CAAE,WAAYD,EAAO,WAAY,KAAMA,EAAO,KAAM,OAAQE,EAA6B,KAAMF,EAAO,KAAM,OAAAC,CAAO,CAE9H,CAAC,CACH,CACF,CACF,EF5DO,IAAME,EAAuB,IAClCC,EACE,CAAE,SAAU,CAAE,CAACC,CAA2B,EAAG,CAAE,EAAG,OAAQC,CAAiB,EAC3E,CACE,QAAS,MAAOC,GACC,MAAMC,EAAsB,OAAOD,CAAM,CAG5D,CACF","names":["PayloadSetSchema","createPayloadSetWitnessPlugin","PrometheusMetricValueSchema","createServer","compact","AbstractWitness","creatableModule","collectDefaultMetrics","Registry","PrometheusNodeWitnessConfigSchema","creatableModule","PrometheusNodeWitness","AbstractWitness","Registry","_payloads","collectDefaultMetrics","createServer","_request","response","_a","compact","metric","values","PrometheusMetricValueSchema","PrometheusNodePlugin","createPayloadSetWitnessPlugin","PrometheusMetricValueSchema","PayloadSetSchema","params","PrometheusNodeWitness"]}
|
package/package.json
CHANGED
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"prom-client": "^15.1.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@xylabs/ts-scripts-yarn3": "^3.11.
|
|
23
|
-
"@xylabs/tsconfig": "^3.11.
|
|
22
|
+
"@xylabs/ts-scripts-yarn3": "^3.11.7",
|
|
23
|
+
"@xylabs/tsconfig": "^3.11.7",
|
|
24
24
|
"@xyo-network/account": "^2.106.0",
|
|
25
25
|
"@xyo-network/payload-wrapper": "^2.106.0",
|
|
26
|
-
"typescript": "^5.
|
|
26
|
+
"typescript": "^5.5.2"
|
|
27
27
|
},
|
|
28
28
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
29
29
|
"exports": {
|
|
@@ -54,6 +54,6 @@
|
|
|
54
54
|
"url": "https://github.com/XYOracleNetwork/plugins.git"
|
|
55
55
|
},
|
|
56
56
|
"sideEffects": false,
|
|
57
|
-
"version": "2.96.
|
|
57
|
+
"version": "2.96.2",
|
|
58
58
|
"type": "module"
|
|
59
59
|
}
|