@platformatic/runtime 2.4.0 → 3.4.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/config.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * and run json-schema-to-typescript to regenerate this file.
6
6
  */
7
7
 
8
- export type HttpsSchemasPlatformaticDevPlatformaticRuntime240Json = {
8
+ export type HttpsSchemasPlatformaticDevPlatformaticRuntime341Json = {
9
9
  [k: string]: unknown;
10
10
  } & {
11
11
  $schema?: string;
@@ -7,7 +7,15 @@ const collectHttpMetrics = require('@platformatic/http-metrics')
7
7
 
8
8
  async function collectMetrics (stackable, serviceId, opts = {}) {
9
9
  const registry = new Registry()
10
- const metricsConfig = await stackable.collectMetrics({ registry })
10
+
11
+ const httpRequestCallbacks = []
12
+ const httpResponseCallbacks = []
13
+
14
+ const metricsConfig = await stackable.collectMetrics({
15
+ registry,
16
+ startHttpTimer: options => httpRequestCallbacks.forEach(cb => cb(options)),
17
+ endHttpTimer: options => httpResponseCallbacks.forEach(cb => cb(options))
18
+ })
11
19
 
12
20
  const labels = opts.labels ?? {}
13
21
  registry.setDefaultLabels({ ...labels, serviceId })
@@ -18,37 +26,45 @@ async function collectMetrics (stackable, serviceId, opts = {}) {
18
26
  }
19
27
 
20
28
  if (metricsConfig.httpMetrics) {
21
- collectHttpMetrics(registry, {
22
- customLabels: ['telemetry_id'],
23
- getCustomLabels: (req) => {
24
- const telemetryId = req.headers['x-plt-telemetry-id'] ?? 'unknown'
25
- return { telemetry_id: telemetryId }
26
- }
27
- })
28
-
29
- // TODO: check if it's a nodejs environment
30
- // Needed for the Meraki metrics
31
- collectHttpMetrics(registry, {
32
- customLabels: ['telemetry_id'],
33
- getCustomLabels: (req) => {
34
- const telemetryId = req.headers['x-plt-telemetry-id'] ?? 'unknown'
35
- return { telemetry_id: telemetryId }
36
- },
37
- histogram: {
38
- name: 'http_request_all_duration_seconds',
39
- help: 'request duration in seconds summary for all requests',
40
- collect: function () {
41
- process.nextTick(() => this.reset())
29
+ {
30
+ const { startTimer, endTimer } = collectHttpMetrics(registry, {
31
+ customLabels: ['telemetry_id'],
32
+ getCustomLabels: (req) => {
33
+ const telemetryId = req.headers?.['x-plt-telemetry-id'] ?? 'unknown'
34
+ return { telemetry_id: telemetryId }
35
+ }
36
+ })
37
+ httpRequestCallbacks.push(startTimer)
38
+ httpResponseCallbacks.push(endTimer)
39
+ }
40
+
41
+ {
42
+ // TODO: check if it's a nodejs environment
43
+ // Needed for the Meraki metrics
44
+ const { startTimer, endTimer } = collectHttpMetrics(registry, {
45
+ customLabels: ['telemetry_id'],
46
+ getCustomLabels: (req) => {
47
+ const telemetryId = req.headers?.['x-plt-telemetry-id'] ?? 'unknown'
48
+ return { telemetry_id: telemetryId }
42
49
  },
43
- },
44
- summary: {
45
- name: 'http_request_all_summary_seconds',
46
- help: 'request duration in seconds histogram for all requests',
47
- collect: function () {
48
- process.nextTick(() => this.reset())
50
+ histogram: {
51
+ name: 'http_request_all_duration_seconds',
52
+ help: 'request duration in seconds summary for all requests',
53
+ collect: function () {
54
+ process.nextTick(() => this.reset())
55
+ },
49
56
  },
50
- },
51
- })
57
+ summary: {
58
+ name: 'http_request_all_summary_seconds',
59
+ help: 'request duration in seconds histogram for all requests',
60
+ collect: function () {
61
+ process.nextTick(() => this.reset())
62
+ },
63
+ },
64
+ })
65
+ httpRequestCallbacks.push(startTimer)
66
+ httpResponseCallbacks.push(endTimer)
67
+ }
52
68
  }
53
69
 
54
70
  return registry
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/runtime",
3
- "version": "2.4.0",
3
+ "version": "3.4.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -34,17 +34,17 @@
34
34
  "typescript": "^5.5.4",
35
35
  "undici-oidc-interceptor": "^0.5.0",
36
36
  "why-is-node-running": "^2.2.2",
37
- "@platformatic/composer": "2.4.0",
38
- "@platformatic/service": "2.4.0",
39
- "@platformatic/db": "2.4.0",
40
- "@platformatic/sql-graphql": "2.4.0",
41
- "@platformatic/sql-mapper": "2.4.0"
37
+ "@platformatic/composer": "3.4.1",
38
+ "@platformatic/db": "3.4.1",
39
+ "@platformatic/service": "3.4.1",
40
+ "@platformatic/sql-graphql": "3.4.1",
41
+ "@platformatic/sql-mapper": "3.4.1"
42
42
  },
43
43
  "dependencies": {
44
44
  "@fastify/error": "^4.0.0",
45
45
  "@fastify/websocket": "^11.0.0",
46
46
  "@hapi/topo": "^6.0.2",
47
- "@platformatic/http-metrics": "^0.1.0",
47
+ "@platformatic/http-metrics": "^0.2.0",
48
48
  "@watchable/unpromise": "^1.0.2",
49
49
  "boring-name-generator": "^1.0.3",
50
50
  "change-case-all": "^2.1.0",
@@ -66,15 +66,15 @@
66
66
  "semgrator": "^0.3.0",
67
67
  "tail-file-stream": "^0.2.0",
68
68
  "undici": "^6.9.0",
69
- "undici-thread-interceptor": "^0.6.1",
69
+ "undici-thread-interceptor": "^0.7.0",
70
70
  "ws": "^8.16.0",
71
- "@platformatic/basic": "2.4.0",
72
- "@platformatic/config": "2.4.0",
73
- "@platformatic/generators": "2.4.0",
74
- "@platformatic/telemetry": "2.4.0",
75
- "@platformatic/ts-compiler": "2.4.0",
76
- "@platformatic/itc": "2.4.0",
77
- "@platformatic/utils": "2.4.0"
71
+ "@platformatic/generators": "3.4.1",
72
+ "@platformatic/basic": "3.4.1",
73
+ "@platformatic/config": "3.4.1",
74
+ "@platformatic/itc": "3.4.1",
75
+ "@platformatic/ts-compiler": "3.4.1",
76
+ "@platformatic/telemetry": "3.4.1",
77
+ "@platformatic/utils": "3.4.1"
78
78
  },
79
79
  "scripts": {
80
80
  "test": "npm run lint && borp --concurrency=1 --timeout=180000 && tsd",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.4.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.4.1.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "type": "object",
5
5
  "properties": {