@platformatic/telemetry 3.57.0 → 3.58.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/diag-logger.js +81 -1
- package/package.json +15 -15
package/lib/diag-logger.js
CHANGED
|
@@ -22,10 +22,90 @@ function getDiagLogLevel (logger) {
|
|
|
22
22
|
return DiagLogLevel.INFO
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
function isObjectLike (value) {
|
|
26
|
+
return value !== null && typeof value === 'object'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function serializeCustomInspectPayload (value) {
|
|
30
|
+
const customInspect = value[util.inspect.custom]
|
|
31
|
+
|
|
32
|
+
if (typeof customInspect !== 'function') {
|
|
33
|
+
return value
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
return customInspect.call(value)
|
|
38
|
+
} catch {
|
|
39
|
+
return value
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function serializeForDiag (value, seen = new WeakSet()) {
|
|
44
|
+
if (!isObjectLike(value)) {
|
|
45
|
+
return value
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (value instanceof Error) {
|
|
49
|
+
return {
|
|
50
|
+
name: value.name,
|
|
51
|
+
message: value.message,
|
|
52
|
+
stack: value.stack,
|
|
53
|
+
...Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, serializeForDiag(entry, seen)]))
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (seen.has(value)) {
|
|
58
|
+
return '[Circular]'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
seen.add(value)
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const inspected = serializeCustomInspectPayload(value)
|
|
65
|
+
if (inspected !== value) {
|
|
66
|
+
return serializeForDiag(inspected, seen)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (typeof value.toJSON === 'function') {
|
|
70
|
+
const json = value.toJSON()
|
|
71
|
+
if (json !== value) {
|
|
72
|
+
return serializeForDiag(json, seen)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (Array.isArray(value)) {
|
|
77
|
+
return value.map(entry => serializeForDiag(entry, seen))
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (value instanceof Map) {
|
|
81
|
+
return Object.fromEntries(Array.from(value.entries(), ([key, entry]) => [String(key), serializeForDiag(entry, seen)]))
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (value instanceof Set) {
|
|
85
|
+
return Array.from(value, entry => serializeForDiag(entry, seen))
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return Object.fromEntries(
|
|
89
|
+
Object.entries(value)
|
|
90
|
+
.filter(([key, entry]) => !key.startsWith('_') && typeof entry !== 'function')
|
|
91
|
+
.map(([key, entry]) => [key, serializeForDiag(entry, seen)])
|
|
92
|
+
)
|
|
93
|
+
} finally {
|
|
94
|
+
seen.delete(value)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
25
98
|
function callLogger (logger, method, fallback, args) {
|
|
26
99
|
if (typeof logger?.[method] === 'function') {
|
|
27
100
|
if (typeof args[0] === 'string') {
|
|
28
|
-
|
|
101
|
+
const [message, ...details] = args
|
|
102
|
+
if (details.length === 0) {
|
|
103
|
+
logger[method](message)
|
|
104
|
+
} else if (details.some(isObjectLike)) {
|
|
105
|
+
logger[method]({ details: details.map(detail => serializeForDiag(detail)) }, message)
|
|
106
|
+
} else {
|
|
107
|
+
logger[method](util.format(...args))
|
|
108
|
+
}
|
|
29
109
|
} else {
|
|
30
110
|
logger[method](...args)
|
|
31
111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/telemetry",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.58.0",
|
|
4
4
|
"description": "OpenTelemetry integration for Platformatic",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"license": "Apache-2.0",
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@databases/pg": "^5.5.0",
|
|
15
|
-
"@opentelemetry/instrumentation-express": "0.
|
|
16
|
-
"@opentelemetry/instrumentation-pg": "0.
|
|
15
|
+
"@opentelemetry/instrumentation-express": "0.67.0",
|
|
16
|
+
"@opentelemetry/instrumentation-pg": "0.71.0",
|
|
17
17
|
"cleaner-spec-reporter": "^0.5.0",
|
|
18
18
|
"express": "^5.1.0",
|
|
19
19
|
"fastify": "^5.7.0",
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@fastify/swagger": "^9.5.1",
|
|
26
26
|
"@opentelemetry/api": "1.9.1",
|
|
27
|
-
"@opentelemetry/core": "2.
|
|
28
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "0.
|
|
29
|
-
"@opentelemetry/exporter-trace-otlp-proto": "0.
|
|
30
|
-
"@opentelemetry/exporter-zipkin": "2.
|
|
31
|
-
"@opentelemetry/instrumentation": "0.
|
|
32
|
-
"@opentelemetry/instrumentation-http": "0.
|
|
33
|
-
"@opentelemetry/instrumentation-undici": "0.
|
|
34
|
-
"@opentelemetry/resources": "2.
|
|
35
|
-
"@opentelemetry/sdk-node": "0.
|
|
36
|
-
"@opentelemetry/sdk-trace-base": "2.
|
|
27
|
+
"@opentelemetry/core": "2.8.0",
|
|
28
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "0.219.0",
|
|
29
|
+
"@opentelemetry/exporter-trace-otlp-proto": "0.219.0",
|
|
30
|
+
"@opentelemetry/exporter-zipkin": "2.8.0",
|
|
31
|
+
"@opentelemetry/instrumentation": "0.219.0",
|
|
32
|
+
"@opentelemetry/instrumentation-http": "0.219.0",
|
|
33
|
+
"@opentelemetry/instrumentation-undici": "0.29.0",
|
|
34
|
+
"@opentelemetry/resources": "2.8.0",
|
|
35
|
+
"@opentelemetry/sdk-node": "0.219.0",
|
|
36
|
+
"@opentelemetry/sdk-trace-base": "2.8.0",
|
|
37
37
|
"@opentelemetry/semantic-conventions": "1.41.1",
|
|
38
38
|
"fast-uri": "^3.0.6",
|
|
39
39
|
"fastify-plugin": "^5.0.1",
|
|
40
|
-
"@platformatic/
|
|
41
|
-
"@platformatic/
|
|
40
|
+
"@platformatic/globals": "3.58.0",
|
|
41
|
+
"@platformatic/foundation": "3.58.0"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=22.19.0"
|