@plitzi/sdk-kernel 0.39.9 → 0.39.11

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @plitzi/sdk-kernel
2
2
 
3
+ ## 0.39.11
4
+
5
+ ### Patch Changes
6
+
7
+ - d0b5be6: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
8
+ `@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
9
+ - Updated dependencies [d0b5be6]
10
+ - @plitzi/sdk-shared@0.39.11
11
+
12
+ ## 0.39.10
13
+
14
+ ### Patch Changes
15
+
16
+ - 97d3b64: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
17
+ `@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
18
+ - Updated dependencies [97d3b64]
19
+ - @plitzi/sdk-shared@0.39.10
20
+
3
21
  ## 0.39.9
4
22
 
5
23
  ### Patch Changes
@@ -247,10 +247,24 @@ var seriesOf = (buckets, minute) => {
247
247
  lagMs: load.lagMs
248
248
  } : {},
249
249
  ...bucket && bucket.slow.length > 0 ? { runsOf: bucket.slow } : {},
250
- ...bucket && bucket.names.size > 0 ? { names: [...bucket.names.values()].sort((a, b) => b.totalMs - a.totalMs).slice(0, 8) } : {}
250
+ ...bucket && bucket.names.size > 0 ? { names: [...bucket.names.values()].sort((a, b) => b.totalMs - a.totalMs).slice(0, 8) } : {},
251
+ ...bucket && bucket.environments.size > 0 ? { environments: Object.fromEntries(bucket.environments) } : {}
251
252
  };
252
253
  });
253
254
  };
255
+ /** The minute's count for one environment, begun at nothing the first time it is named. */
256
+ var workOf = (bucket, environment) => {
257
+ const kept = bucket.environments.get(environment);
258
+ if (kept) return kept;
259
+ const work = {
260
+ runs: 0,
261
+ failed: 0,
262
+ limited: 0,
263
+ refused: 0
264
+ };
265
+ bucket.environments.set(environment, work);
266
+ return work;
267
+ };
254
268
  /** Whether a kept run is one to look at: it failed, or it reached a limit. */
255
269
  var unanswered = (run) => Number(run.failure !== void 0 || run.limit !== void 0);
256
270
  /**
@@ -340,7 +354,8 @@ var createStatsRecorder = (identity, now = Date.now) => {
340
354
  limits: /* @__PURE__ */ new Map(),
341
355
  refusals: /* @__PURE__ */ new Map(),
342
356
  slow: [],
343
- names: /* @__PURE__ */ new Map()
357
+ names: /* @__PURE__ */ new Map(),
358
+ environments: /* @__PURE__ */ new Map()
344
359
  };
345
360
  buckets.push(bucket);
346
361
  while (buckets.length > 0 && (buckets[0]?.minute ?? minute) <= minute - KEPT_MINUTES) buckets.shift();
@@ -408,15 +423,24 @@ var createStatsRecorder = (identity, now = Date.now) => {
408
423
  }
409
424
  if (end && "failed" in end) add(bucket.failures, end.failed);
410
425
  if (end && "limit" in end) add(bucket.limits, end.limit);
426
+ if (label?.environment) {
427
+ const work = workOf(bucket, label.environment);
428
+ work.runs += 1;
429
+ work.failed += Number(end !== void 0 && "failed" in end);
430
+ work.limited += Number(end !== void 0 && "limit" in end);
431
+ }
411
432
  },
