@agoric/telemetry 0.6.3-dev-47470c7.0 → 0.6.3-dev-de9b2e7.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/package.json +4 -4
- package/src/serialize-slog-obj.js +32 -4
- package/src/slog-sender-pipe.js +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/telemetry",
|
|
3
|
-
"version": "0.6.3-dev-
|
|
3
|
+
"version": "0.6.3-dev-de9b2e7.0+de9b2e7",
|
|
4
4
|
"description": "Agoric's telemetry implementation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/Agoric/agoric-sdk",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"author": "Agoric",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@agoric/internal": "0.3.3-dev-
|
|
26
|
-
"@agoric/store": "0.9.3-dev-
|
|
25
|
+
"@agoric/internal": "0.3.3-dev-de9b2e7.0+de9b2e7",
|
|
26
|
+
"@agoric/store": "0.9.3-dev-de9b2e7.0+de9b2e7",
|
|
27
27
|
"@endo/errors": "^1.2.9",
|
|
28
28
|
"@endo/init": "^1.1.8",
|
|
29
29
|
"@endo/marshal": "^1.6.3",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"typeCoverage": {
|
|
69
69
|
"atLeast": 88.87
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "de9b2e7ca244a6d131f2e4206aeee76f814382e4"
|
|
72
72
|
}
|
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
)
|
|
1
|
+
const { hasOwn } = Object;
|
|
2
|
+
|
|
3
|
+
const replacer = (_key, value) => {
|
|
4
|
+
switch (typeof value) {
|
|
5
|
+
case 'object': {
|
|
6
|
+
if (value instanceof Error) {
|
|
7
|
+
// Represent each error as a serialization-friendly
|
|
8
|
+
// { errorType, message, cause?, errors?, stack? } object
|
|
9
|
+
// (itself subject to recursive replacement, particularly in `cause` and
|
|
10
|
+
// `errors`).
|
|
11
|
+
const obj = { errorType: value.name, message: value.message };
|
|
12
|
+
if (hasOwn(value, 'cause')) obj.cause = value.cause;
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
14
|
+
// @ts-ignore TS2339 property "errors" is only on AggregateError
|
|
15
|
+
if (hasOwn(value, 'errors')) obj.errors = value.errors;
|
|
16
|
+
const stack = value.stack;
|
|
17
|
+
if (stack) obj.stack = stack;
|
|
18
|
+
return obj;
|
|
19
|
+
}
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
case 'bigint':
|
|
23
|
+
// Represent each bigint as a JSON-serializable number, accepting the
|
|
24
|
+
// possible loss of precision.
|
|
25
|
+
return Number(value);
|
|
26
|
+
default:
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const serializeSlogObj = slogObj => JSON.stringify(slogObj, replacer);
|
package/src/slog-sender-pipe.js
CHANGED
|
@@ -63,11 +63,13 @@ const withMutex = operation => {
|
|
|
63
63
|
|
|
64
64
|
/** @param {import('.').MakeSlogSenderOptions} options */
|
|
65
65
|
export const makeSlogSender = async options => {
|
|
66
|
+
const { env = {} } = options;
|
|
66
67
|
const { registerShutdown } = makeShutdown();
|
|
67
68
|
|
|
68
69
|
const cp = fork(path.join(dirname, 'slog-sender-pipe-entrypoint.js'), [], {
|
|
69
70
|
stdio: ['ignore', 'inherit', 'inherit', 'ipc'],
|
|
70
71
|
serialization: 'advanced',
|
|
72
|
+
env,
|
|
71
73
|
});
|
|
72
74
|
// logger.log('done fork');
|
|
73
75
|
/** @type {(msg: Record<string, unknown> & {type: string}) => Promise<void>} */
|