@openclaw/diagnostics-prometheus 2026.9.4 → 2026.9.6

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.
@@ -0,0 +1,40 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <!--
3
+ Source: simple-icons@16.31.0, icons/prometheus.svg
4
+ https://www.npmjs.com/package/simple-icons/v/16.31.0
5
+ https://github.com/simple-icons/simple-icons
6
+
7
+ # CC0 1.0 Universal
8
+
9
+ ## Statement of Purpose
10
+
11
+ The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an “owner”) of an original work of authorship and/or a database (each, a “Work”).
12
+
13
+ Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works (“Commons”) that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others.
14
+
15
+ For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the “Affirmer”), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights.
16
+
17
+ 1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights (“Copyright and Related Rights”). Copyright and Related Rights include, but are not limited to, the following:
18
+ 1. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work;
19
+ 2. moral rights retained by the original author(s) and/or performer(s);
20
+ 3. publicity and privacy rights pertaining to a person’s image or likeness depicted in a Work;
21
+ 4. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(i), below;
22
+ 5. rights protecting the extraction, dissemination, use and reuse of data in a Work;
23
+ 6. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and
24
+ 7. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof.
25
+
26
+ 2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer’s Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the “Waiver”). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer’s heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer’s express Statement of Purpose.
27
+
28
+ 3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer’s express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer’s Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the “License”). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer’s express Statement of Purpose.
29
+
30
+ 4. Limitations and Disclaimers.
31
+ 1. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document.
32
+ 2. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law.
33
+ 3. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person’s Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work.
34
+ 4. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work.
35
+
36
+ For more information, please see <https://creativecommons.org/publicdomain/zero/1.0>.
37
+ Names and marks remain the property of their respective owners.
38
+ -->
39
+ <path fill="currentColor" stroke="none" d="M12 0C5.373 0 0 5.372 0 12c0 6.627 5.373 12 12 12s12-5.373 12-12c0-6.628-5.373-12-12-12zm0 22.46c-1.885 0-3.414-1.26-3.414-2.814h6.828c0 1.553-1.528 2.813-3.414 2.813zm5.64-3.745H6.36v-2.046h11.28v2.046zm-.04-3.098H6.391c-.037-.043-.075-.086-.111-.13-1.155-1.401-1.427-2.133-1.69-2.879-.005-.025 1.4.287 2.395.511 0 0 .513.119 1.262.255-.72-.843-1.147-1.915-1.147-3.01 0-2.406 1.845-4.508 1.18-6.207.648.053 1.34 1.367 1.387 3.422.689-.951.977-2.69.977-3.755 0-1.103.727-2.385 1.454-2.429-.648 1.069.168 1.984.894 4.256.272.854.237 2.29.447 3.201.07-1.892.395-4.652 1.595-5.605-.529 1.2.079 2.702.494 3.424.671 1.164 1.078 2.047 1.078 3.716a4.642 4.642 0 01-1.11 2.996c.792-.149 1.34-.283 1.34-.283l2.573-.502s-.374 1.538-1.81 3.019z" />
40
+ </svg>
Binary file
package/dist/index.js CHANGED
@@ -4,72 +4,7 @@ import { isDiagnosticsEnabled, normalizeDiagnosticLane, normalizeDiagnosticValue
4
4
  import { asNonNegativeFiniteNumber } from "openclaw/plugin-sdk/number-runtime";
5
5
  import { getPluginRuntimeGatewayRequestScope } from "openclaw/plugin-sdk/plugin-runtime";
6
6
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
7
- //#region extensions/diagnostics-prometheus/src/service.ts
8
- const DURATION_BUCKETS_SECONDS = [
9
- .005,
10
- .01,
11
- .025,
12
- .05,
13
- .1,
14
- .25,
15
- .5,
16
- 1,
17
- 2.5,
18
- 5,
19
- 10,
20
- 30,
21
- 60,
22
- 120,
23
- 300,
24
- 600
25
- ];
26
- const TOKEN_BUCKETS = [
27
- 1,
28
- 4,
29
- 16,
30
- 64,
31
- 256,
32
- 1024,
33
- 4096,
34
- 16384,
35
- 65536,
36
- 262144,
37
- 1048576
38
- ];
39
- const BYTE_BUCKETS = [
40
- 1024,
41
- 4096,
42
- 16384,
43
- 65536,
44
- 262144,
45
- 1048576,
46
- 4194304,
47
- 16777216,
48
- 67108864,
49
- 268435456,
50
- 1073741824,
51
- 4294967296,
52
- 17179869184
53
- ];
54
- const RATIO_BUCKETS = [
55
- .01,
56
- .05,
57
- .1,
58
- .25,
59
- .5,
60
- .75,
61
- 1,
62
- 2,
63
- 4,
64
- 8,
65
- 16
66
- ];
67
- const MAX_PROMETHEUS_SERIES = 2048;
68
- const DROPPED_SERIES_COUNTER_NAME = "openclaw_prometheus_series_dropped_total";
69
- function seconds(ms) {
70
- const value = asNonNegativeFiniteNumber(ms);
71
- return value === void 0 ? void 0 : value / 1e3;
72
- }
7
+ //#region extensions/diagnostics-prometheus/src/prometheus-format.ts
73
8
  function sortedLabels(labels) {
74
9
  const entries = Object.entries(labels);
75
10
  entries.sort(([left], [right]) => left.localeCompare(right));
@@ -96,6 +31,28 @@ function formatPrometheusNumber(value) {
96
31
  if (!Number.isFinite(value)) return "0";
97
32
  return Number.isInteger(value) ? String(value) : String(Number(value.toPrecision(12)));
98
33
  }
34
+ //#endregion
35
+ //#region extensions/diagnostics-prometheus/src/prometheus-metric-store.ts
36
+ const DURATION_BUCKETS_SECONDS = [
37
+ .005,
38
+ .01,
39
+ .025,
40
+ .05,
41
+ .1,
42
+ .25,
43
+ .5,
44
+ 1,
45
+ 2.5,
46
+ 5,
47
+ 10,
48
+ 30,
49
+ 60,
50
+ 120,
51
+ 300,
52
+ 600
53
+ ];
54
+ const MAX_PROMETHEUS_SERIES = 2048;
55
+ const DROPPED_SERIES_COUNTER_NAME = "openclaw_prometheus_series_dropped_total";
99
56
  function createPrometheusMetricStore() {
100
57
  const counters = /* @__PURE__ */ new Map();
101
58
  const gauges = /* @__PURE__ */ new Map();
@@ -132,6 +89,9 @@ function createPrometheusMetricStore() {
132
89
  value
133
90
  });
134
91
  };
92
+ const clearGauges = (name) => {
93
+ for (const key of gauges.keys()) if (key.startsWith(`${name}|`)) gauges.delete(key);
94
+ };
135
95
  const histogram = (name, help, labels, value, buckets = DURATION_BUCKETS_SECONDS) => {
136
96
  if (value === void 0 || !Number.isFinite(value) || value < 0) return;
137
97
  const key = metricKey(name, labels);
@@ -177,11 +137,59 @@ function createPrometheusMetricStore() {
177
137
  return {
178
138
  counter,
179
139
  gauge,
140
+ clearGauges,
180
141
  histogram,
181
142
  reset,
182
143
  snapshot
183
144
  };
184
145
  }
146
+ //#endregion
147
+ //#region extensions/diagnostics-prometheus/src/service.ts
148
+ const TOKEN_BUCKETS = [
149
+ 1,
150
+ 4,
151
+ 16,
152
+ 64,
153
+ 256,
154
+ 1024,
155
+ 4096,
156
+ 16384,
157
+ 65536,
158
+ 262144,
159
+ 1048576
160
+ ];
161
+ const BYTE_BUCKETS = [
162
+ 1024,
163
+ 4096,
164
+ 16384,
165
+ 65536,
166
+ 262144,
167
+ 1048576,
168
+ 4194304,
169
+ 16777216,
170
+ 67108864,
171
+ 268435456,
172
+ 1073741824,
173
+ 4294967296,
174
+ 17179869184
175
+ ];
176
+ const RATIO_BUCKETS = [
177
+ .01,
178
+ .05,
179
+ .1,
180
+ .25,
181
+ .5,
182
+ .75,
183
+ 1,
184
+ 2,
185
+ 4,
186
+ 8,
187
+ 16
188
+ ];
189
+ function seconds(ms) {
190
+ const value = asNonNegativeFiniteNumber(ms);
191
+ return value === void 0 ? void 0 : value / 1e3;
192
+ }
185
193
  function safeErrorMessage(err) {
186
194
  const message = err instanceof Error ? err.message ?? err.name : String(err);
187
195
  return truncateUtf16Safe(redactSensitiveText(message).replaceAll("\0", " ").replace(/[\r\n\t\u2028\u2029]/gu, " "), 500);
@@ -525,14 +533,30 @@ function recordDiagnosticEvent(store, evt, metadata) {
525
533
  trigger: evt.trigger
526
534
  });
527
535
  return;
528
- case "diagnostic.memory.sample":
536
+ case "diagnostic.child_process.spawn":
537
+ store.counter("openclaw_child_process_spawn_total", "Successful child launches through the shared spawn and exec owners.", { family: normalizeDiagnosticValue(evt.family) }, asNonNegativeFiniteNumber(evt.count) ?? 0);
538
+ return;
539
+ case "diagnostic.memory.sample": {
529
540
  for (const [kind, field] of [
530
541
  ["rss", "rssBytes"],
531
542
  ["heap_total", "heapTotalBytes"],
532
- ["heap_used", "heapUsedBytes"]
533
- ]) store.gauge("openclaw_memory_bytes", "Latest process memory usage by memory kind.", { kind }, evt.memory[field]);
543
+ ["heap_used", "heapUsedBytes"],
544
+ ["external", "externalBytes"],
545
+ ["array_buffers", "arrayBuffersBytes"],
546
+ ["worker_heap_total", "workerHeapTotalBytes"],
547
+ ["worker_heap_used", "workerHeapUsedBytes"]
548
+ ]) store.gauge("openclaw_memory_bytes", "Latest process memory usage by memory kind.", { kind }, asNonNegativeFiniteNumber(evt.memory[field]));
549
+ for (const [name, field] of [["openclaw_worker_count", "workerCount"], ["openclaw_worker_heap_sampled_count", "workerHeapSampledCount"]]) store.gauge(name, "Worker isolate counts.", {}, asNonNegativeFiniteNumber(evt.memory[field]));
550
+ const workerHeaps = /* @__PURE__ */ new Map();
551
+ for (const worker of evt.memory.workerHeaps ?? []) {
552
+ const heapUsed = asNonNegativeFiniteNumber(worker.heapUsed);
553
+ if (heapUsed !== void 0) workerHeaps.set(worker.script, (workerHeaps.get(worker.script) ?? 0) + heapUsed);
554
+ }
555
+ store.clearGauges("openclaw_worker_heap_used_bytes");
556
+ for (const [script, heapUsed] of workerHeaps) store.gauge("openclaw_worker_heap_used_bytes", "Latest live Worker heap usage by bounded script basename.", { script }, heapUsed);
534
557
  store.histogram("openclaw_memory_rss_bytes", "RSS memory sample distribution in bytes.", {}, asNonNegativeFiniteNumber(evt.memory.rssBytes), BYTE_BUCKETS);
535
558
  return;
559
+ }
536
560
  case "diagnostic.memory.pressure":
