@platformatic/basic 2.71.0-alpha.1 → 2.71.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/lib/base.js CHANGED
@@ -446,6 +446,66 @@ export class BaseStackable extends EventEmitter {
446
446
  globalThis.platformatic.onHttpCacheMiss = () => {
447
447
  cacheMissMetric.inc()
448
448
  }
449
+
450
+ const httpStatsFreeMetric = new client.Gauge({
451
+ name: 'http_client_stats_free',
452
+ help: 'Number of free (idle) http clients (sockets)',
453
+ labelNames: ['dispatcher_stats_url'],
454
+ registers: [registry]
455
+ })
456
+ globalThis.platformatic.onHttpStatsFree = (url, val) => {
457
+ httpStatsFreeMetric.set({ dispatcher_stats_url: url }, val)
458
+ }
459
+
460
+ const httpStatsConnectedMetric = new client.Gauge({
461
+ name: 'http_client_stats_connected',
462
+ help: 'Number of open socket connections',
463
+ labelNames: ['dispatcher_stats_url'],
464
+ registers: [registry]
465
+ })
466
+ globalThis.platformatic.onHttpStatsConnected = (url, val) => {
467
+ httpStatsConnectedMetric.set({ dispatcher_stats_url: url }, val)
468
+ }
469
+
470
+ const httpStatsPendingMetric = new client.Gauge({
471
+ name: 'http_client_stats_pending',
472
+ help: 'Number of pending requests across all clients',
473
+ labelNames: ['dispatcher_stats_url'],
474
+ registers: [registry]
475
+ })
476
+ globalThis.platformatic.onHttpStatsPending = (url, val) => {
477
+ httpStatsPendingMetric.set({ dispatcher_stats_url: url }, val)
478
+ }
479
+
480
+ const httpStatsQueuedMetric = new client.Gauge({
481
+ name: 'http_client_stats_queued',
482
+ help: 'Number of queued requests across all clients',
483
+ labelNames: ['dispatcher_stats_url'],
484
+ registers: [registry]
485
+ })
486
+ globalThis.platformatic.onHttpStatsQueued = (url, val) => {
487
+ httpStatsQueuedMetric.set({ dispatcher_stats_url: url }, val)
488
+ }
489
+
490
+ const httpStatsRunningMetric = new client.Gauge({
491
+ name: 'http_client_stats_running',
492
+ help: 'Number of currently active requests across all clients',
493
+ labelNames: ['dispatcher_stats_url'],
494
+ registers: [registry]
495
+ })
496
+ globalThis.platformatic.onHttpStatsRunning = (url, val) => {
497
+ httpStatsRunningMetric.set({ dispatcher_stats_url: url }, val)
498
+ }
499
+
500
+ const httpStatsSizeMetric = new client.Gauge({
501
+ name: 'http_client_stats_size',
502
+ help: 'Number of active, pending, or queued requests across all clients',
503
+ labelNames: ['dispatcher_stats_url'],
504
+ registers: [registry]
505
+ })
506
+ globalThis.platformatic.onHttpStatsSize = (url, val) => {
507
+ httpStatsSizeMetric.set({ dispatcher_stats_url: url }, val)
508
+ }
449
509
  }
450
510
 
451
511
  async #invalidateHttpCache (opts = {}) {
