@agoric/telemetry 0.7.0 → 0.7.1-upgrade-23-dev-bd79330.0.bd79330
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 +10 -9
- package/src/context-aware-slog-file.js +7 -2
- package/src/context-aware-slog.js +3 -3
- package/src/flight-recorder.js +2 -1
- package/src/index.js +9 -3
- package/src/ingest-slog-entrypoint.js +8 -8
- package/src/kv-string-store.js +7 -2
- package/src/make-slog-sender.js +7 -4
- package/src/otel-and-flight-recorder.js +5 -1
- package/src/otel-context-aware-slog.js +11 -5
- 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 +11 -5
- package/src/slog-sender-pipe.js +16 -9
- package/src/slog-to-otel.js +13 -6
- package/CHANGELOG.md +0 -174
- package/sample-otel-collector.yaml +0 -94
- package/scripts/ingest.sh +0 -30
- package/scripts/otelcol.sh +0 -14
- package/test/flight-recorder.test.js +0 -114
- package/test/import.test.js +0 -36
- package/test/prepare-test-env-ava.js +0 -4
- package/tsconfig.json +0 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/telemetry",
|
|
3
|
-
"version": "0.7.0",
|
|
3
|
+
"version": "0.7.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
4
4
|
"description": "Agoric's telemetry implementation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/Agoric/agoric-sdk",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"lint-fix": "yarn lint:eslint --fix",
|
|
14
14
|
"lint": "yarn run -T run-s --continue-on-error 'lint:*'",
|
|
15
15
|
"lint:types": "yarn run -T tsc",
|
|
16
|
-
"lint:eslint": "
|
|
16
|
+
"lint:eslint": "node ../../scripts/eslint-repo.mjs ."
|
|
17
17
|
},
|
|
18
18
|
"bin": {
|
|
19
19
|
"frcat": "./src/frcat-entrypoint.js"
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"author": "Agoric",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@agoric/internal": "0.4.0",
|
|
26
|
-
"@agoric/store": "0.10.0",
|
|
25
|
+
"@agoric/internal": "0.4.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
26
|
+
"@agoric/store": "0.10.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
27
27
|
"@endo/errors": "^1.2.13",
|
|
28
28
|
"@endo/init": "^1.1.12",
|
|
29
29
|
"@endo/marshal": "^1.8.0",
|
|
@@ -39,17 +39,19 @@
|
|
|
39
39
|
"@opentelemetry/sdk-metrics": "~1.30.1",
|
|
40
40
|
"@opentelemetry/sdk-trace-base": "~1.30.1",
|
|
41
41
|
"@opentelemetry/semantic-conventions": "~1.28.0",
|
|
42
|
-
"anylogger": "^0.21.0",
|
|
43
42
|
"better-sqlite3": "^10.1.0",
|
|
44
43
|
"tmp": "^0.2.1"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@endo/lockdown": "^1.0.18",
|
|
48
47
|
"@endo/ses-ava": "^1.3.2",
|
|
49
|
-
"ava": "^
|
|
48
|
+
"ava": "^6.4.1",
|
|
50
49
|
"c8": "^10.1.3",
|
|
51
50
|
"tmp": "^0.2.1"
|
|
52
51
|
},
|
|
52
|
+
"files": [
|
|
53
|
+
"src"
|
|
54
|
+
],
|
|
53
55
|
"publishConfig": {
|
|
54
56
|
"access": "public"
|
|
55
57
|
},
|
|
@@ -63,11 +65,10 @@
|
|
|
63
65
|
"require": [
|
|
64
66
|
"@endo/init/debug.js"
|
|
65
67
|
],
|
|
66
|
-
"timeout": "20m"
|
|
67
|
-
"workerThreads": false
|
|
68
|
+
"timeout": "20m"
|
|
68
69
|
},
|
|
69
70
|
"typeCoverage": {
|
|
70
71
|
"atLeast": 89.28
|
|
71
72
|
},
|
|
72
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "bd79330f78dae2faf9cc3d8b10063567700da07b"
|
|
73
74
|
}
|
|
@@ -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);
|
|
@@ -67,7 +67,7 @@ const SLOG_TYPES = {
|
|
|
67
67
|
FINISH: 'cosmic-swingset-end-block-finish',
|
|
68
68
|
START: 'cosmic-swingset-end-block-start',
|
|
69
69
|
},
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
RUN: {
|
|
72
72
|
FINISH: 'cosmic-swingset-run-finish',
|
|
73
73
|
START: 'cosmic-swingset-run-start',
|
|
@@ -227,7 +227,7 @@ export const makeContextualSlogProcessor = (
|
|
|
227
227
|
|
|
228
228
|
break;
|
|
229
229
|
}
|
|
230
|
-
|
|
230
|
+
|
|
231
231
|
case SLOG_TYPES.COSMIC_SWINGSET.RUN.START: {
|
|
232
232
|
if (!finalBody.runNum) {
|
|
233
233
|
assert(!triggerContext);
|
|
@@ -353,7 +353,7 @@ export const makeContextualSlogProcessor = (
|
|
|
353
353
|
blockContext = null;
|
|
354
354
|
break;
|
|
355
355
|
}
|
|
356
|
-
|
|
356
|
+
|
|
357
357
|
case SLOG_TYPES.COSMIC_SWINGSET.RUN.FINISH: {
|
|
358
358
|
assert(!!triggerContext);
|
|
359
359
|
persistContext(
|
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
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
/* eslint-env node */
|
|
3
3
|
import '@endo/init';
|
|
4
4
|
|
|
5
|
-
import fs from 'fs';
|
|
6
|
-
import zlib from 'zlib';
|
|
7
|
-
import readline from 'readline';
|
|
8
|
-
import process from 'process';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import zlib from 'node:zlib';
|
|
7
|
+
import readline from 'node:readline';
|
|
8
|
+
import process from 'node:process';
|
|
9
9
|
|
|
10
10
|
import { makeSlogSender } from './make-slog-sender.js';
|
|
11
11
|
|
|
@@ -74,7 +74,7 @@ async function run() {
|
|
|
74
74
|
let blocksInThisPeriod = 0;
|
|
75
75
|
let startOfLastPeriod = 0;
|
|
76
76
|
|
|
77
|
-
let lastTime =
|
|
77
|
+
let lastTime = performance.now();
|
|
78
78
|
let lineCount = 0;
|
|
79
79
|
|
|
80
80
|
const stats = async flush => {
|
|
@@ -109,7 +109,7 @@ async function run() {
|
|
|
109
109
|
progress.lastSlogTime = obj.time;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
let now =
|
|
112
|
+
let now = performance.now();
|
|
113
113
|
await maybeUpdateStats(now);
|
|
114
114
|
|
|
115
115
|
if (!update) {
|
|
@@ -128,7 +128,7 @@ async function run() {
|
|
|
128
128
|
maybeWait = new Promise(resolve => setTimeout(resolve, delayMS));
|
|
129
129
|
}
|
|
130
130
|
await maybeWait;
|
|
131
|
-
now =
|
|
131
|
+
now = performance.now();
|
|
132
132
|
|
|
133
133
|
if (now - startOfLastPeriod >= PROCESSING_PERIOD) {
|
|
134
134
|
startOfLastPeriod = now;
|
|
@@ -152,7 +152,7 @@ async function run() {
|
|
|
152
152
|
linesProcessedThisPeriod += 1;
|
|
153
153
|
if (isAfterCommit) {
|
|
154
154
|
blocksInThisPeriod += 1;
|
|
155
|
-
lastTime =
|
|
155
|
+
lastTime = performance.now();
|
|
156
156
|
await stats(true);
|
|
157
157
|
}
|
|
158
158
|
}
|
package/src/kv-string-store.js
CHANGED
|
@@ -2,7 +2,12 @@ import sqlite3ambient from 'better-sqlite3';
|
|
|
2
2
|
import tmpambient from 'tmp';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
5
|
+
* @import {Database} from 'better-sqlite3';
|
|
6
|
+
* @import {LegacyMap} from '@agoric/store';
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {{ sqlite3?: (filename: string) => Database, tmp?: typeof tmpambient }} [io]
|
|
6
11
|
*/
|
|
7
12
|
export const makeTempKVDatabase = io => {
|
|
8
13
|
const { sqlite3 = sqlite3ambient, tmp = tmpambient } = io || {};
|
|
@@ -39,7 +44,7 @@ export const makeKVDatabaseTransactionManager = db => {
|
|
|
39
44
|
|
|
40
45
|
/**
|
|
41
46
|
* @param {string} kind
|
|
42
|
-
* @param {
|
|
47
|
+
* @param {Database} [db]
|
|
43
48
|
*/
|
|
44
49
|
export const makeKVStringStore = (kind, db = makeTempKVDatabase()) => {
|
|
45
50
|
/** @type {Pick<LegacyMap<string, string>, 'get'|'has'|'set'>} */
|
package/src/make-slog-sender.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path from 'path';
|
|
1
|
+
import path from 'node:path';
|
|
2
2
|
import tmp from 'tmp';
|
|
3
3
|
import { PromiseAllOrErrors, unprefixedProperties } from '@agoric/internal';
|
|
4
4
|
import { serializeSlogObj } from './serialize-slog-obj.js';
|
|
@@ -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 || {};
|
|
@@ -6,11 +6,17 @@ import {
|
|
|
6
6
|
LoggerProvider,
|
|
7
7
|
SimpleLogRecordProcessor,
|
|
8
8
|
} from '@opentelemetry/sdk-logs';
|
|
9
|
-
import { readFileSync, writeFileSync } from 'fs';
|
|
9
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
10
10
|
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
|
|
|
@@ -9,19 +9,25 @@
|
|
|
9
9
|
|
|
10
10
|
import '@endo/init';
|
|
11
11
|
|
|
12
|
-
import anylogger from 'anylogger';
|
|
12
|
+
import anylogger from '@agoric/internal/vendor/anylogger.js';
|
|
13
13
|
import { Fail } from '@endo/errors';
|
|
14
14
|
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
|
+
|
|
18
24
|
const logger = anylogger('slog-sender-pipe-entrypoint');
|
|
19
25
|
|
|
20
|
-
/** @type {(msg:
|
|
26
|
+
/** @type {(msg: PipeAPIReply) => void} */
|
|
21
27
|
const send = Function.prototype.bind.call(process.send, process);
|
|
22
28
|
|
|
23
29
|
/**
|
|
24
|
-
* @typedef {{type: 'init', options:
|
|
30
|
+
* @typedef {{type: 'init', options: MakeSlogSenderOptions }} InitMessage
|
|
25
31
|
* @typedef {{type: 'flush' }} FlushMessage
|
|
26
32
|
* @typedef {{type: 'send', obj: Record<string, unknown> }} SendMessage
|
|
27
33
|
*
|
|
@@ -31,7 +37,7 @@ const send = Function.prototype.bind.call(process.send, process);
|
|
|
31
37
|
*/
|
|
32
38
|
|
|
33
39
|
const main = async () => {
|
|
34
|
-
/** @type {
|
|
40
|
+
/** @type {SlogSender | undefined} */
|
|
35
41
|
let slogSender;
|
|
36
42
|
|
|
37
43
|
const sendErrors = [];
|
|
@@ -44,7 +50,7 @@ const main = async () => {
|
|
|
44
50
|
process.disconnect?.();
|
|
45
51
|
});
|
|
46
52
|
|
|
47
|
-
/** @param {
|
|
53
|
+
/** @param {MakeSlogSenderOptions} opts */
|
|
48
54
|
const init = async ({ env, ...otherOpts } = {}) => {
|
|
49
55
|
!slogSender || Fail`Already initialized`;
|
|
50
56
|
|
package/src/slog-sender-pipe.js
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* https://nodejs.org/docs/latest/api/child_process.html#advanced-serialization
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { fork } from 'child_process';
|
|
10
|
-
import path from 'path';
|
|
11
|
-
import { promisify } from 'util';
|
|
12
|
-
import anylogger from 'anylogger';
|
|
9
|
+
import { fork } from 'node:child_process';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { promisify } from 'node:util';
|
|
12
|
+
import anylogger from '@agoric/internal/vendor/anylogger.js';
|
|
13
13
|
|
|
14
14
|
import { q, Fail } from '@endo/errors';
|
|
15
15
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
@@ -17,6 +17,13 @@ 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
|
|
|
22
29
|
const logger = anylogger('slog-sender-pipe');
|
|
@@ -29,7 +36,7 @@ const sink = () => {};
|
|
|
29
36
|
* @param {(...args: T) => Promise<R>} operation
|
|
30
37
|
*/
|
|
31
38
|
const withMutex = operation => {
|
|
32
|
-
/** @type {
|
|
39
|
+
/** @type {AsyncQueue<void>} */
|
|
33
40
|
const mutex = makeQueue();
|
|
34
41
|
mutex.put(Promise.resolve());
|
|
35
42
|
/** @param {T} args */
|
|
@@ -49,11 +56,11 @@ const withMutex = operation => {
|
|
|
49
56
|
/**
|
|
50
57
|
* @typedef {{
|
|
51
58
|
* init: {
|
|
52
|
-
* message:
|
|
59
|
+
* message: InitMessage;
|
|
53
60
|
* reply: PipeReply<{ hasSender: boolean }>;
|
|
54
61
|
* };
|
|
55
62
|
* flush: {
|
|
56
|
-
* message:
|
|
63
|
+
* message: FlushMessage;
|
|
57
64
|
* reply: PipeReply<{}>;
|
|
58
65
|
* };
|
|
59
66
|
* }} SlogSenderPipeAPI
|
|
@@ -62,7 +69,7 @@ const withMutex = operation => {
|
|
|
62
69
|
* @typedef {SlogSenderPipeAPI[PipeAPICommand]["reply"]} PipeAPIReply
|
|
63
70
|
*/
|
|
64
71
|
|
|
65
|
-
/** @param {
|
|
72
|
+
/** @param {MakeSlogSenderOptions} options */
|
|
66
73
|
export const makeSlogSender = async options => {
|
|
67
74
|
const { env = {} } = options;
|
|
68
75
|
const { registerShutdown } = makeShutdown();
|
|
@@ -87,7 +94,7 @@ export const makeSlogSender = async options => {
|
|
|
87
94
|
const rawSend = promisify(cp.send.bind(cp));
|
|
88
95
|
const pipeSend = withMutex(rawSend);
|
|
89
96
|
|
|
90
|
-
/** @type {
|
|
97
|
+
/** @type {AsyncQueue<PipeAPIReply>} */
|
|
91
98
|
const sendWaitQueue = makeQueue();
|
|
92
99
|
/** @type {PipeAPICommand | undefined} */
|
|
93
100
|
let sendWaitType;
|
package/src/slog-to-otel.js
CHANGED
|
@@ -14,7 +14,14 @@ 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
|
+
* @import {LegacyMap} from '@agoric/store';
|
|
24
|
+
*/
|
|
18
25
|
/** @import {SpanContext, SpanOptions} from '@opentelemetry/api' */
|
|
19
26
|
|
|
20
27
|
const { assign } = Object;
|
|
@@ -76,7 +83,7 @@ export const floatSecondsToHiRes = sFloat => {
|
|
|
76
83
|
};
|
|
77
84
|
|
|
78
85
|
/**
|
|
79
|
-
* @param {
|
|
86
|
+
* @param {Tracer} tracer
|
|
80
87
|
* @param {Record<string, any>} [overrideAttrs]
|
|
81
88
|
*/
|
|
82
89
|
export const makeSlogToOtelKit = (tracer, overrideAttrs = {}) => {
|
|
@@ -140,7 +147,7 @@ export const makeSlogToOtelKit = (tracer, overrideAttrs = {}) => {
|
|
|
140
147
|
});
|
|
141
148
|
|
|
142
149
|
/**
|
|
143
|
-
* @param {
|
|
150
|
+
* @param {SwingSetCapData} data
|
|
144
151
|
* @returns {any}
|
|
145
152
|
*/
|
|
146
153
|
const unserialize = data => {
|
|
@@ -156,12 +163,12 @@ export const makeSlogToOtelKit = (tracer, overrideAttrs = {}) => {
|
|
|
156
163
|
/**
|
|
157
164
|
* @typedef {{
|
|
158
165
|
* method: string;
|
|
159
|
-
* args:
|
|
166
|
+
* args: SwingSetCapData;
|
|
160
167
|
* result?: string | undefined | null,
|
|
161
168
|
* }} OldMessage
|
|
162
169
|
*/
|
|
163
170
|
/** @typedef {ReturnType<typeof parseMsg>} ParsedMessage */
|
|
164
|
-
/** @param {
|
|
171
|
+
/** @param {Message | OldMessage} msg */
|
|
165
172
|
const parseMsg = msg => {
|
|
166
173
|
/** @type {string | symbol | null} */
|
|
167
174
|
let method = null;
|
|
@@ -699,7 +706,7 @@ export const makeSlogToOtelKit = (tracer, overrideAttrs = {}) => {
|
|
|
699
706
|
if (isReplaying) {
|
|
700
707
|
break;
|
|
701
708
|
}
|
|
702
|
-
/** @type {{ksc:
|
|
709
|
+
/** @type {{ksc: KernelSyscallObject } & Record<string, unknown>} */
|
|
703
710
|
const { ksc, vsc: _1, ...attrs } = slogAttrs;
|
|
704
711
|
if (!ksc) {
|
|
705
712
|
break;
|
package/CHANGELOG.md
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
## [0.7.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.7.0-u22.2...@agoric/telemetry@0.7.0) (2026-04-02)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @agoric/telemetry
|
|
9
|
-
|
|
10
|
-
## [0.7.0-u22.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.7.0-u22.1...@agoric/telemetry@0.7.0-u22.2) (2025-09-09)
|
|
11
|
-
|
|
12
|
-
**Note:** Version bump only for package @agoric/telemetry
|
|
13
|
-
|
|
14
|
-
## [0.7.0-u22.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.7.0-u22.0...@agoric/telemetry@0.7.0-u22.1) (2025-09-09)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @agoric/telemetry
|
|
17
|
-
|
|
18
|
-
## [0.7.0-u22.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.6.2...@agoric/telemetry@0.7.0-u22.0) (2025-09-08)
|
|
19
|
-
|
|
20
|
-
### Features
|
|
21
|
-
|
|
22
|
-
* Add the Prometheus slog sender module and load it per OTEL_EXPORTER_PROMETHEUS_PORT ([1dc1827](https://github.com/Agoric/agoric-sdk/commit/1dc182783ce191f0ba2131cb1f7b3042f287737a)), closes [#11045](https://github.com/Agoric/agoric-sdk/issues/11045)
|
|
23
|
-
* **cosmic-swingset:** add JS upgrade plan handler stub ([655133e](https://github.com/Agoric/agoric-sdk/commit/655133ed909b5d632dc033e992214a7b6a1b5ab1))
|
|
24
|
-
* **internal:** Add helper `unprefixedProperties` for environment variable consumption ([878fecf](https://github.com/Agoric/agoric-sdk/commit/878fecf4f5153fa80f48a27a8b79e67943b2d199))
|
|
25
|
-
* simple CircularBuffer with fs offsets ([8d9cb7a](https://github.com/Agoric/agoric-sdk/commit/8d9cb7abe96e8905f5aaa0927e02914ef09279c4))
|
|
26
|
-
* **telemetry:** context aware slog support new triggers ([03965d9](https://github.com/Agoric/agoric-sdk/commit/03965d90b86cf75ce7f6677861e3a0aa8ac70710))
|
|
27
|
-
* **telemetry:** ingest-slog explicitly supports `-` for stdin ([63367c4](https://github.com/Agoric/agoric-sdk/commit/63367c4aaf9bafbd6553a1f4cb808c96bc90845a))
|
|
28
|
-
* **telemetry:** ingest-slog throttle and flush per block ([2134944](https://github.com/Agoric/agoric-sdk/commit/21349448b3b9379a9da43218a59a7e7eaf4f5a9e))
|
|
29
|
-
* **telemetry:** Update slog sender JSON serialization of error instances ([5db996d](https://github.com/Agoric/agoric-sdk/commit/5db996d99830e61fad6eed373e2fb2dc810d662e))
|
|
30
|
-
* use writeSync slogSender ([47a2add](https://github.com/Agoric/agoric-sdk/commit/47a2adda72a5377eda181a425130cdc5a7fd7ff5))
|
|
31
|
-
|
|
32
|
-
### Bug Fixes
|
|
33
|
-
|
|
34
|
-
* ensure script main rejections exit with error ([abdab87](https://github.com/Agoric/agoric-sdk/commit/abdab879014a5c3124ebd0e9246995ac6b1ce6e5))
|
|
35
|
-
* Properly synchronize slog sender termination ([f83c01d](https://github.com/Agoric/agoric-sdk/commit/f83c01d89d80798e0922acdb498fcc7250560977))
|
|
36
|
-
* **telemetry:** add missing slog type ([1aec8d0](https://github.com/Agoric/agoric-sdk/commit/1aec8d05036f6b3c3e3730339d1829da6b4a9051))
|
|
37
|
-
* **telemetry:** async flight recorder read ([b7a19dd](https://github.com/Agoric/agoric-sdk/commit/b7a19dd9c106d9b31e6f9188f5d4df0bbb5132bf))
|
|
38
|
-
* **telemetry:** avoid polluting stdout in ingest-slog ([d4b8dfa](https://github.com/Agoric/agoric-sdk/commit/d4b8dfa91155789f7ceda5cc3cef06019b9527e7))
|
|
39
|
-
* **telemetry:** Empty context persisted when remaining beans are negative after run finish ([#10635](https://github.com/Agoric/agoric-sdk/issues/10635)) ([ad4e83e](https://github.com/Agoric/agoric-sdk/commit/ad4e83e0b6dff9716da91fd65d367d3acad1772e))
|
|
40
|
-
* **telemetry:** event name typo ([9e19321](https://github.com/Agoric/agoric-sdk/commit/9e19321ea8fed32d445d44169b32f5d94a93d61e))
|
|
41
|
-
* **telemetry:** Extend shutdown logic for slog-sender-pipe and otel-metrics ([7b8ccc8](https://github.com/Agoric/agoric-sdk/commit/7b8ccc82e641e5d11ccc6b8aebe524f75af829fe)), closes [#11175](https://github.com/Agoric/agoric-sdk/issues/11175)
|
|
42
|
-
* **telemetry:** flight recorder flush does sync ([d270202](https://github.com/Agoric/agoric-sdk/commit/d2702028d77c06f3b4de91ca711a3c45c685a477))
|
|
43
|
-
* **telemetry:** flight-recorder check second read size ([bfbacb2](https://github.com/Agoric/agoric-sdk/commit/bfbacb2b9f8de36f8f66b8cba8a88603fb7225e2))
|
|
44
|
-
* **telemetry:** flight-recorder ignores write after shutdown ([3d2bcb3](https://github.com/Agoric/agoric-sdk/commit/3d2bcb3c56ac24a0f991200b223e6af8514dc5b8))
|
|
45
|
-
* **telemetry:** handle new trigger slog events ([d32cb7e](https://github.com/Agoric/agoric-sdk/commit/d32cb7e9f406c25399321dc32e827b5018c38b69))
|
|
46
|
-
* **telemetry:** ingest-slog avoid writing progress file for stdin ([62589ca](https://github.com/Agoric/agoric-sdk/commit/62589ca7b6d4aaa9eb7042f95ec7aec633db27f9))
|
|
47
|
-
* **telemetry:** initialize empty flight-recorders ([0908258](https://github.com/Agoric/agoric-sdk/commit/0908258c159a18f2bace0f76fa25c485c0460d15))
|
|
48
|
-
* **telemetry:** Launch a slog sender subprocess with the correct environment ([1a60955](https://github.com/Agoric/agoric-sdk/commit/1a60955181f4e8b02b3b0d5a2f213d4cb051d7d3))
|
|
49
|
-
* **telemetry:** otel correctly pop upgrade span ([0ffdf00](https://github.com/Agoric/agoric-sdk/commit/0ffdf001bc8cbdc94081fedfeb4d2376902f4ffc)), closes [#8272](https://github.com/Agoric/agoric-sdk/issues/8272) [#9569](https://github.com/Agoric/agoric-sdk/issues/9569)
|
|
50
|
-
* **telemetry:** silence slogfile write errors ([91089d7](https://github.com/Agoric/agoric-sdk/commit/91089d7273ef3d41555b34d84471120d45602497))
|
|
51
|
-
* **telemetry:** timer-poll run.id ([#10672](https://github.com/Agoric/agoric-sdk/issues/10672)) ([3b478fb](https://github.com/Agoric/agoric-sdk/commit/3b478fb9e3fe7ded8dec1e83bab68760571f9071)), closes [#10357](https://github.com/Agoric/agoric-sdk/issues/10357) [#10357](https://github.com/Agoric/agoric-sdk/issues/10357)
|
|
52
|
-
|
|
53
|
-
### [0.6.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.6.1...@agoric/telemetry@0.6.2) (2023-06-02)
|
|
54
|
-
|
|
55
|
-
**Note:** Version bump only for package @agoric/telemetry
|
|
56
|
-
|
|
57
|
-
### [0.6.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.6.0...@agoric/telemetry@0.6.1) (2023-05-24)
|
|
58
|
-
|
|
59
|
-
**Note:** Version bump only for package @agoric/telemetry
|
|
60
|
-
|
|
61
|
-
## [0.6.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.4.0...@agoric/telemetry@0.6.0) (2023-05-19)
|
|
62
|
-
|
|
63
|
-
### Features
|
|
64
|
-
|
|
65
|
-
* **cosmic-swingset:** basic snapshot wiring ([b1072d8](https://github.com/Agoric/agoric-sdk/commit/b1072d8b1ddabbb5f2835eb503c945fed3b6b080))
|
|
66
|
-
* **telemetry:** add shutdown ([84757ff](https://github.com/Agoric/agoric-sdk/commit/84757ff63c7f603954af9c6e85ce7a819938e5b0))
|
|
67
|
-
* **telemetry:** do not carry span stack corruption across blocks ([16eaa99](https://github.com/Agoric/agoric-sdk/commit/16eaa99caef56b73159b321894aa2dca52846a29))
|
|
68
|
-
* **telemetry:** Expose send errors in forceFlush ([7a9a8c6](https://github.com/Agoric/agoric-sdk/commit/7a9a8c6165d3cb1bc89289faddf355bc04cc9c1f))
|
|
69
|
-
* **telemetry:** fail otel slog sender in more cases ([4549903](https://github.com/Agoric/agoric-sdk/commit/45499031cbb2417d58a50087b857600a96f87fe8))
|
|
70
|
-
* **telemetry:** SLOGSENDER_FAIL_ON_ERROR ([db79fca](https://github.com/Agoric/agoric-sdk/commit/db79fcad8bc784d300acfd994ceab9a2b9c2a567))
|
|
71
|
-
|
|
72
|
-
### Bug Fixes
|
|
73
|
-
|
|
74
|
-
* **telemetry:** do not propagate errors through queue ([601d63b](https://github.com/Agoric/agoric-sdk/commit/601d63b53722bac479ad570e2f7dfc1016dae9c7))
|
|
75
|
-
* **telemetry:** fix various edge cases ([c54d996](https://github.com/Agoric/agoric-sdk/commit/c54d9962deaaefec4f2c9680d58d625644ef9b69))
|
|
76
|
-
* **telemetry:** handle missing syscalls ([0b8475b](https://github.com/Agoric/agoric-sdk/commit/0b8475be8616d81661962c9845315554e58a7f96))
|
|
77
|
-
* **telemetry:** handle paging `create-vat` ([84a7557](https://github.com/Agoric/agoric-sdk/commit/84a75573520b5cc24ba7cc29e054a66d81f06339))
|
|
78
|
-
* **telemetry:** handle smallcaps ([1adc8ce](https://github.com/Agoric/agoric-sdk/commit/1adc8ced2c5d65db8de4992d2273824f79020a2c))
|
|
79
|
-
* **telemetry:** Missing after-commit rename from [#6881](https://github.com/Agoric/agoric-sdk/issues/6881) ([8e211f8](https://github.com/Agoric/agoric-sdk/commit/8e211f8862dea52b1d952c51760d6690a7604d30))
|
|
80
|
-
* **telemetry:** partially undo [#6684](https://github.com/Agoric/agoric-sdk/issues/6684) ([b9fa85b](https://github.com/Agoric/agoric-sdk/commit/b9fa85b7307124e50cc3a84d3b694307cde55f54))
|
|
81
|
-
* **telemetry:** silence pipe sender rejections ([e502f92](https://github.com/Agoric/agoric-sdk/commit/e502f9293ed92b8d705447271aa4f010c6c6dcb6))
|
|
82
|
-
* **telemetry:** upgrade otel deps ([dc48759](https://github.com/Agoric/agoric-sdk/commit/dc4875992937f9648381efae70818fa767d4b901))
|
|
83
|
-
* replace unsafe then with E.when ([#6684](https://github.com/Agoric/agoric-sdk/issues/6684)) ([d7a749e](https://github.com/Agoric/agoric-sdk/commit/d7a749eec4ddec9ba39bbc65434f03ec113cae7c))
|
|
84
|
-
|
|
85
|
-
## [0.5.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.4.0...@agoric/telemetry@0.5.0) (2023-02-17)
|
|
86
|
-
|
|
87
|
-
### Features
|
|
88
|
-
|
|
89
|
-
* **telemetry:** do not carry span stack corruption across blocks ([e150320](https://github.com/Agoric/agoric-sdk/commit/e150320d88ade61b0a7fa0a0c4992988885ad34d))
|
|
90
|
-
|
|
91
|
-
### Bug Fixes
|
|
92
|
-
|
|
93
|
-
* **telemetry:** fix various edge cases ([2c65492](https://github.com/Agoric/agoric-sdk/commit/2c6549289d1c484aff861c061a7730c4b1f284e7))
|
|
94
|
-
* **telemetry:** handle paging `create-vat` ([c9bef2f](https://github.com/Agoric/agoric-sdk/commit/c9bef2f994ddaabf88dac6249f3adbc21fa6b4a0))
|
|
95
|
-
* **telemetry:** upgrade otel deps ([2c9b017](https://github.com/Agoric/agoric-sdk/commit/2c9b017d301048e5782b3b8cf684392e00419221))
|
|
96
|
-
|
|
97
|
-
## [0.4.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.3.0...@agoric/telemetry@0.4.0) (2022-10-05)
|
|
98
|
-
|
|
99
|
-
### Features
|
|
100
|
-
|
|
101
|
-
* **telemetry:** Support slog sender in subprocess ([9fa268f](https://github.com/Agoric/agoric-sdk/commit/9fa268fc9b59d9fb26d829300d7a9d5a768e47bc))
|
|
102
|
-
* **telemetry:** Support SLOGSENDER_AGENT_ env prefix ([e504005](https://github.com/Agoric/agoric-sdk/commit/e50400527a03d32fdf34a30fd29229f98e9baf5c))
|
|
103
|
-
|
|
104
|
-
### Bug Fixes
|
|
105
|
-
|
|
106
|
-
* cleanup, update, and refactor slog-to-otel converter ([225f1dd](https://github.com/Agoric/agoric-sdk/commit/225f1dda46ec99dbc47ba39b3a99e278a4c1adbb)), closes [#4585](https://github.com/Agoric/agoric-sdk/issues/4585)
|
|
107
|
-
* **telemetry:** forceFlush is async ([5cf56b9](https://github.com/Agoric/agoric-sdk/commit/5cf56b9d22a4e9436f1ce1b5020ea68071ef7f55))
|
|
108
|
-
* **telemetry:** further prevent duplication of slog senders ([c7a3fc4](https://github.com/Agoric/agoric-sdk/commit/c7a3fc46526b3ecf05b0f3b2b86983b788467423))
|
|
109
|
-
* **telemetry:** slog sender errors should never propagate ([593aaae](https://github.com/Agoric/agoric-sdk/commit/593aaae57489bb8bfd1217dc995d7d6e4d395ab4))
|
|
110
|
-
|
|
111
|
-
## [0.3.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.2.1...@agoric/telemetry@0.3.0) (2022-09-20)
|
|
112
|
-
|
|
113
|
-
### Features
|
|
114
|
-
|
|
115
|
-
* **cosmic-swingset:** add commit-block slog events ([8335928](https://github.com/Agoric/agoric-sdk/commit/8335928e933b96dc7db78a0895a7582b93ef4f73))
|
|
116
|
-
* **cosmic-swingset:** break up inbound queue processing ([e0d844d](https://github.com/Agoric/agoric-sdk/commit/e0d844da0cae132f63039404c42e5979c12977ce))
|
|
117
|
-
* **telemetry:** `otel-and-flight-recorder.js` for the best of both ([a191b34](https://github.com/Agoric/agoric-sdk/commit/a191b34bd6a4b14f7280b0886fcfd44b5a42b6b5))
|
|
118
|
-
* **telemetry:** flatten nested attributes ([2fc39ca](https://github.com/Agoric/agoric-sdk/commit/2fc39cab8ce3a080c96304af2d772943a653e420))
|
|
119
|
-
|
|
120
|
-
### Bug Fixes
|
|
121
|
-
|
|
122
|
-
* **telemetry:** handle missing slog events ([8e353da](https://github.com/Agoric/agoric-sdk/commit/8e353daf4eceac2eb90fddb6f651bc77f24d299c))
|
|
123
|
-
* Use new `||` assert style, but when TS confused use `if` instead ([#6174](https://github.com/Agoric/agoric-sdk/issues/6174)) ([94625d3](https://github.com/Agoric/agoric-sdk/commit/94625d38c3bb5333b00a69dd3086b1ac13490f62))
|
|
124
|
-
* **kv-string-store:** allow keys to overwrite ([c28b393](https://github.com/Agoric/agoric-sdk/commit/c28b39332c40d4e1def80fee9e7b70588d0c592a))
|
|
125
|
-
* **slog-to-otel:** more `methargs` parsing ([42a9bc0](https://github.com/Agoric/agoric-sdk/commit/42a9bc08dfa66f4653253a9cfc104307b44c908c))
|
|
126
|
-
* **Swingset:** add crank details to slog event ([be1f443](https://github.com/Agoric/agoric-sdk/commit/be1f443bdfd49325316607142f116ca3153e296f))
|
|
127
|
-
* **telemetry:** cleanup slot-to-otel output ([97c695f](https://github.com/Agoric/agoric-sdk/commit/97c695f60fce031bf9307fe8237d3df756d2a4e1))
|
|
128
|
-
* **telemetry:** close store iterator on has check ([6199337](https://github.com/Agoric/agoric-sdk/commit/6199337d40e42ffb4057f5a653f9cecfb21afe3f))
|
|
129
|
-
* **telemetry:** COMMIT should exit the txn ([36bf35c](https://github.com/Agoric/agoric-sdk/commit/36bf35c4daef7a42456aee7d917eba597abeb887))
|
|
130
|
-
* **telemetry:** do not mutate the original slog object ([#5705](https://github.com/Agoric/agoric-sdk/issues/5705)) ([4018a28](https://github.com/Agoric/agoric-sdk/commit/4018a28fcc9ea3ecd28d09e54e5c7cd2d64907b6))
|
|
131
|
-
* **telemetry:** ingest script should not skip lines on time backtrack ([785a5c0](https://github.com/Agoric/agoric-sdk/commit/785a5c0974ad8ed62501ad6e02245dd77d7c7815))
|
|
132
|
-
* **telemetry:** Use transactions for tmp telemetry DB ([dea1a2a](https://github.com/Agoric/agoric-sdk/commit/dea1a2ac31586cf16216e57162ad2951f07dc178))
|
|
133
|
-
|
|
134
|
-
### [0.2.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.2.0...@agoric/telemetry@0.2.1) (2022-05-28)
|
|
135
|
-
|
|
136
|
-
### Bug Fixes
|
|
137
|
-
|
|
138
|
-
* **slog-to-otel:** ignore `vatstoreGetAfter` syscall ([7baed8e](https://github.com/Agoric/agoric-sdk/commit/7baed8ea1c7513d57bd33edb8c4b6a80dd5182ed))
|
|
139
|
-
|
|
140
|
-
## [0.2.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.1.1...@agoric/telemetry@0.2.0) (2022-04-18)
|
|
141
|
-
|
|
142
|
-
### ⚠ BREAKING CHANGES
|
|
143
|
-
|
|
144
|
-
* consistent Node engine requirement (>=14.15.0)
|
|
145
|
-
|
|
146
|
-
### Features
|
|
147
|
-
|
|
148
|
-
* **telemetry:** `echo 2022-02-18T12:00:00Z | ./ingest.sh f.slog` ([bede363](https://github.com/Agoric/agoric-sdk/commit/bede363018656bad32b6764a5216acaaf2ca19bc))
|
|
149
|
-
* **telemetry:** upgrade to latest `[@opentelemetry](https://github.com/opentelemetry)` ([de82224](https://github.com/Agoric/agoric-sdk/commit/de82224eb08a40e139f20e74d6f1038e50fbfa40))
|
|
150
|
-
|
|
151
|
-
### Bug Fixes
|
|
152
|
-
|
|
153
|
-
* **telemetry:** clean up scripts and leave pointers ([1830c55](https://github.com/Agoric/agoric-sdk/commit/1830c55edeb814b79f25f9fbacdbebbac7c2a26f))
|
|
154
|
-
* **telemetry:** count work duration per block, not between blocks ([b95a124](https://github.com/Agoric/agoric-sdk/commit/b95a124d17fca6edf04232f8e3a7eeef196e5b43))
|
|
155
|
-
* **telemetry:** ingest rate limiting ([fd164c8](https://github.com/Agoric/agoric-sdk/commit/fd164c82d56f416309071b85c60da1af34af7821))
|
|
156
|
-
* **telemetry:** rework Prometheus metrics ([38a1922](https://github.com/Agoric/agoric-sdk/commit/38a1922ce2c21e4f31b4a1bedd634bbe627990f9))
|
|
157
|
-
|
|
158
|
-
### Miscellaneous Chores
|
|
159
|
-
|
|
160
|
-
* consistent Node engine requirement (>=14.15.0) ([ddc40fa](https://github.com/Agoric/agoric-sdk/commit/ddc40fa525f845ed900512c38b99f01458a3d131))
|
|
161
|
-
|
|
162
|
-
### 0.1.1 (2022-02-21)
|
|
163
|
-
|
|
164
|
-
### Features
|
|
165
|
-
|
|
166
|
-
* **telemetry:** `frcat` script to extract `flight-recorder.bin` ([7ee4091](https://github.com/Agoric/agoric-sdk/commit/7ee409102269ab41a1f3f5d5a0bdd29b6eb12a36))
|
|
167
|
-
* **telemetry:** add `@agoric/telemetry/src/flight-recorder.js` ([b02b0c8](https://github.com/Agoric/agoric-sdk/commit/b02b0c8086136d8e780b687ae65df41796946eec))
|
|
168
|
-
* **telemetry:** introduce for opentelemetry.io integration ([4e382dc](https://github.com/Agoric/agoric-sdk/commit/4e382dcede81717a4c9941266b0377ad531b8b38))
|
|
169
|
-
* **telemetry:** use `makeSlogSenderFromModule` ([2892da9](https://github.com/Agoric/agoric-sdk/commit/2892da96eff902c5f616424d6fb9946aaaef1b0f))
|
|
170
|
-
|
|
171
|
-
### Bug Fixes
|
|
172
|
-
|
|
173
|
-
* Remove extraneous eslint globals ([17087e4](https://github.com/Agoric/agoric-sdk/commit/17087e4605db7d3b30dfccf2434b2850b45e3408))
|
|
174
|
-
* **telemetry:** make flight recorder big-endian on all platforms ([bfe877e](https://github.com/Agoric/agoric-sdk/commit/bfe877e8825d551b9ea6f80e2623fb450883dab0))
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# Start with https://opentelemetry.io/docs/collector/
|
|
2
|
-
# Then, run ./scripts/otelcol.sh to start the collector and look in the ./data directory.
|
|
3
|
-
receivers:
|
|
4
|
-
# Data sources: metrics
|
|
5
|
-
hostmetrics:
|
|
6
|
-
scrapers:
|
|
7
|
-
cpu:
|
|
8
|
-
disk:
|
|
9
|
-
filesystem:
|
|
10
|
-
load:
|
|
11
|
-
memory:
|
|
12
|
-
network:
|
|
13
|
-
#process:
|
|
14
|
-
# mute_process_name_error: true
|
|
15
|
-
processes:
|
|
16
|
-
#swap:
|
|
17
|
-
|
|
18
|
-
docker_stats:
|
|
19
|
-
endpoint: unix:///var/run/docker.sock
|
|
20
|
-
|
|
21
|
-
# Data sources: traces, metrics, logs
|
|
22
|
-
otlp:
|
|
23
|
-
protocols:
|
|
24
|
-
grpc:
|
|
25
|
-
http:
|
|
26
|
-
|
|
27
|
-
prometheus:
|
|
28
|
-
config:
|
|
29
|
-
scrape_configs:
|
|
30
|
-
- job_name: 'agd-containers'
|
|
31
|
-
docker_sd_configs:
|
|
32
|
-
- host: unix:///var/run/docker.sock
|
|
33
|
-
refresh_interval: 5s
|
|
34
|
-
relabel_configs:
|
|
35
|
-
- source_labels: [__meta_docker_port_private]
|
|
36
|
-
regex: (26660|9464|9465)
|
|
37
|
-
action: keep
|
|
38
|
-
- source_labels: [__meta_docker_port_private]
|
|
39
|
-
regex: (26660|9464)
|
|
40
|
-
target_label: service_name
|
|
41
|
-
replacement: agd-cosmos
|
|
42
|
-
- source_labels: [__meta_docker_port_private]
|
|
43
|
-
regex: 9465
|
|
44
|
-
target_label: service_name
|
|
45
|
-
replacement: solo
|
|
46
|
-
- source_labels: [__meta_docker_container_name]
|
|
47
|
-
# Extract the SDK revision.
|
|
48
|
-
regex: .*-(.*)
|
|
49
|
-
target_label: service_version
|
|
50
|
-
scrape_interval: 5s
|
|
51
|
-
- job_name: 'otelcol'
|
|
52
|
-
scrape_interval: 5s
|
|
53
|
-
static_configs:
|
|
54
|
-
- targets: ['localhost:8888']
|
|
55
|
-
|
|
56
|
-
processors:
|
|
57
|
-
batch:
|
|
58
|
-
timeout: 10s
|
|
59
|
-
resourcedetection:
|
|
60
|
-
detectors: [system]
|
|
61
|
-
|
|
62
|
-
extensions:
|
|
63
|
-
zpages:
|
|
64
|
-
endpoint: :55679
|
|
65
|
-
health_check:
|
|
66
|
-
|
|
67
|
-
exporters:
|
|
68
|
-
file/data:
|
|
69
|
-
path: /data/otel-export.json
|
|
70
|
-
|
|
71
|
-
prometheus:
|
|
72
|
-
endpoint: '0.0.0.0:9411'
|
|
73
|
-
# namespace: "default"
|
|
74
|
-
resource_to_telemetry_conversion:
|
|
75
|
-
enabled: true
|
|
76
|
-
|
|
77
|
-
logging:
|
|
78
|
-
loglevel: debug
|
|
79
|
-
|
|
80
|
-
service:
|
|
81
|
-
# telemetry:
|
|
82
|
-
# logs:
|
|
83
|
-
# level: "debug"
|
|
84
|
-
extensions: [zpages, health_check]
|
|
85
|
-
pipelines:
|
|
86
|
-
# metrics:
|
|
87
|
-
# receivers: [hostmetrics, otlp, prometheus]
|
|
88
|
-
# processors: [batch, resourcedetection]
|
|
89
|
-
# exporters: [prometheus, otlp/uptrace, datadog/api]
|
|
90
|
-
traces:
|
|
91
|
-
receivers: [otlp]
|
|
92
|
-
processors: [batch, resourcedetection]
|
|
93
|
-
#exporters: [otlp/honeycomb, otlp/uptrace, datadog/api]
|
|
94
|
-
exporters: [file/data]
|
package/scripts/ingest.sh
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#! /bin/bash
|
|
2
|
-
# Send a `.slog` or `.slog.gz` to the OpenTelemetry Collector.
|
|
3
|
-
# Run with INGEST_START='' to start ingesting using slogfile timestamps.
|
|
4
|
-
|
|
5
|
-
set -ue
|
|
6
|
-
thisdir=$(dirname -- "${BASH_SOURCE[0]}")
|
|
7
|
-
|
|
8
|
-
# These three lines enable Agoric SDK's OpenTelemetry tracing.
|
|
9
|
-
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
|
|
10
|
-
export SLOGSENDER=@agoric/telemetry/src/otel-trace.js
|
|
11
|
-
export OTEL_RESOURCE_ATTRIBUTES=ingest.file="$1"
|
|
12
|
-
|
|
13
|
-
PROGRESS="$1.ingest-progress"
|
|
14
|
-
|
|
15
|
-
if [[ ! -s "$PROGRESS" ]]; then
|
|
16
|
-
if [[ "${INGEST_START+set}" != set ]]; then
|
|
17
|
-
read -e -r -p 'Target start time [default=actual from slog] (%Y-%m-%dT%H:%M:%SZ): ' INGEST_START
|
|
18
|
-
fi
|
|
19
|
-
if [[ -n "$INGEST_START" ]]; then
|
|
20
|
-
case "$1" in
|
|
21
|
-
*.Z | *.gz) firstline=$(zcat "$1" | head -1) ;;
|
|
22
|
-
*) firstline=$(head -1 "$1") ;;
|
|
23
|
-
esac
|
|
24
|
-
echo "$firstline" | jq --arg targetStart "$INGEST_START" \
|
|
25
|
-
'{virtualTimeOffset: (($targetStart | fromdate) - .time), lastSlogTime: 0}' \
|
|
26
|
-
> "$PROGRESS"
|
|
27
|
-
fi
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
time exec "$thisdir/../bin/ingest-slog" "$1"
|
package/scripts/otelcol.sh
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#! /bin/bash
|
|
2
|
-
# Have a look at ../sample-otel-collector.yaml for tips on configuration.
|
|
3
|
-
set -ueo pipefail
|
|
4
|
-
thisdir=$(dirname -- "${BASH_SOURCE[0]}")
|
|
5
|
-
|
|
6
|
-
# Make ./data to contain the otel-collector.yaml and any data file outputs.
|
|
7
|
-
mkdir -p data
|
|
8
|
-
OTELCOL_CONFIG="data/otel-collector.yaml"
|
|
9
|
-
test -f "$OTELCOL_CONFIG" || cp "$thisdir/../sample-otel-collector.yaml" "$OTELCOL_CONFIG"
|
|
10
|
-
|
|
11
|
-
# Run a Docker container to collect telemetry data.
|
|
12
|
-
docker run -p4318:4318 --rm -i -v"$PWD"/data:/data \
|
|
13
|
-
otel/opentelemetry-collector-contrib --config="/$OTELCOL_CONFIG"
|
|
14
|
-
#watch ls -l data
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import tmp from 'tmp';
|
|
3
|
-
import { test } from './prepare-test-env-ava.js';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
makeSimpleCircularBuffer,
|
|
7
|
-
makeSlogSenderFromBuffer,
|
|
8
|
-
} from '../src/flight-recorder.js';
|
|
9
|
-
|
|
10
|
-
// Factored this way to support multiple implementations, which at one point there were
|
|
11
|
-
const bufferTests = test.macro(
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param {*} t
|
|
15
|
-
* @param {{makeBuffer: typeof makeSimpleCircularBuffer}} input
|
|
16
|
-
*/
|
|
17
|
-
async (t, input) => {
|
|
18
|
-
const BUFFER_SIZE = 512;
|
|
19
|
-
|
|
20
|
-
const { name: tmpFile, removeCallback } = tmp.fileSync({
|
|
21
|
-
discardDescriptor: true,
|
|
22
|
-
});
|
|
23
|
-
t.teardown(removeCallback);
|
|
24
|
-
const { fileHandle, readCircBuf, writeCircBuf } = await input.makeBuffer({
|
|
25
|
-
circularBufferSize: BUFFER_SIZE,
|
|
26
|
-
circularBufferFilename: tmpFile,
|
|
27
|
-
});
|
|
28
|
-
const realSlogSender = makeSlogSenderFromBuffer({
|
|
29
|
-
fileHandle,
|
|
30
|
-
writeCircBuf,
|
|
31
|
-
});
|
|
32
|
-
let wasShutdown = false;
|
|
33
|
-
const shutdown = () => {
|
|
34
|
-
if (wasShutdown) return;
|
|
35
|
-
wasShutdown = true;
|
|
36
|
-
|
|
37
|
-
return realSlogSender.shutdown();
|
|
38
|
-
};
|
|
39
|
-
t.teardown(shutdown);
|
|
40
|
-
// To verify lack of attempted mutation by the consumer, send only hardened
|
|
41
|
-
// entries.
|
|
42
|
-
/** @type {typeof realSlogSender} */
|
|
43
|
-
const slogSender = Object.assign(
|
|
44
|
-
(obj, serialized) => realSlogSender(harden(obj), serialized),
|
|
45
|
-
realSlogSender,
|
|
46
|
-
);
|
|
47
|
-
slogSender({ type: 'start' });
|
|
48
|
-
await slogSender.forceFlush();
|
|
49
|
-
t.is(fs.readFileSync(tmpFile, { encoding: 'utf8' }).length, BUFFER_SIZE);
|
|
50
|
-
|
|
51
|
-
const len0 = new Uint8Array(BigUint64Array.BYTES_PER_ELEMENT);
|
|
52
|
-
const { done: done0 } = await readCircBuf(len0);
|
|
53
|
-
t.false(done0, 'readCircBuf should not be done');
|
|
54
|
-
const dv0 = new DataView(len0.buffer);
|
|
55
|
-
const buf0 = new Uint8Array(Number(dv0.getBigUint64(0)));
|
|
56
|
-
const { done: done0b } = await readCircBuf(buf0, len0.byteLength);
|
|
57
|
-
t.false(done0b, 'readCircBuf should not be done');
|
|
58
|
-
const buf0Str = new TextDecoder().decode(buf0);
|
|
59
|
-
t.is(buf0Str, `\n{"type":"start"}`, `start compare failed`);
|
|
60
|
-
|
|
61
|
-
const last = 500;
|
|
62
|
-
for (let i = 0; i < last; i += 1) {
|
|
63
|
-
slogSender({ type: 'iteration', iteration: i });
|
|
64
|
-
await slogSender.forceFlush();
|
|
65
|
-
t.is(
|
|
66
|
-
fs.readFileSync(tmpFile, { encoding: 'utf8' }).length,
|
|
67
|
-
BUFFER_SIZE,
|
|
68
|
-
`iteration ${i} length mismatch`,
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let offset = 0;
|
|
73
|
-
const len1 = new Uint8Array(BigUint64Array.BYTES_PER_ELEMENT);
|
|
74
|
-
for (let i = 490; i < last; i += 1) {
|
|
75
|
-
const { done: done1 } = await readCircBuf(len1, offset);
|
|
76
|
-
offset += len1.byteLength;
|
|
77
|
-
t.false(done1, `readCircBuf ${i} should not be done`);
|
|
78
|
-
const dv1 = new DataView(len1.buffer);
|
|
79
|
-
const buf1 = new Uint8Array(Number(dv1.getBigUint64(0)));
|
|
80
|
-
const { done: done1b } = await readCircBuf(buf1, offset);
|
|
81
|
-
offset += buf1.byteLength;
|
|
82
|
-
t.false(done1b, `readCircBuf ${i} should not be done`);
|
|
83
|
-
const buf1Str = new TextDecoder().decode(buf1);
|
|
84
|
-
t.is(
|
|
85
|
-
buf1Str,
|
|
86
|
-
`\n{"type":"iteration","iteration":${i}}`,
|
|
87
|
-
`iteration ${i} compare failed`,
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const { done: done2 } = await readCircBuf(len1, offset);
|
|
92
|
-
t.assert(done2, `readCircBuf ${last} should be done`);
|
|
93
|
-
|
|
94
|
-
slogSender(null, 'PRE-SERIALIZED');
|
|
95
|
-
await slogSender.forceFlush();
|
|
96
|
-
t.truthy(fs.readFileSync(tmpFile).includes('PRE-SERIALIZED'));
|
|
97
|
-
|
|
98
|
-
slogSender(null, 'PRE_SHUTDOWN');
|
|
99
|
-
const shutdownP = shutdown();
|
|
100
|
-
slogSender(null, 'POST_SHUTDOWN');
|
|
101
|
-
await shutdownP;
|
|
102
|
-
slogSender(null, 'SHUTDOWN_COMPLETED');
|
|
103
|
-
|
|
104
|
-
const finalContent = fs.readFileSync(tmpFile);
|
|
105
|
-
|
|
106
|
-
t.truthy(finalContent.includes('PRE_SHUTDOWN'));
|
|
107
|
-
t.falsy(finalContent.includes('POST_SHUTDOWN'));
|
|
108
|
-
t.falsy(finalContent.includes('SHUTDOWN_COMPLETED'));
|
|
109
|
-
},
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
test('simple', bufferTests, {
|
|
113
|
-
makeBuffer: makeSimpleCircularBuffer,
|
|
114
|
-
});
|
package/test/import.test.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/* global setTimeout */
|
|
2
|
-
import { test } from './prepare-test-env-ava.js';
|
|
3
|
-
|
|
4
|
-
import { getTelemetryProviders } from '../src/index.js';
|
|
5
|
-
|
|
6
|
-
const sleep = timeoutMs =>
|
|
7
|
-
new Promise(resolve => setTimeout(resolve, timeoutMs));
|
|
8
|
-
|
|
9
|
-
test('get telemetry providers', async t => {
|
|
10
|
-
const logged = [];
|
|
11
|
-
const mockConsole = {
|
|
12
|
-
warn: (...args) => {
|
|
13
|
-
logged.push(args);
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
const providers = getTelemetryProviders({ console: mockConsole, env: {} });
|
|
17
|
-
t.is(providers.metricsProvider, undefined);
|
|
18
|
-
|
|
19
|
-
t.deepEqual(logged, []);
|
|
20
|
-
await sleep(250);
|
|
21
|
-
t.deepEqual(logged, []);
|
|
22
|
-
|
|
23
|
-
const providers2 = getTelemetryProviders({
|
|
24
|
-
console: mockConsole,
|
|
25
|
-
env: { OTEL_EXPORTER_PROMETHEUS_PORT: '9393' },
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
t.is(Object(providers2.metricsProvider), providers2.metricsProvider);
|
|
29
|
-
t.is(typeof providers2.metricsProvider, 'object');
|
|
30
|
-
|
|
31
|
-
t.deepEqual(logged, []);
|
|
32
|
-
await sleep(250);
|
|
33
|
-
t.deepEqual(logged, [
|
|
34
|
-
['Prometheus scrape endpoint: http://0.0.0.0:9393/metrics'],
|
|
35
|
-
]);
|
|
36
|
-
});
|