@agoric/telemetry 0.6.3-other-dev-fbe72e7.0.fbe72e7 → 0.6.3-other-dev-d15096d.0.d15096d
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/context-aware-slog-file.js +7 -2
- package/src/flight-recorder.js +2 -1
- package/src/index.js +9 -3
- package/src/make-slog-sender.js +6 -3
- package/src/otel-and-flight-recorder.js +5 -1
- package/src/otel-context-aware-slog.js +10 -4
- package/src/otel-metrics.js +2 -1
- package/src/prometheus.js +5 -1
- package/src/slog-file.js +5 -1
- package/src/slog-sender-pipe-entrypoint.js +12 -4
- package/src/slog-sender-pipe.js +14 -5
- package/src/slog-to-otel.js +12 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/telemetry",
|
|
3
|
-
"version": "0.6.3-other-dev-
|
|
3
|
+
"version": "0.6.3-other-dev-d15096d.0.d15096d",
|
|
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-other-dev-
|
|
26
|
-
"@agoric/store": "0.9.3-other-dev-
|
|
25
|
+
"@agoric/internal": "0.3.3-other-dev-d15096d.0.d15096d",
|
|
26
|
+
"@agoric/store": "0.9.3-other-dev-d15096d.0.d15096d",
|
|
27
27
|
"@endo/errors": "^1.2.13",
|
|
28
28
|
"@endo/init": "^1.1.12",
|
|
29
29
|
"@endo/marshal": "^1.8.0",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"typeCoverage": {
|
|
70
70
|
"atLeast": 89.28
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "d15096dc4ff8b96e9b6cd11954c20d3a9efbb393"
|
|
73
73
|
}
|
|
@@ -5,7 +5,12 @@ import { makeContextualSlogProcessor } from './context-aware-slog.js';
|
|
|
5
5
|
import { serializeSlogObj } from './serialize-slog-obj.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @
|
|
8
|
+
* @import {MakeSlogSenderOptions} from './index.js';
|
|
9
|
+
* @import {Slog} from './context-aware-slog.js';
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {MakeSlogSenderOptions} options
|
|
9
14
|
*/
|
|
10
15
|
export const makeSlogSender = async options => {
|
|
11
16
|
const { CHAIN_ID, CONTEXTUAL_SLOGFILE } = options.env || {};
|
|
@@ -26,7 +31,7 @@ export const makeSlogSender = async options => {
|
|
|
26
31
|
});
|
|
27
32
|
|
|
28
33
|
/**
|
|
29
|
-
* @param {
|
|
34
|
+
* @param {Slog} slog
|
|
30
35
|
*/
|
|
31
36
|
const slogSender = slog => {
|
|
32
37
|
const contextualizedSlog = contextualSlogProcessor(slog);
|
package/src/flight-recorder.js
CHANGED
|
@@ -9,6 +9,7 @@ import { serializeSlogObj } from './serialize-slog-obj.js';
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @import {EReturn} from '@endo/far';
|
|
12
|
+
* @import {MakeSlogSender} from './index.js';
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
15
|
export const DEFAULT_CBUF_SIZE = 100 * 1024 * 1024;
|
|
@@ -311,7 +312,7 @@ export const makeSlogSenderFromBuffer = ({ fileHandle, writeCircBuf }) => {
|
|
|
311
312
|
/**
|
|
312
313
|
* Loaded dynamically by makeSlogSender()
|
|
313
314
|
*
|
|
314
|
-
* @type {
|
|
315
|
+
* @type {MakeSlogSender}
|
|
315
316
|
*/
|
|
316
317
|
export const makeSlogSender = async opts => {
|
|
317
318
|
const { fileHandle, writeCircBuf } = await makeSimpleCircularBuffer(opts);
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,12 @@ import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
|
|
|
4
4
|
import { Resource } from '@opentelemetry/resources';
|
|
5
5
|
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @import {MakeSlogSenderOptions} from './index.js';
|
|
9
|
+
* @import {ResourceAttributes} from '@opentelemetry/resources';
|
|
10
|
+
* @import {View} from '@opentelemetry/sdk-metrics';
|
|
11
|
+
*/
|
|
12
|
+
|
|
7
13
|
export * from './make-slog-sender.js';
|
|
8
14
|
|
|
9
15
|
/**
|
|
@@ -14,7 +20,7 @@ export * from './make-slog-sender.js';
|
|
|
14
20
|
* }} SlogSender
|
|
15
21
|
*/
|
|
16
22
|
/**
|
|
17
|
-
* @typedef {(opts:
|
|
23
|
+
* @typedef {(opts: MakeSlogSenderOptions) => Promise<SlogSender | undefined>} MakeSlogSender
|
|
18
24
|
*/
|
|
19
25
|
/**
|
|
20
26
|
* @typedef {MakeSlogSenderCommonOptions & Record<string, unknown>} MakeSlogSenderOptions
|
|
@@ -56,7 +62,7 @@ export const getResourceAttributes = ({
|
|
|
56
62
|
}) => {
|
|
57
63
|
const { OTEL_RESOURCE_ATTRIBUTES, SDK_REVISION } = env;
|
|
58
64
|
|
|
59
|
-
/** @type {
|
|
65
|
+
/** @type {ResourceAttributes} */
|
|
60
66
|
const resourceAttributes = {};
|
|
61
67
|
if (SDK_REVISION) {
|
|
62
68
|
// Detect testnet-load-generator target revision.
|
|
@@ -86,7 +92,7 @@ export const getResourceAttributes = ({
|
|
|
86
92
|
* @typedef {object} Powers
|
|
87
93
|
* @property {Pick<Console, 'warn'>} console
|
|
88
94
|
* @property {NodeJS.ProcessEnv} env
|
|
89
|
-
* @property {
|
|
95
|
+
* @property {View[]} views
|
|
90
96
|
* @property {string} [serviceName]
|
|
91
97
|
*/
|
|
92
98
|
|
package/src/make-slog-sender.js
CHANGED
|
@@ -9,7 +9,10 @@ export const DEFAULT_SLOGSENDER_MODULE =
|
|
|
9
9
|
export const SLOGFILE_SENDER_MODULE = '@agoric/telemetry/src/slog-file.js';
|
|
10
10
|
export const PROMETHEUS_SENDER_MODULE = '@agoric/telemetry/src/prometheus.js';
|
|
11
11
|
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* @import {SlogSender} from './index.js'
|
|
14
|
+
* @import {MakeSlogSender} from './index.js';
|
|
15
|
+
*/
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* @template T
|
|
@@ -36,7 +39,7 @@ const filterTruthy = arr => /** @type {any[]} */ (arr.filter(Boolean));
|
|
|
36
39
|
* When there are no subordinates, the return value will be `undefined` rather
|
|
37
40
|
* than a slog sender function.
|
|
38
41
|
*
|
|
39
|
-
* @type {
|
|
42
|
+
* @type {MakeSlogSender}
|
|
40
43
|
*/
|
|
41
44
|
export const makeSlogSender = async (opts = {}) => {
|
|
42
45
|
const { env = {}, stateDir: stateDirOption, ...otherOpts } = opts;
|
|
@@ -102,7 +105,7 @@ export const makeSlogSender = async (opts = {}) => {
|
|
|
102
105
|
console.warn('Loading slog sender modules:', ...slogSenderModules);
|
|
103
106
|
}
|
|
104
107
|
|
|
105
|
-
/** @type {Map<
|
|
108
|
+
/** @type {Map<MakeSlogSender, string>} */
|
|
106
109
|
const makerMap = new Map();
|
|
107
110
|
await Promise.all(
|
|
108
111
|
[...slogSenderModules].map(async moduleIdentifier => {
|
|
@@ -2,7 +2,11 @@ import { NonNullish } from '@agoric/internal';
|
|
|
2
2
|
import { makeSlogSender as makeSlogSenderFromEnv } from './make-slog-sender.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
5
|
+
* @import {MakeSlogSenderOptions} from './index.js';
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {MakeSlogSenderOptions} opts
|
|
6
10
|
*/
|
|
7
11
|
export const makeSlogSender = async opts => {
|
|
8
12
|
const { SLOGFILE: _1, SLOGSENDER: _2, ...otherEnv } = opts.env || {};
|
|
@@ -11,6 +11,12 @@ import { makeContextualSlogProcessor } from './context-aware-slog.js';
|
|
|
11
11
|
import { getResourceAttributes } from './index.js';
|
|
12
12
|
import { serializeSlogObj } from './serialize-slog-obj.js';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @import {Context} from './context-aware-slog.js';
|
|
16
|
+
* @import {MakeSlogSenderOptions} from './index.js';
|
|
17
|
+
* @import {Slog} from './context-aware-slog.js';
|
|
18
|
+
*/
|
|
19
|
+
|
|
14
20
|
const DEFAULT_CONTEXT_FILE = 'slog-context.json';
|
|
15
21
|
const FILE_ENCODING = 'utf8';
|
|
16
22
|
|
|
@@ -22,7 +28,7 @@ export const getContextFilePersistenceUtils = filePath => {
|
|
|
22
28
|
|
|
23
29
|
return {
|
|
24
30
|
/**
|
|
25
|
-
* @param {
|
|
31
|
+
* @param {Context} context
|
|
26
32
|
*/
|
|
27
33
|
persistContext: context => {
|
|
28
34
|
try {
|
|
@@ -33,7 +39,7 @@ export const getContextFilePersistenceUtils = filePath => {
|
|
|
33
39
|
},
|
|
34
40
|
|
|
35
41
|
/**
|
|
36
|
-
* @returns {
|
|
42
|
+
* @returns {Context | null}
|
|
37
43
|
*/
|
|
38
44
|
restoreContext: () => {
|
|
39
45
|
try {
|
|
@@ -47,7 +53,7 @@ export const getContextFilePersistenceUtils = filePath => {
|
|
|
47
53
|
};
|
|
48
54
|
|
|
49
55
|
/**
|
|
50
|
-
* @param {
|
|
56
|
+
* @param {MakeSlogSenderOptions} options
|
|
51
57
|
*/
|
|
52
58
|
export const makeSlogSender = async options => {
|
|
53
59
|
const { CHAIN_ID, OTEL_EXPORTER_OTLP_ENDPOINT } = options.env || {};
|
|
@@ -79,7 +85,7 @@ export const makeSlogSender = async options => {
|
|
|
79
85
|
);
|
|
80
86
|
|
|
81
87
|
/**
|
|
82
|
-
* @param {
|
|
88
|
+
* @param {Slog} slog
|
|
83
89
|
*/
|
|
84
90
|
const slogSender = slog => {
|
|
85
91
|
const { time, ...logRecord } = contextualSlogProcessor(slog);
|
package/src/otel-metrics.js
CHANGED
|
@@ -13,11 +13,12 @@ import {
|
|
|
13
13
|
* @import {MetricOptions, ObservableCounter, ObservableUpDownCounter} from '@opentelemetry/api';
|
|
14
14
|
* @import {MeterProvider} from '@opentelemetry/sdk-metrics';
|
|
15
15
|
* @import {TotalMap} from '@agoric/internal';
|
|
16
|
+
* @import {MakeSlogSenderOptions} from './index.js';
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
const knownActionTypes = new Set(Object.values(ActionType.QueuedActionType));
|
|
19
20
|
|
|
20
|
-
/** @param {
|
|
21
|
+
/** @param {MakeSlogSenderOptions & {otelMeterName: string, otelMeterProvider?: MeterProvider}} opts */
|
|
21
22
|
export const makeSlogSender = async (opts = /** @type {any} */ ({})) => {
|
|
22
23
|
const { otelMeterName, otelMeterProvider } = opts;
|
|
23
24
|
if (!otelMeterName) throw Fail`OTel meter name is required`;
|
package/src/prometheus.js
CHANGED
|
@@ -3,7 +3,11 @@ import { Fail } from '@endo/errors';
|
|
|
3
3
|
import { getPrometheusMeterProvider } from './index.js';
|
|
4
4
|
import { makeSlogSender as makeOtelMetricsSender } from './otel-metrics.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* @import {MakeSlogSenderOptions} from './index.js';
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** @param {MakeSlogSenderOptions & {otelMeterName?: string}} opts */
|
|
7
11
|
export const makeSlogSender = async (opts = {}) => {
|
|
8
12
|
const { env, otelMeterName, serviceName } = opts;
|
|
9
13
|
if (!otelMeterName) throw Fail`OTel meter name is required`;
|
package/src/slog-file.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { makeFsStreamWriter } from '@agoric/internal/src/node/fs-stream.js';
|
|
2
2
|
import { serializeSlogObj } from './serialize-slog-obj.js';
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* @import {MakeSlogSenderOptions} from './index.js';
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** @param {MakeSlogSenderOptions} opts */
|
|
5
9
|
export const makeSlogSender = async ({ env: { SLOGFILE } = {} } = {}) => {
|
|
6
10
|
const stream = await makeFsStreamWriter(SLOGFILE);
|
|
7
11
|
|
|
@@ -15,13 +15,21 @@ import { makeShutdown } from '@agoric/internal/src/node/shutdown.js';
|
|
|
15
15
|
|
|
16
16
|
import { makeSlogSender } from './make-slog-sender.js';
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @import {PipeAPIReply} from './slog-sender-pipe.js';
|
|
20
|
+
* @import {MakeSlogSenderOptions} from './index.js';
|
|
21
|
+
* @import {SlogSender} from './index.js';
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
25
|
+
// @ts-ignore TODO remove when anylogger has types
|
|
18
26
|
const logger = anylogger('slog-sender-pipe-entrypoint');
|
|
19
27
|
|
|
20
|
-
/** @type {(msg:
|
|
28
|
+
/** @type {(msg: PipeAPIReply) => void} */
|
|
21
29
|
const send = Function.prototype.bind.call(process.send, process);
|
|
22
30
|
|
|
23
31
|
/**
|
|
24
|
-
* @typedef {{type: 'init', options:
|
|
32
|
+
* @typedef {{type: 'init', options: MakeSlogSenderOptions }} InitMessage
|
|
25
33
|
* @typedef {{type: 'flush' }} FlushMessage
|
|
26
34
|
* @typedef {{type: 'send', obj: Record<string, unknown> }} SendMessage
|
|
27
35
|
*
|
|
@@ -31,7 +39,7 @@ const send = Function.prototype.bind.call(process.send, process);
|
|
|
31
39
|
*/
|
|
32
40
|
|
|
33
41
|
const main = async () => {
|
|
34
|
-
/** @type {
|
|
42
|
+
/** @type {SlogSender | undefined} */
|
|
35
43
|
let slogSender;
|
|
36
44
|
|
|
37
45
|
const sendErrors = [];
|
|
@@ -44,7 +52,7 @@ const main = async () => {
|
|
|
44
52
|
process.disconnect?.();
|
|
45
53
|
});
|
|
46
54
|
|
|
47
|
-
/** @param {
|
|
55
|
+
/** @param {MakeSlogSenderOptions} opts */
|
|
48
56
|
const init = async ({ env, ...otherOpts } = {}) => {
|
|
49
57
|
!slogSender || Fail`Already initialized`;
|
|
50
58
|
|
package/src/slog-sender-pipe.js
CHANGED
|
@@ -17,8 +17,17 @@ import { makeQueue } from '@endo/stream';
|
|
|
17
17
|
|
|
18
18
|
import { makeShutdown } from '@agoric/internal/src/node/shutdown.js';
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* @import {AsyncQueue} from '@endo/stream';
|
|
22
|
+
* @import {InitMessage} from './slog-sender-pipe-entrypoint.js';
|
|
23
|
+
* @import {FlushMessage} from './slog-sender-pipe-entrypoint.js';
|
|
24
|
+
* @import {MakeSlogSenderOptions} from './index.js';
|
|
25
|
+
*/
|
|
26
|
+
|
|
20
27
|
const dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
21
28
|
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
30
|
+
// @ts-ignore TODO remove when anylogger has types
|
|
22
31
|
const logger = anylogger('slog-sender-pipe');
|
|
23
32
|
|
|
24
33
|
const sink = () => {};
|
|
@@ -29,7 +38,7 @@ const sink = () => {};
|
|
|
29
38
|
* @param {(...args: T) => Promise<R>} operation
|
|
30
39
|
*/
|
|
31
40
|
const withMutex = operation => {
|
|
32
|
-
/** @type {
|
|
41
|
+
/** @type {AsyncQueue<void>} */
|
|
33
42
|
const mutex = makeQueue();
|
|
34
43
|
mutex.put(Promise.resolve());
|
|
35
44
|
/** @param {T} args */
|
|
@@ -49,11 +58,11 @@ const withMutex = operation => {
|
|
|
49
58
|
/**
|
|
50
59
|
* @typedef {{
|
|
51
60
|
* init: {
|
|
52
|
-
* message:
|
|
61
|
+
* message: InitMessage;
|
|
53
62
|
* reply: PipeReply<{ hasSender: boolean }>;
|
|
54
63
|
* };
|
|
55
64
|
* flush: {
|
|
56
|
-
* message:
|
|
65
|
+
* message: FlushMessage;
|
|
57
66
|
* reply: PipeReply<{}>;
|
|
58
67
|
* };
|
|
59
68
|
* }} SlogSenderPipeAPI
|
|
@@ -62,7 +71,7 @@ const withMutex = operation => {
|
|
|
62
71
|
* @typedef {SlogSenderPipeAPI[PipeAPICommand]["reply"]} PipeAPIReply
|
|
63
72
|
*/
|
|
64
73
|
|
|
65
|
-
/** @param {
|
|
74
|
+
/** @param {MakeSlogSenderOptions} options */
|
|
66
75
|
export const makeSlogSender = async options => {
|
|
67
76
|
const { env = {} } = options;
|
|
68
77
|
const { registerShutdown } = makeShutdown();
|
|
@@ -87,7 +96,7 @@ export const makeSlogSender = async options => {
|
|
|
87
96
|
const rawSend = promisify(cp.send.bind(cp));
|
|
88
97
|
const pipeSend = withMutex(rawSend);
|
|
89
98
|
|
|
90
|
-
/** @type {
|
|
99
|
+
/** @type {AsyncQueue<PipeAPIReply>} */
|
|
91
100
|
const sendWaitQueue = makeQueue();
|
|
92
101
|
/** @type {PipeAPICommand | undefined} */
|
|
93
102
|
let sendWaitType;
|
package/src/slog-to-otel.js
CHANGED
|
@@ -14,7 +14,13 @@ import {
|
|
|
14
14
|
|
|
15
15
|
// diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.VERBOSE);
|
|
16
16
|
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* @import {Span, Link as SpanLink} from '@opentelemetry/api'
|
|
19
|
+
* @import {Tracer} from '@opentelemetry/api';
|
|
20
|
+
* @import {SwingSetCapData} from '@agoric/swingset-vat';
|
|
21
|
+
* @import {Message} from '@agoric/swingset-vat';
|
|
22
|
+
* @import {KernelSyscallObject} from '@agoric/swingset-vat';
|
|
23
|
+
*/
|
|
18
24
|
/** @import {SpanContext, SpanOptions} from '@opentelemetry/api' */
|
|
19
25
|
|
|
20
26
|
const { assign } = Object;
|
|
@@ -76,7 +82,7 @@ export const floatSecondsToHiRes = sFloat => {
|
|
|
76
82
|
};
|
|
77
83
|
|
|
78
84
|
/**
|
|
79
|
-
* @param {
|
|
85
|
+
* @param {Tracer} tracer
|
|
80
86
|
* @param {Record<string, any>} [overrideAttrs]
|
|
81
87
|
*/
|
|
82
88
|
export const makeSlogToOtelKit = (tracer, overrideAttrs = {}) => {
|
|
@@ -140,7 +146,7 @@ export const makeSlogToOtelKit = (tracer, overrideAttrs = {}) => {
|
|
|
140
146
|
});
|
|
141
147
|
|
|
142
148
|
/**
|
|
143
|
-
* @param {
|
|
149
|
+
* @param {SwingSetCapData} data
|
|
144
150
|
* @returns {any}
|
|
145
151
|
*/
|
|
146
152
|
const unserialize = data => {
|
|
@@ -156,12 +162,12 @@ export const makeSlogToOtelKit = (tracer, overrideAttrs = {}) => {
|
|
|
156
162
|
/**
|
|
157
163
|
* @typedef {{
|
|
158
164
|
* method: string;
|
|
159
|
-
* args:
|
|
165
|
+
* args: SwingSetCapData;
|
|
160
166
|
* result?: string | undefined | null,
|
|
161
167
|
* }} OldMessage
|
|
162
168
|
*/
|
|
163
169
|
/** @typedef {ReturnType<typeof parseMsg>} ParsedMessage */
|
|
164
|
-
/** @param {
|
|
170
|
+
/** @param {Message | OldMessage} msg */
|
|
165
171
|
const parseMsg = msg => {
|
|
166
172
|
/** @type {string | symbol | null} */
|
|
167
173
|
let method = null;
|
|
@@ -699,7 +705,7 @@ export const makeSlogToOtelKit = (tracer, overrideAttrs = {}) => {
|
|
|
699
705
|
if (isReplaying) {
|
|
700
706
|
break;
|
|
701
707
|
}
|
|
702
|
-
/** @type {{ksc:
|
|
708
|
+
/** @type {{ksc: KernelSyscallObject } & Record<string, unknown>} */
|
|
703
709
|
const { ksc, vsc: _1, ...attrs } = slogAttrs;
|
|
704
710
|
if (!ksc) {
|
|
705
711
|
break;
|