@@ -162,7 +162,7 @@ export class ChildManager extends ITC {
162
162
  const childProcessInclude = `--import="${new URL('./child-process.js', import.meta.url)}"`
163
163
 
164
164
  let telemetryInclude = ''
165
- if (this.#context.telemetryConfig) {
165
+ if (this.#context.telemetryConfig && this.#context.telemetryConfig.enabled !== false) {
166
166
  const require = createRequire(import.meta.url)
167
167
  const telemetryPath = require.resolve('@platformatic/telemetry')
168
168
  const openTelemetrySetupPath = join(telemetryPath, '..', 'lib', 'node-telemetry.js')
@@ -223,6 +223,66 @@ export class ChildProcess extends ITC {
223
223
  globalThis.platformatic.onHttpCacheMiss = () => {
224
224
  cacheMissMetric.inc()
225
225
  }
226
+
227
+ const httpStatsFreeMetric = new client.Gauge({
228
+ name: 'http_client_stats_free',
229
+ help: 'Number of free (idle) http clients (sockets)',
230
+ labelNames: ['dispatcher_stats_url'],
231
+ registers: [registry]
232
+ })
233
+ globalThis.platformatic.onHttpStatsFree = (url, val) => {
234
+ httpStatsFreeMetric.set({ dispatcher_stats_url: url }, val)
235
+ }
236
+
237
+ const httpStatsConnectedMetric = new client.Gauge({
238
+ name: 'http_client_stats_connected',
239
+ help: 'Number of open socket connections',
240
+ labelNames: ['dispatcher_stats_url'],
241
+ registers: [registry]
242
+ })
243
+ globalThis.platformatic.onHttpStatsConnected = (url, val) => {
244
+ httpStatsConnectedMetric.set({ dispatcher_stats_url: url }, val)
245
+ }
246
+
247
+ const httpStatsPendingMetric = new client.Gauge({
248
+ name: 'http_client_stats_pending',
249
+ help: 'Number of pending requests across all clients',
250
+ labelNames: ['dispatcher_stats_url'],
251
+ registers: [registry]
252
+ })
253
+ globalThis.platformatic.onHttpStatsPending = (url, val) => {
254
+ httpStatsPendingMetric.set({ dispatcher_stats_url: url }, val)
255
+ }
256
+
257
+ const httpStatsQueuedMetric = new client.Gauge({
258
+ name: 'http_client_stats_queued',
259
+ help: 'Number of queued requests across all clients',
260
+ labelNames: ['dispatcher_stats_url'],
261
+ registers: [registry]
262
+ })
263
+ globalThis.platformatic.onHttpStatsQueued = (url, val) => {
264
+ httpStatsQueuedMetric.set({ dispatcher_stats_url: url }, val)
265
+ }
266
+
267
+ const httpStatsRunningMetric = new client.Gauge({
268
+ name: 'http_client_stats_running',
269
+ help: 'Number of currently active requests across all clients',
270
+ labelNames: ['dispatcher_stats_url'],
271
+ registers: [registry]
272
+ })
273
+ globalThis.platformatic.onHttpStatsRunning = (url, val) => {
274
+ httpStatsRunningMetric.set({ dispatcher_stats_url: url }, val)
275
+ }
276
+
277
+ const httpStatsSizeMetric = new client.Gauge({
278
+ name: 'http_client_stats_size',
279
+ help: 'Number of active, pending, or queued requests across all clients',
280
+ labelNames: ['dispatcher_stats_url'],
281
+ registers: [registry]
282
+ })
283
+ globalThis.platformatic.onHttpStatsSize = (url, val) => {
284
+ httpStatsSizeMetric.set({ dispatcher_stats_url: url }, val)
285
+ }
226
286
  }
227
287
 
228
288
  async #getMetrics ({ format } = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/basic",
3
- "version": "2.71.0-alpha.1",
3
+ "version": "2.71.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,11 +24,11 @@
24
24
  "split2": "^4.2.0",
25
25
  "undici": "^7.0.0",
26
26
  "ws": "^8.18.0",
27
- "@platformatic/itc": "2.71.0-alpha.1",
28
- "@platformatic/metrics": "2.71.0-alpha.1",
29
- "@platformatic/telemetry": "2.71.0-alpha.1",
30
- "@platformatic/utils": "2.71.0-alpha.1",
31
- "@platformatic/config": "2.71.0-alpha.1"
27
+ "@platformatic/config": "2.71.0",
28
+ "@platformatic/itc": "2.71.0",
29
+ "@platformatic/metrics": "2.71.0",
30
+ "@platformatic/telemetry": "2.71.0",
31
+ "@platformatic/utils": "2.71.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "borp": "^0.20.0",
@@ -37,7 +37,7 @@
37
37
  "fastify": "^5.0.0",
38
38
  "get-port": "^7.1.0",
39
39
  "json-schema-to-typescript": "^15.0.0",
40
- "minimatch": "^10.0.1",
40
+ "minimatch": "^10.0.3",
41
41
  "neostandard": "^0.12.0",
42
42
  "typescript": "^5.5.4"
43
43
  },
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/basic/2.71.0-alpha.1.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/basic/2.71.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Stackable",
5
5
  "type": "object",