@voltro/plugin-prometheus 0.32.0 → 0.34.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/CHANGELOG.md +2006 -0
- package/THIRD-PARTY-NOTICES.md +1 -29
- package/dist/index.js +36 -33
- package/package.json +6 -5
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -5,7 +5,7 @@ property of its respective copyright holders and is used under the terms of
|
|
|
5
5
|
its license. This file is provided for attribution; it grants no rights in
|
|
6
6
|
@voltro/plugin-prometheus itself, which is proprietary (see LICENSE).
|
|
7
7
|
|
|
8
|
-
Generated from the resolved runtime dependency closure (
|
|
8
|
+
Generated from the resolved runtime dependency closure (51 packages).
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -37,34 +37,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
37
37
|
SOFTWARE.
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
## @effect/opentelemetry@0.64.0
|
|
41
|
-
|
|
42
|
-
License: MIT
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
MIT License
|
|
46
|
-
|
|
47
|
-
Copyright (c) 2020-present The Contributors
|
|
48
|
-
|
|
49
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
50
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
51
|
-
in the Software without restriction, including without limitation the rights
|
|
52
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
53
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
54
|
-
furnished to do so, subject to the following conditions:
|
|
55
|
-
|
|
56
|
-
The above copyright notice and this permission notice shall be included in all
|
|
57
|
-
copies or substantial portions of the Software.
|
|
58
|
-
|
|
59
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
60
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
61
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
62
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
63
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
64
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
65
|
-
SOFTWARE.
|
|
66
|
-
```
|
|
67
|
-
|
|
68
40
|
## @effect/platform-node@0.108.0
|
|
69
41
|
|
|
70
42
|
License: MIT
|
package/dist/index.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { Effect as e } from "effect";
|
|
2
|
-
import { definePlugin as t } from "@voltro/protocol";
|
|
3
|
-
import { checkBearer as
|
|
4
|
-
import { snapshotMetrics as
|
|
5
|
-
import { pluginEnv as
|
|
2
|
+
import { definePlugin as t, pluginInstanceName as n } from "@voltro/protocol";
|
|
3
|
+
import { checkBearer as r } from "@voltro/protocol/session";
|
|
4
|
+
import { snapshotMetrics as i } from "@voltro/runtime";
|
|
5
|
+
import { pluginEnv as a } from "@voltro/env";
|
|
6
6
|
//#region src/format.ts
|
|
7
|
-
var
|
|
7
|
+
var o = (e) => e.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/"/g, "\\\""), s = (e, t) => {
|
|
8
8
|
let n = {
|
|
9
9
|
...e,
|
|
10
10
|
...t
|
|
11
11
|
}, r = Object.keys(n);
|
|
12
|
-
return r.length === 0 ? "" : "{" + r.map((e) => `${e}="${
|
|
13
|
-
},
|
|
12
|
+
return r.length === 0 ? "" : "{" + r.map((e) => `${e}="${o(String(n[e]))}"`).join(",") + "}";
|
|
13
|
+
}, c = (e) => Number.isFinite(e) ? String(e) : e > 0 ? "+Inf" : "-Inf", l = {
|
|
14
14
|
counter: "counter",
|
|
15
15
|
gauge: "gauge",
|
|
16
16
|
histogram: "histogram",
|
|
17
17
|
summary: "summary",
|
|
18
18
|
frequency: "gauge"
|
|
19
|
-
},
|
|
19
|
+
}, u = (e, t) => {
|
|
20
20
|
switch (e.type) {
|
|
21
21
|
case "counter":
|
|
22
22
|
case "gauge":
|
|
23
|
-
t.push(`${e.name}${
|
|
23
|
+
t.push(`${e.name}${s(e.labels)} ${c(e.value ?? 0)}`);
|
|
24
24
|
break;
|
|
25
25
|
case "histogram":
|
|
26
|
-
for (let n of e.buckets ?? []) t.push(`${e.name}_bucket${
|
|
27
|
-
t.push(`${e.name}_bucket${
|
|
26
|
+
for (let n of e.buckets ?? []) t.push(`${e.name}_bucket${s(e.labels, { le: c(n.le) })} ${c(n.count)}`);
|
|
27
|
+
t.push(`${e.name}_bucket${s(e.labels, { le: "+Inf" })} ${c(e.count ?? 0)}`), t.push(`${e.name}_sum${s(e.labels)} ${c(e.sum ?? 0)}`), t.push(`${e.name}_count${s(e.labels)} ${c(e.count ?? 0)}`);
|
|
28
28
|
break;
|
|
29
29
|
case "summary":
|
|
30
|
-
for (let n of e.quantiles ?? []) t.push(`${e.name}${
|
|
31
|
-
t.push(`${e.name}_sum${
|
|
30
|
+
for (let n of e.quantiles ?? []) t.push(`${e.name}${s(e.labels, { quantile: c(n.quantile) })} ${c(n.value)}`);
|
|
31
|
+
t.push(`${e.name}_sum${s(e.labels)} ${c(e.sum ?? 0)}`), t.push(`${e.name}_count${s(e.labels)} ${c(e.count ?? 0)}`);
|
|
32
32
|
break;
|
|
33
33
|
case "frequency":
|
|
34
|
-
for (let [n, r] of Object.entries(e.occurrences ?? {})) t.push(`${e.name}${
|
|
34
|
+
for (let [n, r] of Object.entries(e.occurrences ?? {})) t.push(`${e.name}${s(e.labels, { bucket: n })} ${c(r)}`);
|
|
35
35
|
break;
|
|
36
36
|
}
|
|
37
|
-
},
|
|
37
|
+
}, d = (e) => {
|
|
38
38
|
let t = /* @__PURE__ */ new Map();
|
|
39
39
|
for (let n of e) {
|
|
40
40
|
let e = t.get(n.name);
|
|
@@ -43,11 +43,11 @@ var a = (e) => e.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/"/g, "\\\
|
|
|
43
43
|
let n = [];
|
|
44
44
|
for (let [e, r] of t) {
|
|
45
45
|
let t = r[0], i = t.description ?? e;
|
|
46
|
-
n.push(`# HELP ${e} ${i.replace(/\\/g, "\\\\").replace(/\n/g, " ")}`), n.push(`# TYPE ${e} ${
|
|
47
|
-
for (let e of r)
|
|
46
|
+
n.push(`# HELP ${e} ${i.replace(/\\/g, "\\\\").replace(/\n/g, " ")}`), n.push(`# TYPE ${e} ${l[t.type]}`);
|
|
47
|
+
for (let e of r) u(e, n);
|
|
48
48
|
}
|
|
49
49
|
return n.join("\n") + "\n";
|
|
50
|
-
},
|
|
50
|
+
}, f = (e) => {
|
|
51
51
|
let t = process.memoryUsage(), n = process.cpuUsage(), r = [
|
|
52
52
|
{
|
|
53
53
|
name: "process_resident_memory_bytes",
|
|
@@ -78,44 +78,47 @@ var a = (e) => e.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/"/g, "\\\
|
|
|
78
78
|
value: 1,
|
|
79
79
|
description: "Voltro build info (constant 1, version in the label)."
|
|
80
80
|
}), r;
|
|
81
|
-
},
|
|
81
|
+
}, p = "text/plain; version=0.0.4; charset=utf-8", m = a([{
|
|
82
82
|
name: "PROMETHEUS_TOKEN",
|
|
83
83
|
required: !1,
|
|
84
84
|
secret: !0,
|
|
85
85
|
description: "Bearer token required on the scrape endpoint; unset leaves /metrics open."
|
|
86
|
-
}]),
|
|
87
|
-
let
|
|
86
|
+
}]), h = (a = {}) => {
|
|
87
|
+
let o = a.path ?? "/metrics", s = m.read("PROMETHEUS_TOKEN", a.token), c = a.processMetrics ?? !0, l = {
|
|
88
88
|
method: "GET",
|
|
89
|
-
path:
|
|
89
|
+
path: o,
|
|
90
90
|
handle: async (t) => {
|
|
91
|
-
if (!
|
|
91
|
+
if (!r(t.headers, s, { openWhenUnset: !0 })) return {
|
|
92
92
|
status: 401,
|
|
93
93
|
body: "unauthorized",
|
|
94
94
|
contentType: "text/plain"
|
|
95
95
|
};
|
|
96
|
-
let
|
|
96
|
+
let n = await e.runPromise(i);
|
|
97
97
|
return {
|
|
98
98
|
status: 200,
|
|
99
|
-
body:
|
|
100
|
-
contentType:
|
|
99
|
+
body: d(c ? [...n, ...f(a.version)] : n),
|
|
100
|
+
contentType: p,
|
|
101
101
|
headers: { "cache-control": "no-store" }
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
return t({
|
|
106
|
-
name:
|
|
106
|
+
name: n({
|
|
107
|
+
base: "@voltro/plugin-prometheus",
|
|
108
|
+
instance: a.name
|
|
109
|
+
}),
|
|
107
110
|
description: "Prometheus exporter — scrapes the unified Metrics-API at a /metrics endpoint in text exposition format.",
|
|
108
|
-
declaredEnv:
|
|
109
|
-
httpRoutes: [
|
|
111
|
+
declaredEnv: m.declared,
|
|
112
|
+
httpRoutes: [l],
|
|
110
113
|
onActivate: (t) => e.sync(() => {
|
|
111
114
|
t.logger.info("prometheus exporter active", {
|
|
112
|
-
path:
|
|
113
|
-
tokenGated: !!
|
|
114
|
-
processMetrics:
|
|
115
|
+
path: o,
|
|
116
|
+
tokenGated: !!s,
|
|
117
|
+
processMetrics: c
|
|
115
118
|
});
|
|
116
119
|
}),
|
|
117
120
|
onDeactivate: () => e.void
|
|
118
121
|
});
|
|
119
122
|
};
|
|
120
123
|
//#endregion
|
|
121
|
-
export {
|
|
124
|
+
export { d as formatPrometheus, f as processMetrics, h as prometheusPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/plugin-prometheus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "Prometheus exporter — scrapes the framework's unified Metrics-API (Effect MetricRegistry) at GET /metrics in Prometheus text exposition format. Counters, histograms (with buckets), gauges + custom metrics; optional bearer-token gate + node process metrics.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
23
|
"import": "./dist/index.js",
|
|
24
24
|
"default": "./dist/index.js"
|
|
25
|
-
}
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
26
27
|
},
|
|
27
28
|
"main": "./dist/index.js",
|
|
28
29
|
"module": "./dist/index.js",
|
|
@@ -32,9 +33,9 @@
|
|
|
32
33
|
"node": ">=24.0.0"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"@voltro/env": "0.
|
|
36
|
-
"@voltro/protocol": "0.
|
|
37
|
-
"@voltro/runtime": "0.
|
|
36
|
+
"@voltro/env": "0.34.0",
|
|
37
|
+
"@voltro/protocol": "0.34.0",
|
|
38
|
+
"@voltro/runtime": "0.34.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"effect": "^3.22.0"
|