@fluojs/metrics 1.0.4 → 3.0.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.
@@ -0,0 +1,43 @@
1
+ /** Observable state for package-internal serialized scrape scheduling. */
2
+
3
+ /**
4
+ * Serializes refresh-and-render scrape work while preserving individual results.
5
+ *
6
+ * Failed work does not poison later queue entries.
7
+ */
8
+ export class SerializedScrapeQueue {
9
+ isRunning = false;
10
+ queued = 0;
11
+ tail = Promise.resolve();
12
+ get state() {
13
+ return {
14
+ isRunning: this.isRunning,
15
+ queued: this.queued
16
+ };
17
+ }
18
+ enqueue(task) {
19
+ this.queued += 1;
20
+ const scrape = this.tail.then(async () => {
21
+ this.queued -= 1;
22
+ this.isRunning = true;
23
+ try {
24
+ return await task();
25
+ } finally {
26
+ this.isRunning = false;
27
+ }
28
+ });
29
+ this.tail = scrape.then(() => undefined, () => undefined);
30
+ return scrape;
31
+ }
32
+ async drain(finalizer) {
33
+ for (;;) {
34
+ const observedTail = this.tail;
35
+ await observedTail;
36
+ if (this.tail !== observedTail) {
37
+ continue;
38
+ }
39
+ finalizer();
40
+ return;
41
+ }
42
+ }
43
+ }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "monitoring",
9
9
  "observability"
10
10
  ],
11
- "version": "1.0.4",
11
+ "version": "3.0.0",
12
12
  "private": false,
13
13
  "license": "MIT",
14
14
  "repository": {
@@ -17,7 +17,7 @@
17
17
  "directory": "packages/metrics"
18
18
  },
19
19
  "engines": {
20
- "node": ">=20.0.0"
20
+ "node": ">=24.0.0 <27"
21
21
  },
22
22
  "publishConfig": {
23
23
  "access": "public"
@@ -35,15 +35,16 @@
35
35
  "dist"
36
36
  ],
37
37
  "dependencies": {
38
- "prom-client": "^15.1.3",
39
- "@fluojs/core": "^1.0.3",
40
- "@fluojs/http": "^1.1.2",
41
- "@fluojs/di": "^1.1.0",
42
- "@fluojs/runtime": "^1.1.8"
38
+ "prom-client": "15.1.3",
39
+ "@fluojs/core": "^2.0.0",
40
+ "@fluojs/di": "^3.0.0",
41
+ "@fluojs/http": "^3.0.0",
42
+ "@fluojs/runtime": "^3.0.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "^22.0.0",
46
- "vitest": "^3.2.4"
46
+ "vitest": "^4.1.11",
47
+ "@fluojs/testing": "^3.0.0"
47
48
  },
48
49
  "scripts": {
49
50
  "prebuild": "node ../../tooling/scripts/clean-dist.mjs",