@agoric/telemetry 0.6.3-dev-db6d589.0 → 0.6.3-dev-08d306c.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/telemetry",
3
- "version": "0.6.3-dev-db6d589.0+db6d589",
3
+ "version": "0.6.3-dev-08d306c.0+08d306c",
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-db6d589.0+db6d589",
26
- "@agoric/store": "0.9.3-dev-db6d589.0+db6d589",
25
+ "@agoric/internal": "0.3.3-dev-08d306c.0+08d306c",
26
+ "@agoric/store": "0.9.3-dev-08d306c.0+08d306c",
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": "db6d58920be363874b45206b746e838043dfe179"
71
+ "gitHead": "08d306c3a0e07b392720bc317f2680a672a35aec"
72
72
  }
@@ -1,4 +1,32 @@
1
- export const serializeSlogObj = slogObj =>
2
- JSON.stringify(slogObj, (_, arg) =>
3
- typeof arg === 'bigint' ? Number(arg) : arg,
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);
@@ -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>} */