412
- refuse: (reason) => {
413
- add(current().refusals, reason);
433
+ refuse: (reason, environment) => {
434
+ const bucket = current();
435
+ add(bucket.refusals, reason);
436
+ if (environment) workOf(bucket, environment).refused += 1;
414
437
  },
415
- slot: (name, of, used, { queues = false } = {}) => {
438
+ slot: (name, of, used, { queues = false, environments } = {}) => {
416
439
  slots.set(name, {
417
440
  of,
418
441
  used,
419
- queues
442
+ queues,
443
+ ...environments ? { environments } : {}
420
444
  });
421
445
  },
422
446
  snapshot: () => {
@@ -430,7 +454,8 @@ var createStatsRecorder = (identity, now = Date.now) => {
430
454
  const load = {
431
455
  slots: Object.fromEntries([...slots].map(([name, slot]) => [name, {
432
456
  used: slot.used(),
433
- of: slot.of
457
+ of: slot.of,
458
+ ...slot.environments ? { environments: slot.environments() } : {}
434
459
  }])),
435
460
  cpu,
436
461
  memory: {
@@ -1,5 +1,5 @@
1
1
  import { a as isLogged, c as serverLog, d as keepLogEvent, l as traceField, s as renderLogEvent } from "../chunks/serverLog-BWNOjPMV.mjs";
2
- import { a as bearerMatches, f as SHUTDOWN_ANNOUNCE_MS, h as shutdownOf, m as markStopping, n as statsConfigProblem, p as isStopping } from "../chunks/stage-C62Zvzw_.mjs";
2
+ import { a as bearerMatches, f as SHUTDOWN_ANNOUNCE_MS, h as shutdownOf, m as markStopping, n as statsConfigProblem, p as isStopping } from "../chunks/stage-DRzpjuxT.mjs";
3
3
  import { i as hstsFor, n as applySecurityHeaders, r as frameAncestorsOf, t as spaceDeploymentMiddleware } from "../chunks/spaceDeployment-J2IMLfij.mjs";
4
4
  import { TRACEPARENT, readTraceparent, runInTrace, spanOf, traceparentOf } from "../trace/index.mjs";
5
5
  import { a as hostable, i as createStoreHost, n as createFleetHub, o as isFleetMessage, r as createListeners, t as createFleetClient } from "../chunks/channel-b11VTzOp.mjs";
@@ -7,4 +7,4 @@ export { processMemoryLimit, sampleProcessMemory } from './memory';
7
7
  export type { MemoryReading } from './memory';
8
8
  export type { ProcessLoad } from './load';
9
9
  export type { StatsRecorder } from './recorder';
10
- export type { InstanceHealth, InstancePhase, InstanceStatus, NamedWork, PoolHealth, PoolInstance, PoolKnob, PoolOverride, PoolReport, PoolResources, PoolResourcesControl, PoolScaler, PoolSource, ProcessStats, RunEnd, RunLabel, SlowRun, StatsConfig, StatsGauge, StatsMinute, StatsThresholds, StatsWindow } from './types';
10
+ export type { EnvironmentWork, InstanceHealth, InstancePhase, InstanceStatus, NamedWork, PoolHealth, PoolInstance, PoolKnob, PoolOverride, PoolReport, PoolResources, PoolResourcesControl, PoolScaler, PoolSource, ProcessStats, RunEnd, RunLabel, SlowRun, StatsConfig, StatsGauge, StatsMinute, StatsThresholds, StatsWindow } from './types';
@@ -1,4 +1,4 @@
1
- import { _ as STATS_METRICS_PATH, c as METRICS_CONTENT_TYPE, d as processGauges, g as STATS_LOGS_PATH, i as withStopping, l as gaugesText, n as statsConfigProblem, o as createStatsRecorder, r as statsStage, s as statsRecorderFor, t as deploymentGauges, u as metricsText, v as STATS_PATH } from "../chunks/stage-C62Zvzw_.mjs";
1
+ import { _ as STATS_METRICS_PATH, c as METRICS_CONTENT_TYPE, d as processGauges, g as STATS_LOGS_PATH, i as withStopping, l as gaugesText, n as statsConfigProblem, o as createStatsRecorder, r as statsStage, s as statsRecorderFor, t as deploymentGauges, u as metricsText, v as STATS_PATH } from "../chunks/stage-DRzpjuxT.mjs";
2
2
  import { t as isRecord } from "../chunks/isRecord-jspv0BWl.mjs";
3
3
  import { availableParallelism } from "node:os";
4
4
  import { readFileSync } from "node:fs";
@@ -5,8 +5,8 @@ export type StatsRecorder = {
5
5
  * code), and — when the recorder knows — what it was.
6
6
  */
7
7
  run: (durationMs: number, end?: RunEnd, label?: RunLabel) => void;
8
- /** A request refused before it became a run. */
9
- refuse: (reason: string) => void;
8
+ /** A request refused before it became a run — and for which environment, when whoever refuses it knows. */
9
+ refuse: (reason: string, environment?: string) => void;
10
10
  /**
11
11
  * Work in flight against a size: read when the stats are, so nothing is counted twice. With `queues`, what comes past
12
12
  * the size waits its turn rather than being refused — a worker's jobs, a runner's invocations — and a full slot is a
@@ -15,6 +15,8 @@ export type StatsRecorder = {
15
15
  */
16
16
  slot: (name: string, of: number, used: () => number, options?: {
17
17
  queues?: boolean;
18
+ /** What of it each environment's is, read with `used`: what a screen narrowed to one environment shows. */
19
+ environments?: () => Record<string, number>;
18
20
  }) => void;
19
21
  snapshot: () => ProcessStats;
20
22
  };
@@ -60,6 +60,15 @@ export type RunLabel = {
60
60
  name: string;
61
61
  trigger?: string;
62
62
  runId?: string;
63
+ /** Which of the space's environments it ran for (`production`, `main`…), when whoever records it knows. */
64
+ environment?: string;
65
+ };
66
+ /** What a minute counted for one environment of the spaces: a share of the minute's own figures, never beside them. */
67
+ export type EnvironmentWork = {
68
+ runs: number;
69
+ failed: number;
70
+ limited: number;
71
+ refused: number;
63
72
  };
64
73
  /**
65
74
  * How a run ended when it did not simply answer — three things, because they ask different things of whoever reads it:
@@ -123,6 +132,11 @@ export type StatsMinute = {
123
132
  runsOf?: SlowRun[];
124
133
  /** The actions and functions that took the most of it, up to {@link MINUTE_NAMES}. */
125
134
  names?: NamedWork[];
135
+ /**
136
+ * The minute's work by the environment it was for — the runs and refusals whose recorder said one. What nobody
137
+ * named an environment for is in the minute's totals alone: these never add up to more than them.
138
+ */
139
+ environments?: Record<string, EnvironmentWork>;
126
140
  };
127
141
  /** How many of a minute's runs it keeps by name (its slowest, its failures), and how many of its names. */
128
142
  export declare const MINUTE_RUNS = 5;
@@ -137,10 +151,14 @@ export type ProcessStats = {
137
151
  at: string;
138
152
  uptimeSeconds: number;
139
153
  load: {
140
- /** Work in flight against what this process takes at once: `calls`, `renders`, `isolates`. */
154
+ /**
155
+ * Work in flight against what this process takes at once: `calls`, `renders`, `isolates` — and, where its owner
156
+ * knows, how much of it each environment's is (`environments`).
157
+ */
141
158
  slots: Record<string, {
142
159
  used: number;
143
160
  of: number;
161
+ environments?: Record<string, number>;
144
162
  }>;
145
163
  /** CPU spent over the last sample (ten seconds), as a share of one core over that time. */
146
164
  cpu: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-kernel",
3
- "version": "0.39.9",
3
+ "version": "0.39.11",
4
4
  "license": "AGPL-3.0",
5
5
  "description": "What every Plitzi server process is built on: the HTTP pipeline, health and shutdown, the host → deployment resolution, and verifying who a request is.",
6
6
  "files": [
@@ -37,7 +37,7 @@
37
37
  "build:prod": "vite build"
38
38
  },
39
39
  "dependencies": {
40
- "@plitzi/sdk-shared": "0.39.9",
40
+ "@plitzi/sdk-shared": "0.39.11",
41
41
  "jsonwebtoken": "^9.0.3",
42
42
  "undici": "^8.12.4",
43
43
  "ws": "^8.23.0"