537
561
  store.counter("openclaw_memory_pressure_total", "Memory pressure events by level and reason.", {
538
562
  level: evt.level,
@@ -647,7 +671,7 @@ function createDiagnosticsPrometheusExporter() {
647
671
  } catch (err) {
648
672
  ctx.logger.error(`diagnostics-prometheus: event handler failed (${event.type}): ${safeErrorMessage(err)}`);
649
673
  }
650
- }, void 0, { includePrivateData: false });
674
+ }, { exclude: ["log.record"] }, { includePrivateData: false });
651
675
  internalDiagnostics = ctx.internalDiagnostics;
652
676
  reportExporterHealth({
653
677
  signal: "metrics",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "diagnostics-prometheus",
3
- "categories": ["gateway"],
3
+ "categories": ["infrastructure"],
4
4
  "name": "Diagnostics Prometheus",
5
5
  "description": "OpenClaw diagnostics Prometheus exporter for runtime metrics.",
6
6
  "activation": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/diagnostics-prometheus",
3
- "version": "2026.9.4",
3
+ "version": "2026.9.6",
4
4
  "description": "OpenClaw diagnostics Prometheus exporter for runtime metrics.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,10 +18,10 @@
18
18
  "minHostVersion": ">=2026.4.25"
19
19
  },
20
20
  "compat": {
21
- "pluginApi": ">=2026.9.4"
21
+ "pluginApi": ">=2026.9.6"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.9.4"
24
+ "openclawVersion": "2026.9.6"
25
25
  },
26
26
  "release": {
27
27
  "publishToClawHub": true,
@@ -34,10 +34,12 @@
34
34
  "files": [
35
35
  "dist/**",
36
36
  "openclaw.plugin.json",
37
- "README.md"
37
+ "README.md",
38
+ "assets/icon.png",
39
+ "assets/activity.svg"
38
40
  ],
39
41
  "peerDependencies": {
40
- "openclaw": ">=2026.9.4"
42
+ "openclaw": ">=2026.9.6"
41
43
  },
42
44
  "peerDependenciesMeta": {
43
45
  "openclaw": {