@agoric/telemetry 0.6.3-dev-2ede8c1.0 → 0.6.3-dev-7ae1f27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/ingest-slog-entrypoint.js +34 -12
- package/src/slog-file.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/telemetry",
|
|
3
|
-
"version": "0.6.3-dev-
|
|
3
|
+
"version": "0.6.3-dev-7ae1f27.0+7ae1f27",
|
|
4
4
|
"description": "Agoric's telemetry implementation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/Agoric/agoric-sdk",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"author": "Agoric",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@agoric/internal": "0.3.3-dev-
|
|
26
|
-
"@agoric/store": "0.9.3-dev-
|
|
25
|
+
"@agoric/internal": "0.3.3-dev-7ae1f27.0+7ae1f27",
|
|
26
|
+
"@agoric/store": "0.9.3-dev-7ae1f27.0+7ae1f27",
|
|
27
27
|
"@endo/errors": "^1.2.7",
|
|
28
28
|
"@endo/init": "^1.1.6",
|
|
29
29
|
"@endo/marshal": "^1.6.1",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"typeCoverage": {
|
|
66
66
|
"atLeast": 87.03
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "7ae1f278fa8cbeb0cfc777b7cebf507b1f07c958"
|
|
69
69
|
}
|
|
@@ -11,7 +11,8 @@ import { makeSlogSender } from './make-slog-sender.js';
|
|
|
11
11
|
|
|
12
12
|
const LINE_COUNT_TO_FLUSH = 10000;
|
|
13
13
|
const ELAPSED_MS_TO_FLUSH = 3000;
|
|
14
|
-
const MAX_LINE_COUNT_PER_PERIOD =
|
|
14
|
+
const MAX_LINE_COUNT_PER_PERIOD = 10000;
|
|
15
|
+
const MAX_BLOCKS_PER_PERIOD = 10;
|
|
15
16
|
const PROCESSING_PERIOD = 1000;
|
|
16
17
|
|
|
17
18
|
async function run() {
|
|
@@ -29,7 +30,7 @@ async function run() {
|
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
const
|
|
33
|
+
const slogFile = args[0] === '-' ? undefined : args[0];
|
|
33
34
|
const slogSender = await makeSlogSender({
|
|
34
35
|
serviceName,
|
|
35
36
|
stateDir: '.',
|
|
@@ -56,14 +57,21 @@ async function run() {
|
|
|
56
57
|
const lines = readline.createInterface({ input: slogF });
|
|
57
58
|
const slogFileName = slogFile || '*stdin*';
|
|
58
59
|
|
|
59
|
-
const progressFileName = `${slogFileName}.ingest-progress`;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
fs.
|
|
60
|
+
const progressFileName = slogFile && `${slogFileName}.ingest-progress`;
|
|
61
|
+
const progress = { virtualTimeOffset: 0, lastSlogTime: 0 };
|
|
62
|
+
if (progressFileName) {
|
|
63
|
+
if (!fs.existsSync(progressFileName)) {
|
|
64
|
+
fs.writeFileSync(progressFileName, JSON.stringify(progress));
|
|
65
|
+
} else {
|
|
66
|
+
Object.assign(
|
|
67
|
+
progress,
|
|
68
|
+
JSON.parse(fs.readFileSync(progressFileName).toString()),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
63
71
|
}
|
|
64
|
-
const progress = JSON.parse(fs.readFileSync(progressFileName).toString());
|
|
65
72
|
|
|
66
73
|
let linesProcessedThisPeriod = 0;
|
|
74
|
+
let blocksInThisPeriod = 0;
|
|
67
75
|
let startOfLastPeriod = 0;
|
|
68
76
|
|
|
69
77
|
let lastTime = Date.now();
|
|
@@ -75,10 +83,12 @@ async function run() {
|
|
|
75
83
|
return;
|
|
76
84
|
}
|
|
77
85
|
await slogSender.forceFlush?.();
|
|
78
|
-
|
|
86
|
+
if (progressFileName) {
|
|
87
|
+
fs.writeFileSync(progressFileName, JSON.stringify(progress));
|
|
88
|
+
}
|
|
79
89
|
};
|
|
80
90
|
|
|
81
|
-
console.
|
|
91
|
+
console.warn(`parsing`, slogFileName);
|
|
82
92
|
|
|
83
93
|
let update = false;
|
|
84
94
|
const maybeUpdateStats = async now => {
|
|
@@ -106,9 +116,14 @@ async function run() {
|
|
|
106
116
|
continue;
|
|
107
117
|
}
|
|
108
118
|
|
|
119
|
+
const isAfterCommit = obj.type === 'cosmic-swingset-after-commit-stats';
|
|
120
|
+
|
|
109
121
|
// Maybe wait for the next period to process a bunch of lines.
|
|
110
122
|
let maybeWait;
|
|
111
|
-
if (
|
|
123
|
+
if (
|
|
124
|
+
linesProcessedThisPeriod >= MAX_LINE_COUNT_PER_PERIOD ||
|
|
125
|
+
blocksInThisPeriod >= MAX_BLOCKS_PER_PERIOD
|
|
126
|
+
) {
|
|
112
127
|
const delayMS = PROCESSING_PERIOD - (now - startOfLastPeriod);
|
|
113
128
|
maybeWait = new Promise(resolve => setTimeout(resolve, delayMS));
|
|
114
129
|
}
|
|
@@ -118,8 +133,8 @@ async function run() {
|
|
|
118
133
|
if (now - startOfLastPeriod >= PROCESSING_PERIOD) {
|
|
119
134
|
startOfLastPeriod = now;
|
|
120
135
|
linesProcessedThisPeriod = 0;
|
|
136
|
+
blocksInThisPeriod = 0;
|
|
121
137
|
}
|
|
122
|
-
linesProcessedThisPeriod += 1;
|
|
123
138
|
|
|
124
139
|
if (progress.virtualTimeOffset) {
|
|
125
140
|
const virtualTime = obj.time + progress.virtualTimeOffset;
|
|
@@ -133,10 +148,17 @@ async function run() {
|
|
|
133
148
|
// Use the original.
|
|
134
149
|
slogSender(obj);
|
|
135
150
|
}
|
|
151
|
+
|
|
152
|
+
linesProcessedThisPeriod += 1;
|
|
153
|
+
if (isAfterCommit) {
|
|
154
|
+
blocksInThisPeriod += 1;
|
|
155
|
+
lastTime = Date.now();
|
|
156
|
+
await stats(true);
|
|
157
|
+
}
|
|
136
158
|
}
|
|
137
159
|
|
|
138
160
|
await stats(true);
|
|
139
|
-
console.
|
|
161
|
+
console.warn(
|
|
140
162
|
`done parsing`,
|
|
141
163
|
slogFileName,
|
|
142
164
|
`(${lineCount} lines, ${byteCount} bytes)`,
|
package/src/slog-file.js
CHANGED
|
@@ -11,7 +11,7 @@ export const makeSlogSender = async ({ env: { SLOGFILE } = {} } = {}) => {
|
|
|
11
11
|
|
|
12
12
|
const slogSender = (slogObj, jsonObj = serializeSlogObj(slogObj)) => {
|
|
13
13
|
// eslint-disable-next-line prefer-template
|
|
14
|
-
|
|
14
|
+
stream.write(jsonObj + '\n').catch(() => {});
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
return Object.assign(slogSender, {
|