@agoric/telemetry 0.6.3-other-dev-d15096d.0.d15096d → 0.6.3-other-dev-ecf44df.0.ecf44df
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 +20 -28
- package/src/block-slog.js +155 -0
- package/src/context-aware-slog-file.js +0 -2
- package/src/context-aware-slog.js +10 -8
- package/src/flight-recorder.js +0 -1
- package/src/frcat-entrypoint.js +0 -1
- package/src/index.js +0 -1
- package/src/ingest-slog-entrypoint.js +8 -9
- package/src/kv-string-store.js +7 -2
- package/src/make-slog-sender.js +1 -1
- package/src/otel-context-aware-slog.js +1 -2
- package/src/slog-sender-pipe-entrypoint.js +1 -4
- package/src/slog-sender-pipe.js +4 -6
- package/src/slog-to-otel.js +1 -0
- package/CHANGELOG.md +0 -161
- 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.6.3-other-dev-
|
|
3
|
+
"version": "0.6.3-other-dev-ecf44df.0.ecf44df",
|
|
4
4
|
"description": "Agoric's telemetry implementation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/Agoric/agoric-sdk",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"test:xs": "exit 0",
|
|
13
13
|
"lint-fix": "yarn lint:eslint --fix",
|
|
14
14
|
"lint": "yarn run -T run-s --continue-on-error 'lint:*'",
|
|
15
|
-
"lint:types": "yarn run -T
|
|
16
|
-
"lint:eslint": "
|
|
15
|
+
"lint:types": "yarn run -T tsgo --tsBuildInfoFile tsconfig.tsgo.tsbuildinfo",
|
|
16
|
+
"lint:eslint": "node ../../scripts/eslint-repo.mjs ."
|
|
17
17
|
},
|
|
18
18
|
"bin": {
|
|
19
19
|
"frcat": "./src/frcat-entrypoint.js"
|
|
@@ -22,13 +22,13 @@
|
|
|
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-
|
|
27
|
-
"@endo/errors": "^1.
|
|
28
|
-
"@endo/init": "^1.1.
|
|
29
|
-
"@endo/marshal": "^1.
|
|
30
|
-
"@endo/promise-kit": "^1.1
|
|
31
|
-
"@endo/stream": "^1.
|
|
25
|
+
"@agoric/internal": "0.3.3-other-dev-ecf44df.0.ecf44df",
|
|
26
|
+
"@agoric/store": "0.9.3-other-dev-ecf44df.0.ecf44df",
|
|
27
|
+
"@endo/errors": "^1.3.1",
|
|
28
|
+
"@endo/init": "^1.1.13",
|
|
29
|
+
"@endo/marshal": "^1.10.0",
|
|
30
|
+
"@endo/promise-kit": "^1.2.1",
|
|
31
|
+
"@endo/stream": "^1.3.1",
|
|
32
32
|
"@opentelemetry/api": "~1.9.0",
|
|
33
33
|
"@opentelemetry/api-logs": "0.57.1",
|
|
34
34
|
"@opentelemetry/exporter-logs-otlp-http": "0.57.1",
|
|
@@ -39,35 +39,27 @@
|
|
|
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
|
-
"
|
|
43
|
-
"better-sqlite3": "^10.1.0",
|
|
42
|
+
"better-sqlite3": "^12.10.0",
|
|
44
43
|
"tmp": "^0.2.1"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
|
-
"@endo/lockdown": "^1.0.
|
|
48
|
-
"@endo/ses-ava": "^1.
|
|
49
|
-
"ava": "^
|
|
46
|
+
"@endo/lockdown": "^1.0.19",
|
|
47
|
+
"@endo/ses-ava": "^1.4.2",
|
|
48
|
+
"ava": "^8.0.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
|
},
|
|
56
58
|
"engines": {
|
|
57
|
-
"node": "^
|
|
58
|
-
},
|
|
59
|
-
"ava": {
|
|
60
|
-
"files": [
|
|
61
|
-
"test/**/*.test.*"
|
|
62
|
-
],
|
|
63
|
-
"require": [
|
|
64
|
-
"@endo/init/debug.js"
|
|
65
|
-
],
|
|
66
|
-
"timeout": "20m",
|
|
67
|
-
"workerThreads": false
|
|
59
|
+
"node": "^22.11 || ^24.14"
|
|
68
60
|
},
|
|
69
61
|
"typeCoverage": {
|
|
70
|
-
"atLeast": 89.
|
|
62
|
+
"atLeast": 89.52
|
|
71
63
|
},
|
|
72
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "ecf44df5eadcc7a1d68745f056fca19155fb5231"
|
|
73
65
|
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { open } from 'node:fs/promises';
|
|
2
|
+
import { createGzip } from 'node:zlib';
|
|
3
|
+
import { SLOG_TYPES } from './context-aware-slog.js';
|
|
4
|
+
import { serializeSlogObj } from './serialize-slog-obj.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @import {Slog} from '@agoric/telemetry/src/context-aware-slog.js';
|
|
8
|
+
* @import {MakeSlogSenderOptions} from '@agoric/telemetry/src/index.js';
|
|
9
|
+
* @import {WriteStream} from 'node:fs';
|
|
10
|
+
* @import {FileHandle} from 'node:fs/promises';
|
|
11
|
+
* @import {Gzip} from 'node:zlib';
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {MakeSlogSenderOptions} options
|
|
16
|
+
*/
|
|
17
|
+
export const makeSlogSender = async options => {
|
|
18
|
+
const { CONTEXTUAL_BLOCK_SLOGS } = options.env || {};
|
|
19
|
+
if (!(options.stateDir || CONTEXTUAL_BLOCK_SLOGS))
|
|
20
|
+
return console.error(
|
|
21
|
+
'Ignoring invocation of slogger "block-slog" without the presence of "stateDir" or "CONTEXTUAL_BLOCK_SLOGS"',
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
let chainedPromises = Promise.resolve();
|
|
25
|
+
/**
|
|
26
|
+
* @type {FileHandle | null}
|
|
27
|
+
*/
|
|
28
|
+
let currentFileHandle = null;
|
|
29
|
+
/**
|
|
30
|
+
* @type {WriteStream | null}
|
|
31
|
+
*/
|
|
32
|
+
let currentFileStream = null;
|
|
33
|
+
/**
|
|
34
|
+
* @type {Gzip | null}
|
|
35
|
+
*/
|
|
36
|
+
let currentStream = null;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param {Array<() => Promise<void>>} promises
|
|
40
|
+
*/
|
|
41
|
+
const chainPromises = (...promises) => {
|
|
42
|
+
for (const promise of promises)
|
|
43
|
+
chainedPromises = chainedPromises.then(promise);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const closeStream = () =>
|
|
47
|
+
currentStream
|
|
48
|
+
? chainPromises(
|
|
49
|
+
() =>
|
|
50
|
+
new Promise(resolve =>
|
|
51
|
+
// @ts-expect-error
|
|
52
|
+
currentStream.end(() => currentStream.once('finish', resolve)),
|
|
53
|
+
),
|
|
54
|
+
() =>
|
|
55
|
+
// @ts-expect-error
|
|
56
|
+
new Promise(resolve => currentFileStream.once('finish', resolve)),
|
|
57
|
+
async () => {
|
|
58
|
+
currentStream = null;
|
|
59
|
+
currentFileStream = null;
|
|
60
|
+
currentFileHandle = null;
|
|
61
|
+
},
|
|
62
|
+
)
|
|
63
|
+
: console.error('No stream to close');
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @param {string} fileName
|
|
67
|
+
*/
|
|
68
|
+
const createStream = async fileName => {
|
|
69
|
+
if (currentStream) throw Error('Stream already open');
|
|
70
|
+
|
|
71
|
+
const filePath = `${options.stateDir || CONTEXTUAL_BLOCK_SLOGS}/slogfile_${fileName}.gz`;
|
|
72
|
+
currentFileHandle = await open(filePath, 'w');
|
|
73
|
+
currentFileStream = currentFileHandle.createWriteStream();
|
|
74
|
+
currentStream = createGzip();
|
|
75
|
+
currentStream.pipe(currentFileStream);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {Slog} slog
|
|
80
|
+
*/
|
|
81
|
+
const slogSender = slog => {
|
|
82
|
+
const { blockHeight, type: slogType } = slog;
|
|
83
|
+
|
|
84
|
+
switch (slogType) {
|
|
85
|
+
case SLOG_TYPES.KERNEL.INIT.START: {
|
|
86
|
+
chainPromises(() => createStream(`init_${new Date().getTime()}`));
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case SLOG_TYPES.COSMIC_SWINGSET.BOOTSTRAP_BLOCK.START: {
|
|
90
|
+
chainPromises(() => createStream(`bootstrap_${new Date().getTime()}`));
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case SLOG_TYPES.COSMIC_SWINGSET.UPGRADE.START: {
|
|
94
|
+
chainPromises(() => createStream(`upgrade_${new Date().getTime()}`));
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case SLOG_TYPES.COSMIC_SWINGSET.BEGIN_BLOCK: {
|
|
98
|
+
chainPromises(() =>
|
|
99
|
+
createStream(`block_${blockHeight}_${new Date().getTime()}`),
|
|
100
|
+
);
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
default: {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
chainPromises(() => writeSlogToStream(slog));
|
|
109
|
+
|
|
110
|
+
switch (slogType) {
|
|
111
|
+
case SLOG_TYPES.KERNEL.INIT.FINISH:
|
|
112
|
+
case SLOG_TYPES.COSMIC_SWINGSET.BOOTSTRAP_BLOCK.FINISH:
|
|
113
|
+
case SLOG_TYPES.COSMIC_SWINGSET.UPGRADE.FINISH:
|
|
114
|
+
case SLOG_TYPES.COSMIC_SWINGSET.AFTER_COMMIT_STATS: {
|
|
115
|
+
closeStream();
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
default: {
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @param {Slog} slog
|
|
126
|
+
* @returns {Promise<void>}
|
|
127
|
+
*/
|
|
128
|
+
const writeSlogToStream = slog =>
|
|
129
|
+
new Promise(resolve => {
|
|
130
|
+
if (!currentStream) {
|
|
131
|
+
console.error(`No stream available for slog type "${slog.type}"`);
|
|
132
|
+
resolve();
|
|
133
|
+
} else {
|
|
134
|
+
// eslint-disable-next-line prefer-template
|
|
135
|
+
const message = serializeSlogObj(slog) + '\n';
|
|
136
|
+
|
|
137
|
+
if (!currentStream.write(message)) currentStream.once('drain', resolve);
|
|
138
|
+
else resolve();
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return Object.assign(slogSender, {
|
|
143
|
+
forceFlush: () =>
|
|
144
|
+
chainedPromises.then(
|
|
145
|
+
() =>
|
|
146
|
+
/** @type {Promise<void>} */ (
|
|
147
|
+
new Promise(resolve => currentStream?.flush(resolve))
|
|
148
|
+
),
|
|
149
|
+
),
|
|
150
|
+
shutdown: async () => {
|
|
151
|
+
closeStream();
|
|
152
|
+
await chainedPromises;
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-env node */
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* @typedef {Partial<{
|
|
5
3
|
* 'block.height': Slog['blockHeight'];
|
|
@@ -49,7 +47,7 @@
|
|
|
49
47
|
* }} Slog
|
|
50
48
|
*/
|
|
51
49
|
|
|
52
|
-
const SLOG_TYPES = {
|
|
50
|
+
export const SLOG_TYPES = {
|
|
53
51
|
CLIST: 'clist',
|
|
54
52
|
CONSOLE: 'console',
|
|
55
53
|
COSMIC_SWINGSET: {
|
|
@@ -60,18 +58,22 @@ const SLOG_TYPES = {
|
|
|
60
58
|
START: 'cosmic-swingset-bootstrap-block-start',
|
|
61
59
|
},
|
|
62
60
|
COMMIT: {
|
|
63
|
-
FINISH: 'cosmic-swingset-commit-finish',
|
|
64
|
-
START: 'cosmic-swingset-commit-start',
|
|
61
|
+
FINISH: 'cosmic-swingset-commit-block-finish',
|
|
62
|
+
START: 'cosmic-swingset-commit-block-start',
|
|
65
63
|
},
|
|
66
64
|
END_BLOCK: {
|
|
67
65
|
FINISH: 'cosmic-swingset-end-block-finish',
|
|
68
66
|
START: 'cosmic-swingset-end-block-start',
|
|
69
67
|
},
|
|
70
|
-
|
|
68
|
+
|
|
71
69
|
RUN: {
|
|
72
70
|
FINISH: 'cosmic-swingset-run-finish',
|
|
73
71
|
START: 'cosmic-swingset-run-start',
|
|
74
72
|
},
|
|
73
|
+
UPGRADE: {
|
|
74
|
+
FINISH: 'cosmic-swingset-upgrade-finish',
|
|
75
|
+
START: 'cosmic-swingset-upgrade-start',
|
|
76
|
+
},
|
|
75
77
|
},
|
|
76
78
|
COSMIC_SWINGSET_TRIGGERS: {
|
|
77
79
|
BRIDGE_INBOUND: 'cosmic-swingset-bridge-inbound',
|
|
@@ -227,7 +229,7 @@ export const makeContextualSlogProcessor = (
|
|
|
227
229
|
|
|
228
230
|
break;
|
|
229
231
|
}
|
|
230
|
-
|
|
232
|
+
|
|
231
233
|
case SLOG_TYPES.COSMIC_SWINGSET.RUN.START: {
|
|
232
234
|
if (!finalBody.runNum) {
|
|
233
235
|
assert(!triggerContext);
|
|
@@ -353,7 +355,7 @@ export const makeContextualSlogProcessor = (
|
|
|
353
355
|
blockContext = null;
|
|
354
356
|
break;
|
|
355
357
|
}
|
|
356
|
-
|
|
358
|
+
|
|
357
359
|
case SLOG_TYPES.COSMIC_SWINGSET.RUN.FINISH: {
|
|
358
360
|
assert(!!triggerContext);
|
|
359
361
|
persistContext(
|
package/src/flight-recorder.js
CHANGED
package/src/frcat-entrypoint.js
CHANGED
package/src/index.js
CHANGED
|
@@ -5,7 +5,6 @@ import { Resource } from '@opentelemetry/resources';
|
|
|
5
5
|
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @import {MakeSlogSenderOptions} from './index.js';
|
|
9
8
|
* @import {ResourceAttributes} from '@opentelemetry/resources';
|
|
10
9
|
* @import {View} from '@opentelemetry/sdk-metrics';
|
|
11
10
|
*/
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
/* eslint-env node */
|
|
3
2
|
import '@endo/init';
|
|
4
3
|
|
|
5
|
-
import fs from 'fs';
|
|
6
|
-
import zlib from 'zlib';
|
|
7
|
-
import readline from 'readline';
|
|
8
|
-
import process from 'process';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import zlib from 'node:zlib';
|
|
6
|
+
import readline from 'node:readline';
|
|
7
|
+
import process from 'node:process';
|
|
9
8
|
|
|
10
9
|
import { makeSlogSender } from './make-slog-sender.js';
|
|
11
10
|
|
|
@@ -74,7 +73,7 @@ async function run() {
|
|
|
74
73
|
let blocksInThisPeriod = 0;
|
|
75
74
|
let startOfLastPeriod = 0;
|
|
76
75
|
|
|
77
|
-
let lastTime =
|
|
76
|
+
let lastTime = performance.now();
|
|
78
77
|
let lineCount = 0;
|
|
79
78
|
|
|
80
79
|
const stats = async flush => {
|
|
@@ -109,7 +108,7 @@ async function run() {
|
|
|
109
108
|
progress.lastSlogTime = obj.time;
|
|
110
109
|
}
|
|
111
110
|
|
|
112
|
-
let now =
|
|
111
|
+
let now = performance.now();
|
|
113
112
|
await maybeUpdateStats(now);
|
|
114
113
|
|
|
115
114
|
if (!update) {
|
|
@@ -128,7 +127,7 @@ async function run() {
|
|
|
128
127
|
maybeWait = new Promise(resolve => setTimeout(resolve, delayMS));
|
|
129
128
|
}
|
|
130
129
|
await maybeWait;
|
|
131
|
-
now =
|
|
130
|
+
now = performance.now();
|
|
132
131
|
|
|
133
132
|
if (now - startOfLastPeriod >= PROCESSING_PERIOD) {
|
|
134
133
|
startOfLastPeriod = now;
|
|
@@ -152,7 +151,7 @@ async function run() {
|
|
|
152
151
|
linesProcessedThisPeriod += 1;
|
|
153
152
|
if (isAfterCommit) {
|
|
154
153
|
blocksInThisPeriod += 1;
|
|
155
|
-
lastTime =
|
|
154
|
+
lastTime = performance.now();
|
|
156
155
|
await stats(true);
|
|
157
156
|
}
|
|
158
157
|
}
|
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,3 @@
|
|
|
1
|
-
/* eslint-env node */
|
|
2
1
|
import { logs, SeverityNumber } from '@opentelemetry/api-logs';
|
|
3
2
|
import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
|
|
4
3
|
import { Resource } from '@opentelemetry/resources';
|
|
@@ -6,7 +5,7 @@ import {
|
|
|
6
5
|
LoggerProvider,
|
|
7
6
|
SimpleLogRecordProcessor,
|
|
8
7
|
} from '@opentelemetry/sdk-logs';
|
|
9
|
-
import { readFileSync, writeFileSync } from 'fs';
|
|
8
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
10
9
|
import { makeContextualSlogProcessor } from './context-aware-slog.js';
|
|
11
10
|
import { getResourceAttributes } from './index.js';
|
|
12
11
|
import { serializeSlogObj } from './serialize-slog-obj.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-env node */
|
|
2
1
|
/**
|
|
3
2
|
* @file Run as a child process of {@link ./slog-sender-pipe.js} to isolate an
|
|
4
3
|
* aggregate slog sender (@see {@link ./make-slog-sender.js}). Communicates
|
|
@@ -9,7 +8,7 @@
|
|
|
9
8
|
|
|
10
9
|
import '@endo/init';
|
|
11
10
|
|
|
12
|
-
import anylogger from 'anylogger';
|
|
11
|
+
import anylogger from '@agoric/internal/vendor/anylogger.js';
|
|
13
12
|
import { Fail } from '@endo/errors';
|
|
14
13
|
import { makeShutdown } from '@agoric/internal/src/node/shutdown.js';
|
|
15
14
|
|
|
@@ -21,8 +20,6 @@ import { makeSlogSender } from './make-slog-sender.js';
|
|
|
21
20
|
* @import {SlogSender} from './index.js';
|
|
22
21
|
*/
|
|
23
22
|
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
25
|
-
// @ts-ignore TODO remove when anylogger has types
|
|
26
23
|
const logger = anylogger('slog-sender-pipe-entrypoint');
|
|
27
24
|
|
|
28
25
|
/** @type {(msg: PipeAPIReply) => void} */
|
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';
|
|
@@ -26,8 +26,6 @@ import { makeShutdown } from '@agoric/internal/src/node/shutdown.js';
|
|
|
26
26
|
|
|
27
27
|
const dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
28
28
|
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
30
|
-
// @ts-ignore TODO remove when anylogger has types
|
|
31
29
|
const logger = anylogger('slog-sender-pipe');
|
|
32
30
|
|
|
33
31
|
const sink = () => {};
|
package/src/slog-to-otel.js
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
* @import {SwingSetCapData} from '@agoric/swingset-vat';
|
|
21
21
|
* @import {Message} from '@agoric/swingset-vat';
|
|
22
22
|
* @import {KernelSyscallObject} from '@agoric/swingset-vat';
|
|
23
|
+
* @import {LegacyMap} from '@agoric/store';
|
|
23
24
|
*/
|
|
24
25
|
/** @import {SpanContext, SpanOptions} from '@opentelemetry/api' */
|
|
25
26
|
|
package/CHANGELOG.md
DELETED
|
@@ -1,161 +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.6.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.6.1...@agoric/telemetry@0.6.2) (2023-06-02)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @agoric/telemetry
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
### [0.6.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.6.0...@agoric/telemetry@0.6.1) (2023-05-24)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @agoric/telemetry
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## [0.6.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.4.0...@agoric/telemetry@0.6.0) (2023-05-19)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Features
|
|
26
|
-
|
|
27
|
-
* **cosmic-swingset:** basic snapshot wiring ([b1072d8](https://github.com/Agoric/agoric-sdk/commit/b1072d8b1ddabbb5f2835eb503c945fed3b6b080))
|
|
28
|
-
* **telemetry:** add shutdown ([84757ff](https://github.com/Agoric/agoric-sdk/commit/84757ff63c7f603954af9c6e85ce7a819938e5b0))
|
|
29
|
-
* **telemetry:** do not carry span stack corruption across blocks ([16eaa99](https://github.com/Agoric/agoric-sdk/commit/16eaa99caef56b73159b321894aa2dca52846a29))
|
|
30
|
-
* **telemetry:** Expose send errors in forceFlush ([7a9a8c6](https://github.com/Agoric/agoric-sdk/commit/7a9a8c6165d3cb1bc89289faddf355bc04cc9c1f))
|
|
31
|
-
* **telemetry:** fail otel slog sender in more cases ([4549903](https://github.com/Agoric/agoric-sdk/commit/45499031cbb2417d58a50087b857600a96f87fe8))
|
|
32
|
-
* **telemetry:** SLOGSENDER_FAIL_ON_ERROR ([db79fca](https://github.com/Agoric/agoric-sdk/commit/db79fcad8bc784d300acfd994ceab9a2b9c2a567))
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
### Bug Fixes
|
|
36
|
-
|
|
37
|
-
* **telemetry:** do not propagate errors through queue ([601d63b](https://github.com/Agoric/agoric-sdk/commit/601d63b53722bac479ad570e2f7dfc1016dae9c7))
|
|
38
|
-
* **telemetry:** fix various edge cases ([c54d996](https://github.com/Agoric/agoric-sdk/commit/c54d9962deaaefec4f2c9680d58d625644ef9b69))
|
|
39
|
-
* **telemetry:** handle missing syscalls ([0b8475b](https://github.com/Agoric/agoric-sdk/commit/0b8475be8616d81661962c9845315554e58a7f96))
|
|
40
|
-
* **telemetry:** handle paging `create-vat` ([84a7557](https://github.com/Agoric/agoric-sdk/commit/84a75573520b5cc24ba7cc29e054a66d81f06339))
|
|
41
|
-
* **telemetry:** handle smallcaps ([1adc8ce](https://github.com/Agoric/agoric-sdk/commit/1adc8ced2c5d65db8de4992d2273824f79020a2c))
|
|
42
|
-
* **telemetry:** Missing after-commit rename from [#6881](https://github.com/Agoric/agoric-sdk/issues/6881) ([8e211f8](https://github.com/Agoric/agoric-sdk/commit/8e211f8862dea52b1d952c51760d6690a7604d30))
|
|
43
|
-
* **telemetry:** partially undo [#6684](https://github.com/Agoric/agoric-sdk/issues/6684) ([b9fa85b](https://github.com/Agoric/agoric-sdk/commit/b9fa85b7307124e50cc3a84d3b694307cde55f54))
|
|
44
|
-
* **telemetry:** silence pipe sender rejections ([e502f92](https://github.com/Agoric/agoric-sdk/commit/e502f9293ed92b8d705447271aa4f010c6c6dcb6))
|
|
45
|
-
* **telemetry:** upgrade otel deps ([dc48759](https://github.com/Agoric/agoric-sdk/commit/dc4875992937f9648381efae70818fa767d4b901))
|
|
46
|
-
* replace unsafe then with E.when ([#6684](https://github.com/Agoric/agoric-sdk/issues/6684)) ([d7a749e](https://github.com/Agoric/agoric-sdk/commit/d7a749eec4ddec9ba39bbc65434f03ec113cae7c))
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
## [0.5.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.4.0...@agoric/telemetry@0.5.0) (2023-02-17)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
### Features
|
|
54
|
-
|
|
55
|
-
* **telemetry:** do not carry span stack corruption across blocks ([e150320](https://github.com/Agoric/agoric-sdk/commit/e150320d88ade61b0a7fa0a0c4992988885ad34d))
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
### Bug Fixes
|
|
59
|
-
|
|
60
|
-
* **telemetry:** fix various edge cases ([2c65492](https://github.com/Agoric/agoric-sdk/commit/2c6549289d1c484aff861c061a7730c4b1f284e7))
|
|
61
|
-
* **telemetry:** handle paging `create-vat` ([c9bef2f](https://github.com/Agoric/agoric-sdk/commit/c9bef2f994ddaabf88dac6249f3adbc21fa6b4a0))
|
|
62
|
-
* **telemetry:** upgrade otel deps ([2c9b017](https://github.com/Agoric/agoric-sdk/commit/2c9b017d301048e5782b3b8cf684392e00419221))
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
## [0.4.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.3.0...@agoric/telemetry@0.4.0) (2022-10-05)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
### Features
|
|
70
|
-
|
|
71
|
-
* **telemetry:** Support slog sender in subprocess ([9fa268f](https://github.com/Agoric/agoric-sdk/commit/9fa268fc9b59d9fb26d829300d7a9d5a768e47bc))
|
|
72
|
-
* **telemetry:** Support SLOGSENDER_AGENT_ env prefix ([e504005](https://github.com/Agoric/agoric-sdk/commit/e50400527a03d32fdf34a30fd29229f98e9baf5c))
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
### Bug Fixes
|
|
76
|
-
|
|
77
|
-
* 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)
|
|
78
|
-
* **telemetry:** forceFlush is async ([5cf56b9](https://github.com/Agoric/agoric-sdk/commit/5cf56b9d22a4e9436f1ce1b5020ea68071ef7f55))
|
|
79
|
-
* **telemetry:** further prevent duplication of slog senders ([c7a3fc4](https://github.com/Agoric/agoric-sdk/commit/c7a3fc46526b3ecf05b0f3b2b86983b788467423))
|
|
80
|
-
* **telemetry:** slog sender errors should never propagate ([593aaae](https://github.com/Agoric/agoric-sdk/commit/593aaae57489bb8bfd1217dc995d7d6e4d395ab4))
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
## [0.3.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.2.1...@agoric/telemetry@0.3.0) (2022-09-20)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
### Features
|
|
88
|
-
|
|
89
|
-
* **cosmic-swingset:** add commit-block slog events ([8335928](https://github.com/Agoric/agoric-sdk/commit/8335928e933b96dc7db78a0895a7582b93ef4f73))
|
|
90
|
-
* **cosmic-swingset:** break up inbound queue processing ([e0d844d](https://github.com/Agoric/agoric-sdk/commit/e0d844da0cae132f63039404c42e5979c12977ce))
|
|
91
|
-
* **telemetry:** `otel-and-flight-recorder.js` for the best of both ([a191b34](https://github.com/Agoric/agoric-sdk/commit/a191b34bd6a4b14f7280b0886fcfd44b5a42b6b5))
|
|
92
|
-
* **telemetry:** flatten nested attributes ([2fc39ca](https://github.com/Agoric/agoric-sdk/commit/2fc39cab8ce3a080c96304af2d772943a653e420))
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
### Bug Fixes
|
|
96
|
-
|
|
97
|
-
* **telemetry:** handle missing slog events ([8e353da](https://github.com/Agoric/agoric-sdk/commit/8e353daf4eceac2eb90fddb6f651bc77f24d299c))
|
|
98
|
-
* 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))
|
|
99
|
-
* **kv-string-store:** allow keys to overwrite ([c28b393](https://github.com/Agoric/agoric-sdk/commit/c28b39332c40d4e1def80fee9e7b70588d0c592a))
|
|
100
|
-
* **slog-to-otel:** more `methargs` parsing ([42a9bc0](https://github.com/Agoric/agoric-sdk/commit/42a9bc08dfa66f4653253a9cfc104307b44c908c))
|
|
101
|
-
* **Swingset:** add crank details to slog event ([be1f443](https://github.com/Agoric/agoric-sdk/commit/be1f443bdfd49325316607142f116ca3153e296f))
|
|
102
|
-
* **telemetry:** cleanup slot-to-otel output ([97c695f](https://github.com/Agoric/agoric-sdk/commit/97c695f60fce031bf9307fe8237d3df756d2a4e1))
|
|
103
|
-
* **telemetry:** close store iterator on has check ([6199337](https://github.com/Agoric/agoric-sdk/commit/6199337d40e42ffb4057f5a653f9cecfb21afe3f))
|
|
104
|
-
* **telemetry:** COMMIT should exit the txn ([36bf35c](https://github.com/Agoric/agoric-sdk/commit/36bf35c4daef7a42456aee7d917eba597abeb887))
|
|
105
|
-
* **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))
|
|
106
|
-
* **telemetry:** ingest script should not skip lines on time backtrack ([785a5c0](https://github.com/Agoric/agoric-sdk/commit/785a5c0974ad8ed62501ad6e02245dd77d7c7815))
|
|
107
|
-
* **telemetry:** Use transactions for tmp telemetry DB ([dea1a2a](https://github.com/Agoric/agoric-sdk/commit/dea1a2ac31586cf16216e57162ad2951f07dc178))
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
### [0.2.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.2.0...@agoric/telemetry@0.2.1) (2022-05-28)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
### Bug Fixes
|
|
115
|
-
|
|
116
|
-
* **slog-to-otel:** ignore `vatstoreGetAfter` syscall ([7baed8e](https://github.com/Agoric/agoric-sdk/commit/7baed8ea1c7513d57bd33edb8c4b6a80dd5182ed))
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
## [0.2.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/telemetry@0.1.1...@agoric/telemetry@0.2.0) (2022-04-18)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
### ⚠ BREAKING CHANGES
|
|
124
|
-
|
|
125
|
-
* consistent Node engine requirement (>=14.15.0)
|
|
126
|
-
|
|
127
|
-
### Features
|
|
128
|
-
|
|
129
|
-
* **telemetry:** `echo 2022-02-18T12:00:00Z | ./ingest.sh f.slog` ([bede363](https://github.com/Agoric/agoric-sdk/commit/bede363018656bad32b6764a5216acaaf2ca19bc))
|
|
130
|
-
* **telemetry:** upgrade to latest `[@opentelemetry](https://github.com/opentelemetry)` ([de82224](https://github.com/Agoric/agoric-sdk/commit/de82224eb08a40e139f20e74d6f1038e50fbfa40))
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
### Bug Fixes
|
|
134
|
-
|
|
135
|
-
* **telemetry:** clean up scripts and leave pointers ([1830c55](https://github.com/Agoric/agoric-sdk/commit/1830c55edeb814b79f25f9fbacdbebbac7c2a26f))
|
|
136
|
-
* **telemetry:** count work duration per block, not between blocks ([b95a124](https://github.com/Agoric/agoric-sdk/commit/b95a124d17fca6edf04232f8e3a7eeef196e5b43))
|
|
137
|
-
* **telemetry:** ingest rate limiting ([fd164c8](https://github.com/Agoric/agoric-sdk/commit/fd164c82d56f416309071b85c60da1af34af7821))
|
|
138
|
-
* **telemetry:** rework Prometheus metrics ([38a1922](https://github.com/Agoric/agoric-sdk/commit/38a1922ce2c21e4f31b4a1bedd634bbe627990f9))
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
### Miscellaneous Chores
|
|
142
|
-
|
|
143
|
-
* consistent Node engine requirement (>=14.15.0) ([ddc40fa](https://github.com/Agoric/agoric-sdk/commit/ddc40fa525f845ed900512c38b99f01458a3d131))
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
### 0.1.1 (2022-02-21)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
### Features
|
|
151
|
-
|
|
152
|
-
* **telemetry:** `frcat` script to extract `flight-recorder.bin` ([7ee4091](https://github.com/Agoric/agoric-sdk/commit/7ee409102269ab41a1f3f5d5a0bdd29b6eb12a36))
|
|
153
|
-
* **telemetry:** add `@agoric/telemetry/src/flight-recorder.js` ([b02b0c8](https://github.com/Agoric/agoric-sdk/commit/b02b0c8086136d8e780b687ae65df41796946eec))
|
|
154
|
-
* **telemetry:** introduce for opentelemetry.io integration ([4e382dc](https://github.com/Agoric/agoric-sdk/commit/4e382dcede81717a4c9941266b0377ad531b8b38))
|
|
155
|
-
* **telemetry:** use `makeSlogSenderFromModule` ([2892da9](https://github.com/Agoric/agoric-sdk/commit/2892da96eff902c5f616424d6fb9946aaaef1b0f))
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
### Bug Fixes
|
|
159
|
-
|
|
160
|
-
* Remove extraneous eslint globals ([17087e4](https://github.com/Agoric/agoric-sdk/commit/17087e4605db7d3b30dfccf2434b2850b45e3408))
|
|
161
|
-
* **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
|
-
});
|