@platformatic/basic 2.26.0-alpha.1 → 2.26.1

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
@@ -341,6 +341,7 @@ export class BaseStackable {
341
341
 
342
342
  this.#metricsCollected = true
343
343
  await this.#collectMetrics()
344
+ this.#setHttpCacheMetrics()
344
345
  }
345
346
 
346
347
  async #collectMetrics () {
@@ -373,6 +374,25 @@ export class BaseStackable {
373
374
  }
374
375
  }
375
376
 
377
+ #setHttpCacheMetrics () {
378
+ const { client, registry } = globalThis.platformatic.prometheus
379
+
380
+ const cacheHitMetric = new client.Counter({
381
+ name: 'http_cache_hit_count',
382
+ help: 'Number of http cache hits',
383
+ registers: [registry]
384
+ })
385
+
386
+ const cacheMissMetric = new client.Counter({
387
+ name: 'http_cache_miss_count',
388
+ help: 'Number of http cache misses',
389
+ registers: [registry]
390
+ })
391
+
392
+ globalThis.platformatic.onHttpCacheHit = () => { cacheHitMetric.inc() }
393
+ globalThis.platformatic.onHttpCacheMiss = () => { cacheMissMetric.inc() }
394
+ }
395
+
376
396
  async getMetrics ({ format } = {}) {
377
397
  if (this.childManager && this.clientWs) {
378
398
  return this.childManager.send(this.clientWs, 'getMetrics', { format })
@@ -180,6 +180,26 @@ export class ChildProcess extends ITC {
180
180
 
181
181
  async #collectMetrics ({ serviceId, workerId, metricsConfig }) {
182
182
  await collectMetrics(serviceId, workerId, metricsConfig, this.#metricsRegistry)
183
+ this.#setHttpCacheMetrics()
184
+ }
185
+
186
+ #setHttpCacheMetrics () {
187
+ const { client, registry } = globalThis.platformatic.prometheus
188
+
189
+ const cacheHitMetric = new client.Counter({
190
+ name: 'http_cache_hit_count',
191
+ help: 'Number of http cache hits',
192
+ registers: [registry]
193
+ })
194
+
195
+ const cacheMissMetric = new client.Counter({
196
+ name: 'http_cache_miss_count',
197
+ help: 'Number of http cache misses',
198
+ registers: [registry]
199
+ })
200
+
201
+ globalThis.platformatic.onHttpCacheHit = () => { cacheHitMetric.inc() }
202
+ globalThis.platformatic.onHttpCacheMiss = () => { cacheMissMetric.inc() }
183
203
  }
184
204
 
185
205
  async #getMetrics ({ format } = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/basic",
3
- "version": "2.26.0-alpha.1",
3
+ "version": "2.26.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,11 +23,11 @@
23
23
  "split2": "^4.2.0",
24
24
  "undici": "^7.0.0",
25
25
  "ws": "^8.18.0",
26
- "@platformatic/config": "2.26.0-alpha.1",
27
- "@platformatic/metrics": "2.26.0-alpha.1",
28
- "@platformatic/telemetry": "2.26.0-alpha.1",
29
- "@platformatic/utils": "2.26.0-alpha.1",
30
- "@platformatic/itc": "2.26.0-alpha.1"
26
+ "@platformatic/config": "2.26.1",
27
+ "@platformatic/itc": "2.26.1",
28
+ "@platformatic/telemetry": "2.26.1",
29
+ "@platformatic/metrics": "2.26.1",
30
+ "@platformatic/utils": "2.26.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "borp": "^0.19.0",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/basic/2.26.0-alpha.1.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/basic/2.26.1.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Stackable",
5
5
  "type": "object",