@dvmkit/sdk 0.3.1-rc.10 → 0.3.3-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-2D75MNNG.js → chunk-2SD2W2BG.js} +8 -5
- package/dist/{chunk-XZ7LW4S5.js → chunk-4J32DTLT.js} +20 -16
- package/dist/{chunk-XMDQOXHO.js → chunk-4UZN2GP5.js} +4 -1
- package/dist/{chunk-YO56VCTQ.js → chunk-6DOGTAHA.js} +190 -75
- package/dist/{chunk-VA7GT6C6.js → chunk-7X6UDVCQ.js} +56 -53
- package/dist/{chunk-4A2RAKCW.js → chunk-BYCEKO65.js} +7 -3
- package/dist/{chunk-MMCE7XSR.js → chunk-C2AGARLM.js} +1 -13
- package/dist/{chunk-H2MEFVH6.js → chunk-CE7XEHYC.js} +7 -4
- package/dist/{chunk-D7YQYLLM.js → chunk-EAMZZ2B4.js} +1 -1
- package/dist/chunk-ETXDTUJO.js +1438 -0
- package/dist/{chunk-FDKRXOZO.js → chunk-FI4CST2D.js} +57 -49
- package/dist/{chunk-HHTL3ZFT.js → chunk-JDFLRNAZ.js} +16 -13
- package/dist/{chunk-U5VNEALI.js → chunk-M4QDXD2A.js} +1 -1
- package/dist/{chunk-GAIPXGM3.js → chunk-O3QDFPKM.js} +1 -1
- package/dist/{chunk-MD3H3BF7.js → chunk-O5AT6S5T.js} +1 -1
- package/dist/{chunk-C3MTFLC6.js → chunk-P6QON7ER.js} +14 -12
- package/dist/{chunk-CC3UY6OS.js → chunk-UZC4A4DM.js} +379 -374
- package/dist/{chunk-QX52F6IB.js → chunk-VAMSJRJT.js} +7 -4
- package/dist/{chunk-AJNFXR7J.js → chunk-VHNPVGSA.js} +4 -1
- package/dist/{chunk-N5B66UOS.js → chunk-YHN3WMMF.js} +4 -1
- 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/{credit-ledger-MHA652TV.js → credit-ledger-A35WH2TI.js} +3 -2
- package/dist/index.js +4 -3
- package/dist/internal/caller.d.ts +32 -3
- package/dist/internal/caller.js +22 -12
- package/dist/internal/index.js +1 -1
- package/dist/internal/server.js +16 -15
- package/dist/memory-credit-ledger-2LBZVMKJ.js +10 -0
- package/dist/{mpp-setup-MPP3ST5X.js → mpp-setup-7CGBKNUP.js} +2 -1
- package/dist/{payout-reporter-KEMUXEUO.js → payout-reporter-ZMOA37GN.js} +2 -1
- package/dist/{postgres-consumed-credential-store-6N2V5MJN.js → postgres-consumed-credential-store-CUQJKRSL.js} +4 -1
- package/dist/{postgres-job-store-VE2JRUEC.js → postgres-job-store-MSD2HZOI.js} +2 -1
- package/dist/{postgres-replay-store-ZF4JNZOW.js → postgres-replay-store-ARZSQ45X.js} +2 -1
- package/dist/{pricing-MU5GNUJZ.js → pricing-XT2IAPNE.js} +2 -1
- package/dist/{revenue-reporter-O75BGYFK.js → revenue-reporter-EKJOGQYR.js} +2 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +112 -112
- package/dist/{tempo-charge-store-SDTUNTKA.js → tempo-charge-store-4WX7FPOV.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-LCSDHB7G.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 +1 -1
- package/dist/memory-credit-ledger-BYBATRN3.js +0 -9
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
} from "./chunk-COYKJRMM.js";
|
|
4
4
|
import {
|
|
5
5
|
applyRetryToPool
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-P6QON7ER.js";
|
|
7
|
+
import {
|
|
8
|
+
diagnosticConsole
|
|
9
|
+
} from "./chunk-ETXDTUJO.js";
|
|
7
10
|
|
|
8
11
|
// src/sdk/server/credit-ledger.ts
|
|
9
12
|
import { randomUUID } from "crypto";
|
|
@@ -1323,15 +1326,15 @@ var CreditLedger = class {
|
|
|
1323
1326
|
const uncovered = Number(rows[0]?.uncovered ?? 0);
|
|
1324
1327
|
const unbacked = Number(rows[0]?.unbacked ?? 0);
|
|
1325
1328
|
if (rowCount === 0 && uncovered === 0 && unbacked === 0) return;
|
|
1326
|
-
|
|
1327
|
-
|
|
1329
|
+
diagnosticConsole.warn(
|
|
1330
|
+
{
|
|
1328
1331
|
level: uncovered > 0 ? "warn" : "info",
|
|
1329
1332
|
event: "credit_funding_lot_backfill",
|
|
1330
1333
|
backfilled: rowCount ?? 0,
|
|
1331
1334
|
uncovered_credits: uncovered,
|
|
1332
1335
|
unbacked_credits: unbacked,
|
|
1333
|
-
message:
|
|
1334
|
-
}
|
|
1336
|
+
message: void 0
|
|
1337
|
+
}
|
|
1335
1338
|
);
|
|
1336
1339
|
}
|
|
1337
1340
|
/**
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
diagnosticConsole
|
|
3
|
+
} from "./chunk-ETXDTUJO.js";
|
|
4
|
+
|
|
1
5
|
// src/sdk/server/mpp-setup.ts
|
|
2
6
|
import { randomUUID } from "crypto";
|
|
3
7
|
import { Errors as MppxErrors, PaymentRequest } from "mppx";
|
|
@@ -117,8 +121,8 @@ var TempoSettlementReadiness = class {
|
|
|
117
121
|
...failure.creditId ? { creditId: failure.creditId } : {},
|
|
118
122
|
...failure.drainId ? { drainId: failure.drainId } : {}
|
|
119
123
|
};
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
diagnosticConsole.warn(
|
|
125
|
+
{
|
|
122
126
|
level: "warn",
|
|
123
127
|
event: "tempo_settlement_insufficient_funds",
|
|
124
128
|
address: observation.address,
|
|
@@ -129,7 +133,7 @@ var TempoSettlementReadiness = class {
|
|
|
129
133
|
...observation.channelId ? { channel_id: observation.channelId } : {},
|
|
130
134
|
...observation.creditId ? { credit_id: observation.creditId } : {},
|
|
131
135
|
...observation.drainId ? { drain_id: observation.drainId } : {}
|
|
132
|
-
}
|
|
136
|
+
}
|
|
133
137
|
);
|
|
134
138
|
await this.notify((listener) => listener.onFailure?.(observation));
|
|
135
139
|
if (sharedLatchWritten && this.failureBalanceMicro === void 0) {
|
|
@@ -259,8 +263,8 @@ var TempoSettlementReadiness = class {
|
|
|
259
263
|
checkedAt: this.now(),
|
|
260
264
|
ready: this.available()
|
|
261
265
|
};
|
|
262
|
-
|
|
263
|
-
|
|
266
|
+
diagnosticConsole.info(
|
|
267
|
+
{
|
|
264
268
|
level: "info",
|
|
265
269
|
event: "tempo_settlement_fee_balance",
|
|
266
270
|
address: observation.address,
|
|
@@ -269,7 +273,7 @@ var TempoSettlementReadiness = class {
|
|
|
269
273
|
balance_micro: observation.balanceMicro.toString(),
|
|
270
274
|
low_balance_micro: observation.lowBalanceMicro.toString(),
|
|
271
275
|
ready: observation.ready
|
|
272
|
-
}
|
|
276
|
+
}
|
|
273
277
|
);
|
|
274
278
|
await this.notify((listener) => listener.onBalance?.(observation));
|
|
275
279
|
return observation;
|
|
@@ -286,22 +290,22 @@ function isTempoInsufficientFundsError(error) {
|
|
|
286
290
|
if (error instanceof InsufficientFundsError) return true;
|
|
287
291
|
return error instanceof BaseError && error.walk((cause) => cause instanceof InsufficientFundsError) !== null;
|
|
288
292
|
}
|
|
289
|
-
function logBalanceFailure(
|
|
290
|
-
|
|
291
|
-
|
|
293
|
+
function logBalanceFailure(_error) {
|
|
294
|
+
diagnosticConsole.warn(
|
|
295
|
+
{
|
|
292
296
|
level: "warn",
|
|
293
297
|
event: "tempo_settlement_fee_balance_failed",
|
|
294
|
-
error_name:
|
|
295
|
-
}
|
|
298
|
+
error_name: void 0
|
|
299
|
+
}
|
|
296
300
|
);
|
|
297
301
|
}
|
|
298
|
-
function logStateFailure(
|
|
299
|
-
|
|
300
|
-
|
|
302
|
+
function logStateFailure(_error) {
|
|
303
|
+
diagnosticConsole.warn(
|
|
304
|
+
{
|
|
301
305
|
level: "warn",
|
|
302
306
|
event: "tempo_settlement_readiness_state_failed",
|
|
303
|
-
error_name:
|
|
304
|
-
}
|
|
307
|
+
error_name: void 0
|
|
308
|
+
}
|
|
305
309
|
);
|
|
306
310
|
}
|
|
307
311
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
withSdkInitLock
|
|
3
3
|
} from "./chunk-COYKJRMM.js";
|
|
4
|
+
import {
|
|
5
|
+
diagnosticConsole
|
|
6
|
+
} from "./chunk-ETXDTUJO.js";
|
|
4
7
|
|
|
5
8
|
// src/sdk/server/payout-reporter.ts
|
|
6
9
|
import { createHash, randomUUID } from "crypto";
|
|
@@ -719,7 +722,7 @@ function message(err) {
|
|
|
719
722
|
return err instanceof Error ? err.message : String(err);
|
|
720
723
|
}
|
|
721
724
|
function warn(level, fields) {
|
|
722
|
-
|
|
725
|
+
diagnosticConsole.warn({ level, ...fields });
|
|
723
726
|
}
|
|
724
727
|
|
|
725
728
|
export {
|
|
@@ -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-ETXDTUJO.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) {
|