@dvmkit/sdk 0.3.0-rc.9 → 0.3.2-rc.10
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/dist/{chunk-MD3H3BF7.js → chunk-2A33VHYM.js} +1 -1
- package/dist/{chunk-AJNFXR7J.js → chunk-3KYLYVY4.js} +4 -1
- package/dist/{chunk-YO56VCTQ.js → chunk-BWGRKGKG.js} +190 -75
- package/dist/{chunk-MMCE7XSR.js → chunk-C2AGARLM.js} +1 -13
- package/dist/chunk-D42FMCLJ.js +1423 -0
- package/dist/{chunk-QX52F6IB.js → chunk-DSVGYW3B.js} +7 -4
- package/dist/{chunk-LTAIBLS2.js → chunk-HNIKSOI2.js} +524 -408
- package/dist/{chunk-4A2RAKCW.js → chunk-IBDDIG4K.js} +7 -3
- package/dist/{chunk-D7YQYLLM.js → chunk-J7PW2U6P.js} +1 -1
- package/dist/{chunk-FDKRXOZO.js → chunk-KL4C3LQV.js} +57 -49
- package/dist/{chunk-VA7GT6C6.js → chunk-LHN75BTX.js} +56 -53
- package/dist/{chunk-C3MTFLC6.js → chunk-M4RSKQAV.js} +14 -12
- package/dist/{chunk-U5VNEALI.js → chunk-PPHE7XUU.js} +1 -1
- package/dist/{chunk-GAIPXGM3.js → chunk-SP42AI5T.js} +1 -1
- package/dist/{chunk-N5B66UOS.js → chunk-U2EYIPFX.js} +4 -1
- package/dist/{chunk-H2MEFVH6.js → chunk-UQCK5VMA.js} +7 -4
- package/dist/{chunk-XMDQOXHO.js → chunk-Y7JZLO5J.js} +4 -1
- package/dist/{chunk-HHTL3ZFT.js → chunk-YEO5GW7U.js} +16 -13
- package/dist/{chunk-O6D72KYA.js → chunk-YRDA7EWN.js} +1 -1
- package/dist/{chunk-VIVXB4CD.js → chunk-YYQG4R7T.js} +1 -1
- package/dist/{chunk-FPOLJRBF.js → chunk-Z3EHBW2G.js} +2 -2
- package/dist/{chunk-2D75MNNG.js → chunk-ZHTUITDW.js} +8 -5
- package/dist/{chunk-XZ7LW4S5.js → chunk-ZUTI56L7.js} +20 -16
- package/dist/{credit-ledger-MHA652TV.js → credit-ledger-4CCHRJE2.js} +3 -2
- package/dist/{credit-menu-BlCL7gZx.d.ts → credit-menu-0-UtJ3hh.d.ts} +5 -1
- package/dist/index.js +4 -3
- package/dist/internal/caller.d.ts +38 -3
- package/dist/internal/caller.js +59 -19
- package/dist/internal/index.js +1 -1
- package/dist/internal/server.d.ts +2 -2
- package/dist/internal/server.js +16 -15
- package/dist/memory-credit-ledger-TERNM5T6.js +10 -0
- package/dist/{mpp-setup-MPP3ST5X.js → mpp-setup-OQ4OV7A5.js} +2 -1
- package/dist/{payout-reporter-KEMUXEUO.js → payout-reporter-TQ3YIFLZ.js} +2 -1
- package/dist/{postgres-consumed-credential-store-6N2V5MJN.js → postgres-consumed-credential-store-LFQNC7LD.js} +4 -1
- package/dist/{postgres-job-store-VE2JRUEC.js → postgres-job-store-FGOJ7UIX.js} +2 -1
- package/dist/{postgres-replay-store-ZF4JNZOW.js → postgres-replay-store-DFQSXPCG.js} +2 -1
- package/dist/{pricing-MU5GNUJZ.js → pricing-UJAPJLOM.js} +2 -1
- package/dist/{revenue-reporter-O75BGYFK.js → revenue-reporter-VN4WYN74.js} +2 -1
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +112 -112
- package/dist/{tempo-charge-store-SDTUNTKA.js → tempo-charge-store-EA66LSVJ.js} +2 -1
- package/dist/{tempo-lifecycle-G5SB4HFC.js → tempo-lifecycle-TJ62A7UX.js} +3 -3
- package/dist/{tempo-session-store-WF3VZXNF.js → tempo-session-store-65NA77KJ.js} +3 -2
- package/dist/{tempo-wallet-ZFNUDFVO.js → tempo-wallet-RCGBBAJH.js} +1 -1
- package/dist/testing/index.js +4 -3
- package/dist/{x402-CI6PSHNO.js → x402-S47Q77UE.js} +2 -2
- package/package.json +2 -2
- package/dist/memory-credit-ledger-BYBATRN3.js +0 -9
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
withSdkInitLock
|
|
3
3
|
} from "./chunk-COYKJRMM.js";
|
|
4
|
+
import {
|
|
5
|
+
diagnosticConsole
|
|
6
|
+
} from "./chunk-D42FMCLJ.js";
|
|
4
7
|
|
|
5
8
|
// src/sdk/server/postgres-replay-store.ts
|
|
6
9
|
var DEFAULT_TABLE_NAME = "signed_request_replays";
|
|
@@ -57,7 +60,7 @@ var PostgresReplayStore = class {
|
|
|
57
60
|
gcSweep(now) {
|
|
58
61
|
const cutoff = now - this.windowSeconds;
|
|
59
62
|
this.pool.query(`DELETE FROM ${this.tableName} WHERE recorded_at < $1`, [cutoff]).catch((err) => {
|
|
60
|
-
|
|
63
|
+
diagnosticConsole.error("PostgresReplayStore GC sweep failed:", err);
|
|
61
64
|
});
|
|
62
65
|
}
|
|
63
66
|
};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
initCallerLoggers
|
|
3
3
|
} from "./chunk-66HGCPBU.js";
|
|
4
|
+
import {
|
|
5
|
+
bindDiagnosticCapabilityAuthority,
|
|
6
|
+
bindDiagnosticIdentityAuthority,
|
|
7
|
+
emitDiagnostic,
|
|
8
|
+
extendDiagnosticIdentityAuthority,
|
|
9
|
+
projectDiagnosticFields,
|
|
10
|
+
projectSpanRow
|
|
11
|
+
} from "./chunk-D42FMCLJ.js";
|
|
4
12
|
|
|
5
13
|
// src/sdk/step-cache.ts
|
|
6
14
|
var StepCache = class _StepCache {
|
|
@@ -36,36 +44,34 @@ var StepCache = class _StepCache {
|
|
|
36
44
|
};
|
|
37
45
|
|
|
38
46
|
// src/sdk/logger.ts
|
|
39
|
-
function createConsoleLogger(
|
|
40
|
-
const fmt = (message, data) => {
|
|
41
|
-
const parts = [`[${jobId}] ${message}`];
|
|
42
|
-
if (data) parts.push(data);
|
|
43
|
-
return parts;
|
|
44
|
-
};
|
|
47
|
+
function createConsoleLogger(_jobId) {
|
|
45
48
|
return {
|
|
46
|
-
debug(
|
|
47
|
-
|
|
49
|
+
debug(_message, data) {
|
|
50
|
+
emitDiagnostic("debug", "diagnostic.message", data);
|
|
48
51
|
},
|
|
49
|
-
info(
|
|
50
|
-
|
|
52
|
+
info(_message, data) {
|
|
53
|
+
emitDiagnostic("info", "diagnostic.message", data);
|
|
51
54
|
},
|
|
52
|
-
warn(
|
|
53
|
-
|
|
55
|
+
warn(_message, data) {
|
|
56
|
+
emitDiagnostic("warn", "diagnostic.message", data);
|
|
54
57
|
},
|
|
55
|
-
error(
|
|
56
|
-
|
|
58
|
+
error(_message, data) {
|
|
59
|
+
emitDiagnostic("error", "diagnostic.message", data);
|
|
57
60
|
}
|
|
58
61
|
};
|
|
59
62
|
}
|
|
60
63
|
function createStdoutLogger(context) {
|
|
61
|
-
const emit = (
|
|
62
|
-
|
|
64
|
+
const emit = (level) => (_message, data) => {
|
|
65
|
+
emitDiagnostic(level, "diagnostic.message", {
|
|
66
|
+
...projectDiagnosticFields(context),
|
|
67
|
+
...projectDiagnosticFields(data)
|
|
68
|
+
});
|
|
63
69
|
};
|
|
64
70
|
return {
|
|
65
|
-
debug: emit(
|
|
66
|
-
info: emit(
|
|
67
|
-
warn: emit(
|
|
68
|
-
error: emit(
|
|
71
|
+
debug: emit("debug"),
|
|
72
|
+
info: emit("info"),
|
|
73
|
+
warn: emit("warn"),
|
|
74
|
+
error: emit("error")
|
|
69
75
|
};
|
|
70
76
|
}
|
|
71
77
|
function createNoopLogger() {
|
|
@@ -108,6 +114,17 @@ function currentContext(service) {
|
|
|
108
114
|
};
|
|
109
115
|
}
|
|
110
116
|
function pinDimension(key, value) {
|
|
117
|
+
const ctx = storage.getStore();
|
|
118
|
+
if (ctx) {
|
|
119
|
+
ctx.dimensions = { ...ctx.dimensions, [key]: value };
|
|
120
|
+
ctx.diagnosticIdentityAuthority = extendDiagnosticIdentityAuthority(
|
|
121
|
+
ctx.diagnosticIdentityAuthority,
|
|
122
|
+
key,
|
|
123
|
+
value
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function setDimension(key, value) {
|
|
111
128
|
const ctx = storage.getStore();
|
|
112
129
|
if (ctx) {
|
|
113
130
|
ctx.dimensions = { ...ctx.dimensions, [key]: value };
|
|
@@ -121,36 +138,35 @@ function rawContext() {
|
|
|
121
138
|
import { hostname } from "os";
|
|
122
139
|
|
|
123
140
|
// src/observability/stdout-sink.ts
|
|
124
|
-
var SENSITIVE_KEY_RE = /secret|token|password|private|bearer|seed|preimage|api[_-]?key|signing[_-]?key|priv[_-]?key/i;
|
|
125
141
|
var isTTY = typeof process.stdout.isTTY === "boolean" && process.stdout.isTTY;
|
|
126
142
|
var RED = isTTY ? "\x1B[31m" : "";
|
|
127
143
|
var YELLOW = isTTY ? "\x1B[33m" : "";
|
|
128
144
|
var RESET = isTTY ? "\x1B[0m" : "";
|
|
129
145
|
function formatSpanLine(span) {
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
146
|
+
const result = projectSpanRow(span);
|
|
147
|
+
if (!result.ok) return "";
|
|
148
|
+
const safeSpan = result.row;
|
|
149
|
+
const ts = new Date(safeSpan.started_at_ms).toISOString();
|
|
150
|
+
const levelStr = colorLevel(safeSpan.level);
|
|
151
|
+
const parts = [`[${ts}]`, safeSpan.dataset, `${levelStr}:`, safeSpan.name];
|
|
152
|
+
if (safeSpan.trace_id) {
|
|
153
|
+
parts.push(`trace=${safeSpan.trace_id}`);
|
|
135
154
|
}
|
|
136
|
-
for (const [k, v] of Object.entries(
|
|
155
|
+
for (const [k, v] of Object.entries(safeSpan.dimensions)) {
|
|
137
156
|
parts.push(formatKV(k, v));
|
|
138
157
|
}
|
|
139
|
-
for (const [k, v] of Object.entries(
|
|
158
|
+
for (const [k, v] of Object.entries(safeSpan.attributes)) {
|
|
140
159
|
parts.push(formatKV(k, v));
|
|
141
160
|
}
|
|
142
|
-
const durationMs =
|
|
161
|
+
const durationMs = safeSpan.ended_at_ms - safeSpan.started_at_ms;
|
|
143
162
|
if (durationMs > 0) {
|
|
144
163
|
parts.push(`duration=${durationMs}ms`);
|
|
145
164
|
}
|
|
146
|
-
if (span.error_message) {
|
|
147
|
-
parts.push(`error=${truncate(span.error_message, 120)}`);
|
|
148
|
-
}
|
|
149
165
|
return parts.join(" ");
|
|
150
166
|
}
|
|
151
167
|
function writeSpanLine(span) {
|
|
152
168
|
const line = formatSpanLine(span);
|
|
153
|
-
process.stdout.write(line + "\n");
|
|
169
|
+
if (line) process.stdout.write(line + "\n");
|
|
154
170
|
}
|
|
155
171
|
function colorLevel(level) {
|
|
156
172
|
if (level === "error") return `${RED}error${RESET}`;
|
|
@@ -158,7 +174,6 @@ function colorLevel(level) {
|
|
|
158
174
|
return level;
|
|
159
175
|
}
|
|
160
176
|
function formatKV(key, value) {
|
|
161
|
-
if (SENSITIVE_KEY_RE.test(key)) return `${key}=[REDACTED]`;
|
|
162
177
|
return `${key}=${truncate(stringify(value), 80)}`;
|
|
163
178
|
}
|
|
164
179
|
function stringify(value) {
|
|
@@ -182,28 +197,88 @@ function setEmitter(fn) {
|
|
|
182
197
|
}
|
|
183
198
|
var cachedHost = hostname();
|
|
184
199
|
var serviceVersion = process.env.GIT_SHA ?? process.env.FLY_IMAGE_REF ?? "dev";
|
|
200
|
+
function ownDataValue(input, key) {
|
|
201
|
+
if ((typeof input !== "object" || input === null) && typeof input !== "function") {
|
|
202
|
+
return void 0;
|
|
203
|
+
}
|
|
204
|
+
const descriptor = Object.getOwnPropertyDescriptor(input, key);
|
|
205
|
+
if (!descriptor) return void 0;
|
|
206
|
+
if (!("value" in descriptor)) throw new TypeError("accessor override");
|
|
207
|
+
return descriptor.value;
|
|
208
|
+
}
|
|
209
|
+
function ownIdentityKeys(input) {
|
|
210
|
+
try {
|
|
211
|
+
return ["dvm_id", "dvm_slug", "builder_id"].filter((key) => {
|
|
212
|
+
const descriptor = (typeof input === "object" && input !== null || typeof input === "function") && Object.getOwnPropertyDescriptor(input, key);
|
|
213
|
+
return descriptor && "value" in descriptor;
|
|
214
|
+
});
|
|
215
|
+
} catch {
|
|
216
|
+
return [];
|
|
217
|
+
}
|
|
218
|
+
}
|
|
185
219
|
async function withSpan(opts, fn) {
|
|
186
220
|
const spanId = randomSpanId();
|
|
187
221
|
const existingCtx = rawContext();
|
|
188
222
|
const ctx = existingCtx ?? currentContext();
|
|
223
|
+
const authority = ctx.diagnosticCapabilityAuthority;
|
|
224
|
+
const identityAuthority = ctx.diagnosticIdentityAuthority;
|
|
189
225
|
const startMs = opts.startMs ?? Date.now();
|
|
226
|
+
const attributeInput = opts.attrs;
|
|
227
|
+
const attributeIdentityKeys = ownIdentityKeys(attributeInput);
|
|
190
228
|
let status = "ok";
|
|
191
229
|
let level = opts.level;
|
|
192
|
-
let errorMessage = null;
|
|
193
|
-
let errorStack = null;
|
|
194
230
|
if (opts.err) {
|
|
195
231
|
status = "error";
|
|
196
|
-
errorMessage = opts.err.message;
|
|
197
|
-
errorStack = opts.err.stack ?? null;
|
|
198
232
|
}
|
|
233
|
+
let attributes = projectDiagnosticFields(
|
|
234
|
+
attributeInput,
|
|
235
|
+
opts.dataset,
|
|
236
|
+
authority,
|
|
237
|
+
identityAuthority
|
|
238
|
+
);
|
|
239
|
+
const childDimensions = bindDiagnosticIdentityAuthority(
|
|
240
|
+
bindDiagnosticCapabilityAuthority(
|
|
241
|
+
{
|
|
242
|
+
...projectDiagnosticFields(
|
|
243
|
+
ctx.dimensions,
|
|
244
|
+
opts.dataset,
|
|
245
|
+
authority,
|
|
246
|
+
identityAuthority
|
|
247
|
+
),
|
|
248
|
+
...projectDiagnosticFields(
|
|
249
|
+
opts.dims,
|
|
250
|
+
opts.dataset,
|
|
251
|
+
authority,
|
|
252
|
+
identityAuthority
|
|
253
|
+
)
|
|
254
|
+
},
|
|
255
|
+
authority
|
|
256
|
+
),
|
|
257
|
+
identityAuthority
|
|
258
|
+
);
|
|
199
259
|
const childCtx = {
|
|
200
260
|
traceId: ctx.traceId,
|
|
201
261
|
spanId,
|
|
202
|
-
dimensions:
|
|
262
|
+
dimensions: childDimensions,
|
|
203
263
|
service: ctx.service,
|
|
204
|
-
tracestate: ctx.tracestate
|
|
264
|
+
tracestate: ctx.tracestate,
|
|
265
|
+
diagnosticCapabilityAuthority: authority,
|
|
266
|
+
diagnosticIdentityAuthority: identityAuthority
|
|
267
|
+
};
|
|
268
|
+
const latestIdentityAuthority = () => childCtx.diagnosticIdentityAuthority;
|
|
269
|
+
const refreshAttributes = () => {
|
|
270
|
+
const identityCandidates = Object.fromEntries(
|
|
271
|
+
attributeIdentityKeys.map((key) => [key, null])
|
|
272
|
+
);
|
|
273
|
+
attributes = projectDiagnosticFields(
|
|
274
|
+
{ ...attributes, ...identityCandidates },
|
|
275
|
+
opts.dataset,
|
|
276
|
+
authority,
|
|
277
|
+
latestIdentityAuthority()
|
|
278
|
+
);
|
|
205
279
|
};
|
|
206
280
|
const emitRow = () => {
|
|
281
|
+
const activeIdentityAuthority = latestIdentityAuthority();
|
|
207
282
|
const endMs = opts.endMs ?? Date.now();
|
|
208
283
|
const row = {
|
|
209
284
|
span_id: spanId,
|
|
@@ -219,43 +294,81 @@ async function withSpan(opts, fn) {
|
|
|
219
294
|
service_version: serviceVersion,
|
|
220
295
|
host: cachedHost,
|
|
221
296
|
pid: process.pid,
|
|
222
|
-
dimensions:
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
297
|
+
dimensions: projectDiagnosticFields(
|
|
298
|
+
childCtx.dimensions,
|
|
299
|
+
opts.dataset,
|
|
300
|
+
authority,
|
|
301
|
+
activeIdentityAuthority
|
|
302
|
+
),
|
|
303
|
+
attributes,
|
|
304
|
+
error_message: null,
|
|
305
|
+
error_stack: null,
|
|
226
306
|
sample_rate: 1
|
|
227
307
|
};
|
|
228
|
-
|
|
229
|
-
|
|
308
|
+
bindDiagnosticCapabilityAuthority(row, authority);
|
|
309
|
+
bindDiagnosticIdentityAuthority(row, activeIdentityAuthority);
|
|
310
|
+
const projected = projectSpanRow(row);
|
|
311
|
+
if (!projected.ok) return;
|
|
312
|
+
try {
|
|
313
|
+
writeSpanLine(projected.row);
|
|
314
|
+
} catch {
|
|
315
|
+
}
|
|
316
|
+
try {
|
|
317
|
+
if (emitter) emitter(projected.row);
|
|
318
|
+
} catch {
|
|
319
|
+
}
|
|
230
320
|
};
|
|
321
|
+
let result;
|
|
231
322
|
try {
|
|
232
|
-
|
|
233
|
-
if (opts.inspect) {
|
|
234
|
-
const overrides = opts.inspect(result);
|
|
235
|
-
if (overrides) {
|
|
236
|
-
if (overrides.status) status = overrides.status;
|
|
237
|
-
if (overrides.level) level = overrides.level;
|
|
238
|
-
if (overrides.errorMessage !== void 0) errorMessage = overrides.errorMessage;
|
|
239
|
-
if (overrides.attrs) Object.assign(opts.attrs ??= {}, overrides.attrs);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
emitRow();
|
|
243
|
-
return result;
|
|
323
|
+
result = await withTraceContext(childCtx, () => fn());
|
|
244
324
|
} catch (err) {
|
|
245
325
|
status = "error";
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
326
|
+
refreshAttributes();
|
|
327
|
+
try {
|
|
328
|
+
const onError = opts.onError;
|
|
329
|
+
if (onError) {
|
|
330
|
+
const overrides = onError(err);
|
|
331
|
+
attributes = {
|
|
332
|
+
...attributes,
|
|
333
|
+
...projectDiagnosticFields(
|
|
334
|
+
overrides,
|
|
335
|
+
opts.dataset,
|
|
336
|
+
authority,
|
|
337
|
+
latestIdentityAuthority()
|
|
338
|
+
)
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
} catch {
|
|
255
342
|
}
|
|
256
343
|
emitRow();
|
|
257
344
|
throw err;
|
|
258
345
|
}
|
|
346
|
+
refreshAttributes();
|
|
347
|
+
try {
|
|
348
|
+
const inspect = opts.inspect;
|
|
349
|
+
if (inspect) {
|
|
350
|
+
const overrides = inspect(result);
|
|
351
|
+
const nextStatus = ownDataValue(overrides, "status");
|
|
352
|
+
const nextLevel = ownDataValue(overrides, "level");
|
|
353
|
+
const nextAttributes = ownDataValue(overrides, "attrs");
|
|
354
|
+
const projectedAttributes = nextAttributes === void 0 ? void 0 : projectDiagnosticFields(
|
|
355
|
+
nextAttributes,
|
|
356
|
+
opts.dataset,
|
|
357
|
+
authority,
|
|
358
|
+
latestIdentityAuthority()
|
|
359
|
+
);
|
|
360
|
+
if (nextStatus === "ok" || nextStatus === "error") status = nextStatus;
|
|
361
|
+
if (nextLevel === "info" || nextLevel === "warn" || nextLevel === "error") {
|
|
362
|
+
level = nextLevel;
|
|
363
|
+
}
|
|
364
|
+
if (projectedAttributes) {
|
|
365
|
+
attributes = { ...attributes, ...projectedAttributes };
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
} catch {
|
|
369
|
+
}
|
|
370
|
+
emitRow();
|
|
371
|
+
return result;
|
|
259
372
|
}
|
|
260
373
|
|
|
261
374
|
// src/observability/datasets.ts
|
|
@@ -298,11 +411,15 @@ function createLogger(dataset, bakedDims) {
|
|
|
298
411
|
void withSpan({ dataset, name, level: "warn", attrs, dims: bakedDims }, noop).catch(noop);
|
|
299
412
|
},
|
|
300
413
|
error(name, attrs) {
|
|
301
|
-
const err = attrs?.err instanceof Error ? attrs.err : void 0;
|
|
302
|
-
const cleanAttrs = attrs ? { ...attrs } : void 0;
|
|
303
|
-
if (cleanAttrs) delete cleanAttrs.err;
|
|
304
414
|
void withSpan(
|
|
305
|
-
{
|
|
415
|
+
{
|
|
416
|
+
dataset,
|
|
417
|
+
name,
|
|
418
|
+
level: "error",
|
|
419
|
+
attrs,
|
|
420
|
+
dims: bakedDims,
|
|
421
|
+
err: new Error()
|
|
422
|
+
},
|
|
306
423
|
noop
|
|
307
424
|
).catch(noop);
|
|
308
425
|
},
|
|
@@ -314,15 +431,13 @@ function createLogger(dataset, bakedDims) {
|
|
|
314
431
|
return {
|
|
315
432
|
[Symbol.dispose]() {
|
|
316
433
|
const endMs = Date.now();
|
|
317
|
-
void withSpan({ dataset, name, attrs, dims: bakedDims, startMs, endMs }, noop).catch(
|
|
318
|
-
noop
|
|
319
|
-
);
|
|
434
|
+
void withSpan({ dataset, name, attrs, dims: bakedDims, startMs, endMs }, noop).catch(noop);
|
|
320
435
|
}
|
|
321
436
|
};
|
|
322
437
|
},
|
|
323
438
|
set(dims) {
|
|
324
439
|
for (const [k, v] of Object.entries(dims)) {
|
|
325
|
-
|
|
440
|
+
setDimension(k, v);
|
|
326
441
|
}
|
|
327
442
|
},
|
|
328
443
|
extend(dims) {
|
|
@@ -765,7 +765,7 @@ function recordPendingDrain(endpoint, callerPubkey, drain, identity) {
|
|
|
765
765
|
);
|
|
766
766
|
if (index === -1) drains.push(drain);
|
|
767
767
|
else drains[index] = drain;
|
|
768
|
-
record.pendingDrains =
|
|
768
|
+
record.pendingDrains = drains;
|
|
769
769
|
return void 0;
|
|
770
770
|
});
|
|
771
771
|
}
|
|
@@ -879,7 +879,6 @@ function adoptCreditId(record, creditId) {
|
|
|
879
879
|
delete record.discrepancy;
|
|
880
880
|
delete record.lastReceiptJobId;
|
|
881
881
|
}
|
|
882
|
-
var MAX_PENDING_DRAINS = 8;
|
|
883
882
|
var MAX_SETTLED_DRAIN_EVIDENCE = 8;
|
|
884
883
|
var MAX_LOST_IMPLICIT_CREDITS = 8;
|
|
885
884
|
var MAX_DATE_MS = 864e13;
|
|
@@ -1285,17 +1284,6 @@ function isEvidenceish(value) {
|
|
|
1285
1284
|
function isDrainish(value) {
|
|
1286
1285
|
return typeof value === "object" && value !== null && typeof value.drainId === "string";
|
|
1287
1286
|
}
|
|
1288
|
-
function capPendingDrains(drains, creditId) {
|
|
1289
|
-
if (drains.length <= MAX_PENDING_DRAINS) return drains;
|
|
1290
|
-
const evictable = drains.filter((d) => d.creditId !== creditId).sort((a, b) => a.requestedAt - b.requestedAt);
|
|
1291
|
-
const dropped = new Set(evictable.slice(0, drains.length - MAX_PENDING_DRAINS));
|
|
1292
|
-
for (const d of dropped) {
|
|
1293
|
-
info(
|
|
1294
|
-
`Dropping the oldest unclaimed drain record (${d.drainId}${d.creditId ? ` on credit ${d.creditId}` : ""}) \u2014 ${String(MAX_PENDING_DRAINS)} is the most this DVM's record keeps.`
|
|
1295
|
-
);
|
|
1296
|
-
}
|
|
1297
|
-
return drains.filter((d) => !dropped.has(d));
|
|
1298
|
-
}
|
|
1299
1287
|
function capDrainEvidence(evidence, endpoint) {
|
|
1300
1288
|
const settled = evidence.filter((e) => e.settledAt !== void 0).sort((a, b) => (a.settledAt ?? 0) - (b.settledAt ?? 0));
|
|
1301
1289
|
if (settled.length <= MAX_SETTLED_DRAIN_EVIDENCE) return evidence;
|