@autter/runtime-node 1.5.0 → 1.6.1
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/README.md +139 -1
- package/dist/{chunk-GI47WGRR.cjs → chunk-4MVWIRBI.cjs} +120 -39
- package/dist/{chunk-3TJHUCZ6.js → chunk-5KISVAVB.js} +326 -54
- package/dist/{chunk-L6SRL65J.cjs → chunk-7OTD2YPT.cjs} +11 -11
- package/dist/{chunk-L7HWKMCZ.js → chunk-HRDELHZP.js} +112 -31
- package/dist/{chunk-ZS4WQJQR.js → chunk-L5ENELB2.js} +1 -1
- package/dist/{chunk-P4VRTFAV.cjs → chunk-UXTIMS3G.cjs} +353 -81
- package/dist/cli.cjs +29 -9
- package/dist/cli.js +22 -2
- package/dist/index.cjs +668 -272
- package/dist/index.d.cts +160 -7
- package/dist/index.d.ts +160 -7
- package/dist/index.js +529 -133
- package/dist/{sinks-RFV76lF1.d.cts → sinks-CPGDyfU8.d.cts} +29 -1
- package/dist/{sinks-RFV76lF1.d.ts → sinks-CPGDyfU8.d.ts} +29 -1
- package/dist/testing.cjs +8 -8
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +2 -2
- package/package.json +3 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
var _chunk4MVWIRBIcjs = require('./chunk-4MVWIRBI.cjs');
|
|
5
6
|
|
|
6
7
|
// ../runtime-core/dist/index.js
|
|
7
8
|
var SENSITIVE_KEY_PATTERNS = [
|
|
@@ -327,8 +328,8 @@ function priority(key) {
|
|
|
327
328
|
if (/^(?:exception|autter\.error)\./.test(key)) return 1;
|
|
328
329
|
return 0;
|
|
329
330
|
}
|
|
330
|
-
function boundContext(attributes = {},
|
|
331
|
-
const redacted =
|
|
331
|
+
function boundContext(attributes = {}, redact3) {
|
|
332
|
+
const redacted = redact3 ? redact3(attributes) : redactAttributes(attributes);
|
|
332
333
|
let budget = 512;
|
|
333
334
|
let characters = 16384;
|
|
334
335
|
let truncated = false;
|
|
@@ -365,14 +366,14 @@ function boundContext(attributes = {}, redact2) {
|
|
|
365
366
|
if (truncated) result["autter.context.truncated"] = true;
|
|
366
367
|
return result;
|
|
367
368
|
}
|
|
368
|
-
function userContext(attributes = {},
|
|
369
|
+
function userContext(attributes = {}, redact3) {
|
|
369
370
|
return Object.fromEntries(
|
|
370
|
-
Object.entries(boundContext(attributes,
|
|
371
|
+
Object.entries(boundContext(attributes, redact3)).filter(
|
|
371
372
|
([key]) => !RESERVED_KEY.test(key)
|
|
372
373
|
)
|
|
373
374
|
);
|
|
374
375
|
}
|
|
375
|
-
function mergeContext(current, next = {},
|
|
376
|
+
function mergeContext(current, next = {}, redact3) {
|
|
376
377
|
const merge2 = (left, right, depth) => {
|
|
377
378
|
const result = { ...left };
|
|
378
379
|
for (const [key, value] of Object.entries(right)) {
|
|
@@ -381,7 +382,7 @@ function mergeContext(current, next = {}, redact2) {
|
|
|
381
382
|
}
|
|
382
383
|
return result;
|
|
383
384
|
};
|
|
384
|
-
return userContext(merge2(current, userContext(next,
|
|
385
|
+
return userContext(merge2(current, userContext(next, redact3), 0), redact3);
|
|
385
386
|
}
|
|
386
387
|
function toSpanAttributes(context) {
|
|
387
388
|
return Object.fromEntries(
|
|
@@ -473,6 +474,17 @@ function defineRuntimeErrors(namespace, catalog) {
|
|
|
473
474
|
}
|
|
474
475
|
return out;
|
|
475
476
|
}
|
|
477
|
+
function isError(value) {
|
|
478
|
+
if (!value || typeof value !== "object") return false;
|
|
479
|
+
try {
|
|
480
|
+
if (value instanceof Error) return true;
|
|
481
|
+
const native = Error.isError;
|
|
482
|
+
if (typeof native === "function") return native(value) === true;
|
|
483
|
+
return Object.prototype.toString.call(value) === "[object Error]";
|
|
484
|
+
} catch (e10) {
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
476
488
|
function isRuntimeErrorLike(err) {
|
|
477
489
|
if (err instanceof RuntimeError) return true;
|
|
478
490
|
if (!err || typeof err !== "object") return false;
|
|
@@ -483,7 +495,7 @@ function field(err, key) {
|
|
|
483
495
|
if (!err || typeof err !== "object") return void 0;
|
|
484
496
|
try {
|
|
485
497
|
return err[key];
|
|
486
|
-
} catch (
|
|
498
|
+
} catch (e11) {
|
|
487
499
|
return void 0;
|
|
488
500
|
}
|
|
489
501
|
}
|
|
@@ -523,15 +535,15 @@ function errorAttributes(err, options = {}) {
|
|
|
523
535
|
for (let n = 1; n <= CAUSE_DEPTH && cause !== void 0 && cause !== null; n++) {
|
|
524
536
|
if (seen.has(cause)) break;
|
|
525
537
|
seen.add(cause);
|
|
526
|
-
const
|
|
527
|
-
const type =
|
|
528
|
-
const message =
|
|
538
|
+
const isError2 = typeof cause === "object";
|
|
539
|
+
const type = isError2 ? String(_nullishCoalesce(_nullishCoalesce(field(cause, "name"), () => ( _optionalChain([cause, 'access', _10 => _10.constructor, 'optionalAccess', _11 => _11.name]))), () => ( "Error"))) : typeof cause;
|
|
540
|
+
const message = isError2 ? field(cause, "message") : cause;
|
|
529
541
|
out[`exception.cause.${n}.type`] = type.slice(0, 200);
|
|
530
542
|
out[`exception.cause.${n}.message`] = String(_nullishCoalesce(message, () => ( ""))).slice(0, 1e3);
|
|
531
543
|
const causeCode = field(cause, "code");
|
|
532
544
|
if (typeof causeCode === "string" && causeCode)
|
|
533
545
|
out[`exception.cause.${n}.code`] = causeCode.slice(0, CODE_MAX_LENGTH);
|
|
534
|
-
cause =
|
|
546
|
+
cause = isError2 ? field(cause, "cause") : void 0;
|
|
535
547
|
}
|
|
536
548
|
}
|
|
537
549
|
return out;
|
|
@@ -577,19 +589,19 @@ function createInlineLogState(startedAt) {
|
|
|
577
589
|
level: "info"
|
|
578
590
|
};
|
|
579
591
|
}
|
|
580
|
-
function appendInlineLog(state, level, message, attrs,
|
|
592
|
+
function appendInlineLog(state, level, message, attrs, redact3, now = Date.now()) {
|
|
581
593
|
state.level = maxLevel(state.level, level);
|
|
582
594
|
if (state.logs.length >= INLINE_LOG_LIMIT) {
|
|
583
595
|
state.logsTruncated = true;
|
|
584
596
|
return;
|
|
585
597
|
}
|
|
586
|
-
const text = String(_nullishCoalesce(boundContext({ message },
|
|
598
|
+
const text = String(_nullishCoalesce(boundContext({ message }, redact3).message, () => ( ""))).slice(
|
|
587
599
|
0,
|
|
588
600
|
INLINE_MESSAGE_MAX
|
|
589
601
|
);
|
|
590
602
|
let small;
|
|
591
603
|
if (attrs && Object.keys(attrs).length) {
|
|
592
|
-
small = boundContext(attrs,
|
|
604
|
+
small = boundContext(attrs, redact3);
|
|
593
605
|
const encoded = JSON.stringify(small);
|
|
594
606
|
if (encoded.length > 1e3) small = { "autter.context.truncated": true };
|
|
595
607
|
}
|
|
@@ -779,7 +791,7 @@ function parseCarrier(input) {
|
|
|
779
791
|
if (value.length > 1024) return null;
|
|
780
792
|
try {
|
|
781
793
|
value = JSON.parse(value);
|
|
782
|
-
} catch (
|
|
794
|
+
} catch (e12) {
|
|
783
795
|
return null;
|
|
784
796
|
}
|
|
785
797
|
}
|
|
@@ -806,6 +818,172 @@ function parseUserAgent(ua) {
|
|
|
806
818
|
const device = !value ? "unknown" : bot ? "bot" : /iPad|Tablet/.test(value) || /Android/.test(value) && !/Mobile/.test(value) ? "tablet" : /Mobi|iPhone|iPod|Android/.test(value) ? "mobile" : "desktop";
|
|
807
819
|
return { browser, os, device, bot };
|
|
808
820
|
}
|
|
821
|
+
var BREADCRUMBS_ATTRIBUTE = "autter.breadcrumbs";
|
|
822
|
+
var MAX_BREADCRUMBS = 30;
|
|
823
|
+
var MAX_MESSAGE = 500;
|
|
824
|
+
var MAX_DATA_KEYS = 10;
|
|
825
|
+
var MAX_DATA_STRING = 200;
|
|
826
|
+
var BREADCRUMBS_ATTRIBUTE_MAX_CHARS = 16 * 1024;
|
|
827
|
+
var MASK = "[redacted]";
|
|
828
|
+
var TYPES = /* @__PURE__ */ new Set(["console", "request", "navigation", "click", "log", "custom"]);
|
|
829
|
+
var LEVELS = {
|
|
830
|
+
debug: "debug",
|
|
831
|
+
trace: "debug",
|
|
832
|
+
info: "info",
|
|
833
|
+
log: "info",
|
|
834
|
+
warning: "warning",
|
|
835
|
+
warn: "warning",
|
|
836
|
+
error: "error",
|
|
837
|
+
fatal: "error"
|
|
838
|
+
};
|
|
839
|
+
var UNSAFE_KEY = /^(?:__proto__|constructor|prototype)$/;
|
|
840
|
+
function scrubber(redact3) {
|
|
841
|
+
return (value, max) => {
|
|
842
|
+
const scrubbed = redact3({ message: value.slice(0, max + 512) }).message;
|
|
843
|
+
return stripUrlQueries(typeof scrubbed === "string" ? scrubbed : "").slice(0, max);
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
function cleanData(raw, redact3) {
|
|
847
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
848
|
+
const picked = {};
|
|
849
|
+
let count = 0;
|
|
850
|
+
for (const key of Object.keys(raw).slice(0, 64)) {
|
|
851
|
+
if (count >= MAX_DATA_KEYS) break;
|
|
852
|
+
if (!key || UNSAFE_KEY.test(key)) continue;
|
|
853
|
+
const value = raw[key];
|
|
854
|
+
const name = key.slice(0, 100);
|
|
855
|
+
if (typeof value === "string") {
|
|
856
|
+
const text = /(?:url|path|route|target)$/i.test(name) ? value.split(/[?#]/)[0] : value;
|
|
857
|
+
picked[name] = text.slice(0, MAX_DATA_STRING + 512);
|
|
858
|
+
} else if (typeof value === "number") {
|
|
859
|
+
if (!Number.isFinite(value)) continue;
|
|
860
|
+
picked[name] = value;
|
|
861
|
+
} else if (typeof value === "boolean" || value === null) {
|
|
862
|
+
picked[name] = value;
|
|
863
|
+
} else {
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
866
|
+
count++;
|
|
867
|
+
}
|
|
868
|
+
if (count === 0) return void 0;
|
|
869
|
+
const redacted = redact3(picked);
|
|
870
|
+
const out = {};
|
|
871
|
+
for (const key of Object.keys(picked)) {
|
|
872
|
+
const value = key in redacted ? redacted[key] : picked[key];
|
|
873
|
+
out[key] = typeof value === "string" ? stripUrlQueries(value).slice(0, MAX_DATA_STRING) : value;
|
|
874
|
+
}
|
|
875
|
+
return out;
|
|
876
|
+
}
|
|
877
|
+
function timestamp(value) {
|
|
878
|
+
if (value === void 0) return (/* @__PURE__ */ new Date()).toISOString();
|
|
879
|
+
if (typeof value !== "string" && typeof value !== "number" && !(value instanceof Date)) return null;
|
|
880
|
+
const at = new Date(value);
|
|
881
|
+
return Number.isNaN(at.getTime()) ? null : at.toISOString();
|
|
882
|
+
}
|
|
883
|
+
function normalizeBreadcrumb(input, redact3, options = {}) {
|
|
884
|
+
try {
|
|
885
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) return null;
|
|
886
|
+
const raw = input;
|
|
887
|
+
if (options.requireAt && raw.at === void 0) return null;
|
|
888
|
+
const at = timestamp(raw.at);
|
|
889
|
+
if (!at) return null;
|
|
890
|
+
const rawMessage = raw.message;
|
|
891
|
+
const message = typeof rawMessage === "string" ? rawMessage : typeof rawMessage === "number" || typeof rawMessage === "boolean" ? String(rawMessage) : "";
|
|
892
|
+
const data = cleanData(raw.data, redact3);
|
|
893
|
+
if (!message && !data) return null;
|
|
894
|
+
const type = typeof raw.type === "string" && TYPES.has(raw.type) ? raw.type : "custom";
|
|
895
|
+
const level = typeof raw.level === "string" ? LEVELS[raw.level.toLowerCase()] : void 0;
|
|
896
|
+
return {
|
|
897
|
+
type,
|
|
898
|
+
at,
|
|
899
|
+
...level ? { level } : {},
|
|
900
|
+
message: scrubber(redact3)(message, MAX_MESSAGE),
|
|
901
|
+
...data ? { data } : {}
|
|
902
|
+
};
|
|
903
|
+
} catch (e13) {
|
|
904
|
+
return null;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
function sanitizeBreadcrumbs(raw, redact3) {
|
|
908
|
+
const out = [];
|
|
909
|
+
try {
|
|
910
|
+
if (!Array.isArray(raw)) return void 0;
|
|
911
|
+
const first = Math.max(0, raw.length - 200);
|
|
912
|
+
for (let i = raw.length - 1; i >= first && out.length < MAX_BREADCRUMBS; i--) {
|
|
913
|
+
const crumb = normalizeBreadcrumb(raw[i], redact3, { requireAt: true });
|
|
914
|
+
if (crumb) out.push(crumb);
|
|
915
|
+
}
|
|
916
|
+
} catch (e14) {
|
|
917
|
+
}
|
|
918
|
+
return out.length ? out.reverse() : void 0;
|
|
919
|
+
}
|
|
920
|
+
var BreadcrumbTrail = (_class = class {
|
|
921
|
+
constructor(max = MAX_BREADCRUMBS) {;_class.prototype.__init.call(this);
|
|
922
|
+
this.max = max;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
__init() {this.items = []}
|
|
926
|
+
add(crumb) {
|
|
927
|
+
this.items.push(crumb);
|
|
928
|
+
if (this.items.length > this.max) this.items.splice(0, this.items.length - this.max);
|
|
929
|
+
}
|
|
930
|
+
/** Copies, oldest first. */
|
|
931
|
+
list() {
|
|
932
|
+
return this.items.map((crumb) => ({ ...crumb, ...crumb.data ? { data: { ...crumb.data } } : {} }));
|
|
933
|
+
}
|
|
934
|
+
get size() {
|
|
935
|
+
return this.items.length;
|
|
936
|
+
}
|
|
937
|
+
clear() {
|
|
938
|
+
this.items = [];
|
|
939
|
+
}
|
|
940
|
+
}, _class);
|
|
941
|
+
function breadcrumbsAttribute(list, scrub, maxChars = BREADCRUMBS_ATTRIBUTE_MAX_CHARS) {
|
|
942
|
+
const parts = [];
|
|
943
|
+
let chars = 2;
|
|
944
|
+
for (let i = list.length - 1; i >= 0 && parts.length < MAX_BREADCRUMBS; i--) {
|
|
945
|
+
const crumb = list[i];
|
|
946
|
+
let json = JSON.stringify(crumb);
|
|
947
|
+
if (scrub(json) !== json) {
|
|
948
|
+
json = JSON.stringify({ type: crumb.type, at: crumb.at, ...crumb.level ? { level: crumb.level } : {}, message: MASK });
|
|
949
|
+
}
|
|
950
|
+
if (chars + json.length + 1 > maxChars) break;
|
|
951
|
+
chars += json.length + 1;
|
|
952
|
+
parts.push(json);
|
|
953
|
+
}
|
|
954
|
+
if (parts.length === 0) return void 0;
|
|
955
|
+
const out = `[${parts.reverse().join(",")}]`;
|
|
956
|
+
return scrub(out) === out ? out : void 0;
|
|
957
|
+
}
|
|
958
|
+
var FINGERPRINT_ATTRIBUTE = "autter.fingerprint";
|
|
959
|
+
var FINGERPRINT_MAX_VALUES = 10;
|
|
960
|
+
var FINGERPRINT_MAX_LENGTH = 200;
|
|
961
|
+
function fingerprintValues(value, scrub = (text) => text) {
|
|
962
|
+
const list = Array.isArray(value) ? value : [value];
|
|
963
|
+
const values = list.filter((item) => typeof item === "string" && item !== "").slice(0, FINGERPRINT_MAX_VALUES).map((item) => scrub(item.slice(0, FINGERPRINT_MAX_LENGTH + 512)).slice(0, FINGERPRINT_MAX_LENGTH)).filter((item) => item !== "");
|
|
964
|
+
return values.length > 0 ? values : void 0;
|
|
965
|
+
}
|
|
966
|
+
function fingerprintEventAttributes(value, scrub) {
|
|
967
|
+
const values = fingerprintValues(value, scrub);
|
|
968
|
+
return values ? { [FINGERPRINT_ATTRIBUTE]: JSON.stringify(values) } : {};
|
|
969
|
+
}
|
|
970
|
+
function splitFingerprint(attributes) {
|
|
971
|
+
if (!attributes || typeof attributes !== "object" || !("fingerprint" in attributes)) {
|
|
972
|
+
return { attributes: _nullishCoalesce(attributes, () => ( void 0)), fingerprint: void 0 };
|
|
973
|
+
}
|
|
974
|
+
const { fingerprint, ...rest } = attributes;
|
|
975
|
+
return { attributes: rest, fingerprint };
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
// src/breadcrumbs.ts
|
|
979
|
+
var _api = require('@opentelemetry/api');
|
|
980
|
+
|
|
981
|
+
// src/logger.ts
|
|
982
|
+
var _async_hooks = require('async_hooks');
|
|
983
|
+
var _crypto = require('crypto');
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
|
|
809
987
|
|
|
810
988
|
// src/sinks.ts
|
|
811
989
|
|
|
@@ -816,7 +994,7 @@ function parseUserAgent(ua) {
|
|
|
816
994
|
|
|
817
995
|
var _fs = require('fs');
|
|
818
996
|
var _path = require('path');
|
|
819
|
-
var sinkStats = { dropped: 0 };
|
|
997
|
+
var sinkStats = _chunk4MVWIRBIcjs.sharedSlot.call(void 0, "sinks", () => ({ dropped: 0 }));
|
|
820
998
|
function otlpSink(options = {}) {
|
|
821
999
|
let context = null;
|
|
822
1000
|
let queue = [];
|
|
@@ -892,7 +1070,7 @@ function otlpSink(options = {}) {
|
|
|
892
1070
|
Math.max(1, Math.min(3e3, deadline - Date.now()))
|
|
893
1071
|
)
|
|
894
1072
|
});
|
|
895
|
-
|
|
1073
|
+
_chunk4MVWIRBIcjs.observeIngesterResponse.call(void 0, { status: response.status, headers: response.headers, route: "/v1/logs" });
|
|
896
1074
|
if (!response.ok)
|
|
897
1075
|
throw new Error(`Runtime log export failed (${response.status})`);
|
|
898
1076
|
failure = void 0;
|
|
@@ -942,7 +1120,7 @@ function otlpSink(options = {}) {
|
|
|
942
1120
|
}
|
|
943
1121
|
queue.push({ record, bytes });
|
|
944
1122
|
queueBytes += bytes;
|
|
945
|
-
|
|
1123
|
+
_chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "operation_logging");
|
|
946
1124
|
scheduleFlush();
|
|
947
1125
|
},
|
|
948
1126
|
flush,
|
|
@@ -1115,7 +1293,7 @@ function fileSink(options = {}) {
|
|
|
1115
1293
|
index = sameDay.length ? sameDay[sameDay.length - 1].index : 0;
|
|
1116
1294
|
try {
|
|
1117
1295
|
currentBytes = _fs.statSync.call(void 0, _path.join.call(void 0, dir, fileName(day, index))).size;
|
|
1118
|
-
} catch (
|
|
1296
|
+
} catch (e15) {
|
|
1119
1297
|
currentBytes = 0;
|
|
1120
1298
|
}
|
|
1121
1299
|
prune();
|
|
@@ -1185,23 +1363,22 @@ function memorySink() {
|
|
|
1185
1363
|
}
|
|
1186
1364
|
|
|
1187
1365
|
// src/logger.ts
|
|
1188
|
-
var
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
var
|
|
1195
|
-
var
|
|
1196
|
-
var extraSinks = /* @__PURE__ */ new Set();
|
|
1366
|
+
var shared = _chunk4MVWIRBIcjs.sharedSlot.call(void 0, "logger", () => ({
|
|
1367
|
+
local: new (0, _async_hooks.AsyncLocalStorage)(),
|
|
1368
|
+
config: null,
|
|
1369
|
+
sinks: [],
|
|
1370
|
+
extraSinks: /* @__PURE__ */ new Set()
|
|
1371
|
+
}));
|
|
1372
|
+
var local = shared.local;
|
|
1373
|
+
var extraSinks = shared.extraSinks;
|
|
1197
1374
|
var fallbackConsole = null;
|
|
1198
1375
|
function redact(attributes) {
|
|
1199
|
-
return _nullishCoalesce(_optionalChain([
|
|
1376
|
+
return _nullishCoalesce(_optionalChain([shared, 'access', _16 => _16.config, 'optionalAccess', _17 => _17.redact, 'call', _18 => _18(attributes)]), () => ( redactAttributes(attributes)));
|
|
1200
1377
|
}
|
|
1201
1378
|
var safe = (attributes = {}) => boundContext(attributes, redact);
|
|
1202
1379
|
var merge = (current, next) => mergeContext(current, next, redact);
|
|
1203
1380
|
function activeSinks() {
|
|
1204
|
-
if (config) return extraSinks.size ? [...sinks, ...extraSinks] : sinks;
|
|
1381
|
+
if (shared.config) return extraSinks.size ? [...shared.sinks, ...extraSinks] : shared.sinks;
|
|
1205
1382
|
if (extraSinks.size) return [...extraSinks];
|
|
1206
1383
|
fallbackConsole ??= consoleSink();
|
|
1207
1384
|
return [fallbackConsole];
|
|
@@ -1235,11 +1412,12 @@ function traceAttributes(state) {
|
|
|
1235
1412
|
}
|
|
1236
1413
|
function emit(level, message, attributes, extra = {}, options = {}) {
|
|
1237
1414
|
const state = options.state !== void 0 ? _nullishCoalesce(options.state, () => ( void 0)) : local.getStore();
|
|
1238
|
-
if (_optionalChain([state, 'optionalAccess',
|
|
1415
|
+
if (_optionalChain([state, 'optionalAccess', _19 => _19.sealed])) return;
|
|
1239
1416
|
const summary = extra["autter.event.type"] === "operation";
|
|
1240
|
-
if (!summary
|
|
1417
|
+
if (!summary) recordLogBreadcrumb(level, message, attributes, state);
|
|
1418
|
+
if (!summary && LEVEL_SEVERITY[level] < LEVEL_SEVERITY[_nullishCoalesce(_optionalChain([shared, 'access', _20 => _20.config, 'optionalAccess', _21 => _21.options, 'optionalAccess', _22 => _22.minLevel]), () => ( "debug"))])
|
|
1241
1419
|
return;
|
|
1242
|
-
if (!summary && state && _optionalChain([config, 'optionalAccess',
|
|
1420
|
+
if (!summary && state && _optionalChain([shared, 'access', _23 => _23.config, 'optionalAccess', _24 => _24.options, 'optionalAccess', _25 => _25.inline]) !== false) {
|
|
1243
1421
|
const { "exception.stacktrace": _stack, ...inlineAttrs } = userContext(
|
|
1244
1422
|
attributes,
|
|
1245
1423
|
redact
|
|
@@ -1247,8 +1425,8 @@ function emit(level, message, attributes, extra = {}, options = {}) {
|
|
|
1247
1425
|
appendInlineLog(state.inline, level, message, inlineAttrs, redact);
|
|
1248
1426
|
if (level === "debug" || level === "info") return;
|
|
1249
1427
|
}
|
|
1250
|
-
const span = _nullishCoalesce(options.span, () => ( _optionalChain([_api.trace, 'access',
|
|
1251
|
-
const user = merge(_nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
1428
|
+
const span = _nullishCoalesce(options.span, () => ( _optionalChain([_api.trace, 'access', _26 => _26.getActiveSpan, 'call', _27 => _27(), 'optionalAccess', _28 => _28.spanContext, 'call', _29 => _29()])));
|
|
1429
|
+
const user = merge(_nullishCoalesce(_optionalChain([state, 'optionalAccess', _30 => _30.attributes]), () => ( {})), attributes);
|
|
1252
1430
|
const exceptions = Object.fromEntries(
|
|
1253
1431
|
Object.entries(user).filter(([key]) => key.startsWith("exception."))
|
|
1254
1432
|
);
|
|
@@ -1259,8 +1437,8 @@ function emit(level, message, attributes, extra = {}, options = {}) {
|
|
|
1259
1437
|
...operationAttributes(state),
|
|
1260
1438
|
...user
|
|
1261
1439
|
};
|
|
1262
|
-
const enrichers = _optionalChain([config, 'optionalAccess',
|
|
1263
|
-
if (summary && state && _optionalChain([enrichers, 'optionalAccess',
|
|
1440
|
+
const enrichers = _optionalChain([shared, 'access', _31 => _31.config, 'optionalAccess', _32 => _32.options, 'optionalAccess', _33 => _33.enrich]);
|
|
1441
|
+
if (summary && state && _optionalChain([enrichers, 'optionalAccess', _34 => _34.length])) {
|
|
1264
1442
|
const event2 = { level, message, attributes: raw };
|
|
1265
1443
|
for (const enrich of enrichers) {
|
|
1266
1444
|
try {
|
|
@@ -1269,7 +1447,7 @@ function emit(level, message, attributes, extra = {}, options = {}) {
|
|
|
1269
1447
|
res: state.res,
|
|
1270
1448
|
operation: { id: state.id, name: state.name, kind: state.kind }
|
|
1271
1449
|
});
|
|
1272
|
-
} catch (
|
|
1450
|
+
} catch (e16) {
|
|
1273
1451
|
}
|
|
1274
1452
|
}
|
|
1275
1453
|
}
|
|
@@ -1282,16 +1460,16 @@ function emit(level, message, attributes, extra = {}, options = {}) {
|
|
|
1282
1460
|
for (const sink of activeSinks()) {
|
|
1283
1461
|
try {
|
|
1284
1462
|
sink.write(event);
|
|
1285
|
-
} catch (
|
|
1463
|
+
} catch (e17) {
|
|
1286
1464
|
}
|
|
1287
1465
|
}
|
|
1288
1466
|
}
|
|
1289
1467
|
function configureRuntimeLogger(next) {
|
|
1290
|
-
config = next;
|
|
1291
|
-
sinks = defaultSinks(next);
|
|
1292
|
-
for (const sink of sinks) {
|
|
1468
|
+
shared.config = next;
|
|
1469
|
+
shared.sinks = defaultSinks(next);
|
|
1470
|
+
for (const sink of shared.sinks) {
|
|
1293
1471
|
try {
|
|
1294
|
-
_optionalChain([sink, 'access',
|
|
1472
|
+
_optionalChain([sink, 'access', _35 => _35.start, 'optionalCall', _36 => _36({
|
|
1295
1473
|
endpoint: next.endpoint,
|
|
1296
1474
|
apiKey: next.apiKey,
|
|
1297
1475
|
service: next.service,
|
|
@@ -1299,54 +1477,57 @@ function configureRuntimeLogger(next) {
|
|
|
1299
1477
|
...next.release ? { release: next.release } : {},
|
|
1300
1478
|
...next.distro ? { distro: next.distro } : {}
|
|
1301
1479
|
})]);
|
|
1302
|
-
} catch (
|
|
1480
|
+
} catch (e18) {
|
|
1303
1481
|
}
|
|
1304
1482
|
}
|
|
1305
1483
|
}
|
|
1484
|
+
function loggerConfigured() {
|
|
1485
|
+
return shared.config;
|
|
1486
|
+
}
|
|
1306
1487
|
function addRuntimeSink(sink) {
|
|
1307
1488
|
extraSinks.add(sink);
|
|
1308
1489
|
return () => extraSinks.delete(sink);
|
|
1309
1490
|
}
|
|
1310
1491
|
function notifyException(error, attributes = {}) {
|
|
1311
|
-
if (!extraSinks.size && !sinks.some((sink) => sink.exception)) return;
|
|
1492
|
+
if (!extraSinks.size && !shared.sinks.some((sink) => sink.exception)) return;
|
|
1312
1493
|
const state = local.getStore();
|
|
1313
1494
|
const record = {
|
|
1314
1495
|
time: Date.now(),
|
|
1315
1496
|
error,
|
|
1316
|
-
message: error
|
|
1317
|
-
type: error
|
|
1497
|
+
message: isError(error) ? error.message : String(error),
|
|
1498
|
+
type: isError(error) ? error.name : "Error",
|
|
1318
1499
|
attributes: { ...attributes, ...errorAttributes(error) },
|
|
1319
1500
|
...state ? { operationId: state.id } : {},
|
|
1320
|
-
..._optionalChain([state, 'optionalAccess',
|
|
1501
|
+
..._optionalChain([state, 'optionalAccess', _37 => _37.requestId]) ? { requestId: state.requestId } : {}
|
|
1321
1502
|
};
|
|
1322
|
-
for (const sink of [...sinks, ...extraSinks]) {
|
|
1503
|
+
for (const sink of [...shared.sinks, ...extraSinks]) {
|
|
1323
1504
|
try {
|
|
1324
|
-
_optionalChain([sink, 'access',
|
|
1325
|
-
} catch (
|
|
1505
|
+
_optionalChain([sink, 'access', _38 => _38.exception, 'optionalCall', _39 => _39(record)]);
|
|
1506
|
+
} catch (e19) {
|
|
1326
1507
|
}
|
|
1327
1508
|
}
|
|
1328
1509
|
}
|
|
1329
1510
|
function runtimeLogStats() {
|
|
1330
1511
|
return {
|
|
1331
|
-
buffered: sinks.reduce((sum, sink) => sum + (_nullishCoalesce(_optionalChain([sink, 'access',
|
|
1512
|
+
buffered: shared.sinks.reduce((sum, sink) => sum + (_nullishCoalesce(_optionalChain([sink, 'access', _40 => _40.buffered, 'optionalCall', _41 => _41()]), () => ( 0))), 0),
|
|
1332
1513
|
dropped: sinkStats.dropped
|
|
1333
1514
|
};
|
|
1334
1515
|
}
|
|
1335
1516
|
async function flushRuntimeLogs() {
|
|
1336
|
-
if (!config) return;
|
|
1517
|
+
if (!shared.config) return;
|
|
1337
1518
|
const results = await Promise.allSettled(
|
|
1338
|
-
sinks.map((sink) => Promise.resolve().then(() => _optionalChain([sink, 'access',
|
|
1519
|
+
shared.sinks.map((sink) => Promise.resolve().then(() => _optionalChain([sink, 'access', _42 => _42.flush, 'optionalCall', _43 => _43()])))
|
|
1339
1520
|
);
|
|
1340
1521
|
const failed = results.find((result) => result.status === "rejected");
|
|
1341
1522
|
if (failed) throw failed.reason;
|
|
1342
1523
|
}
|
|
1343
1524
|
async function shutdownRuntimeLogger() {
|
|
1344
|
-
const active = sinks;
|
|
1525
|
+
const active = shared.sinks;
|
|
1345
1526
|
const results = await Promise.allSettled(
|
|
1346
|
-
active.map((sink) => Promise.resolve().then(() => _optionalChain([sink, 'access',
|
|
1527
|
+
active.map((sink) => Promise.resolve().then(() => _optionalChain([sink, 'access', _44 => _44.shutdown, 'optionalCall', _45 => _45()])))
|
|
1347
1528
|
);
|
|
1348
|
-
config = null;
|
|
1349
|
-
sinks = [];
|
|
1529
|
+
shared.config = null;
|
|
1530
|
+
shared.sinks = [];
|
|
1350
1531
|
const failed = results.find((result) => result.status === "rejected");
|
|
1351
1532
|
if (failed) throw failed.reason;
|
|
1352
1533
|
}
|
|
@@ -1367,11 +1548,11 @@ function createRuntimeLogger(attributes = {}) {
|
|
|
1367
1548
|
warn: (message, extra) => emit("warning", message, merge(attrs, extra)),
|
|
1368
1549
|
error: (error, extra) => emit(
|
|
1369
1550
|
"error",
|
|
1370
|
-
error
|
|
1551
|
+
isError(error) ? error.message : String(error),
|
|
1371
1552
|
{
|
|
1372
1553
|
...attrs,
|
|
1373
1554
|
...extra,
|
|
1374
|
-
...error
|
|
1555
|
+
...isError(error) ? {
|
|
1375
1556
|
"exception.type": error.name,
|
|
1376
1557
|
"exception.stacktrace": _nullishCoalesce(error.stack, () => ( ""))
|
|
1377
1558
|
} : {}
|
|
@@ -1382,16 +1563,16 @@ function createRuntimeLogger(attributes = {}) {
|
|
|
1382
1563
|
}
|
|
1383
1564
|
var runtimeLogger = createRuntimeLogger();
|
|
1384
1565
|
function captureExceptionAsLog(error, attributes = {}) {
|
|
1385
|
-
const
|
|
1386
|
-
const message =
|
|
1387
|
-
const stack =
|
|
1566
|
+
const isErr = isError(error);
|
|
1567
|
+
const message = isErr ? error.message : String(error);
|
|
1568
|
+
const stack = isErr && error.stack ? error.stack : _nullishCoalesce(_optionalChain([new Error(), 'access', _46 => _46.stack, 'optionalAccess', _47 => _47.split, 'call', _48 => _48("\n"), 'access', _49 => _49.filter, 'call', _50 => _50((line, i) => i === 0 || !/captureException/.test(line)), 'access', _51 => _51.join, 'call', _52 => _52("\n")]), () => ( ""));
|
|
1388
1569
|
noteOperationError(error);
|
|
1389
1570
|
emit(
|
|
1390
1571
|
"error",
|
|
1391
1572
|
message,
|
|
1392
1573
|
{
|
|
1393
1574
|
...attributes,
|
|
1394
|
-
"exception.type":
|
|
1575
|
+
"exception.type": isErr ? error.name : "Error",
|
|
1395
1576
|
"exception.message": message,
|
|
1396
1577
|
"exception.stacktrace": stack
|
|
1397
1578
|
},
|
|
@@ -1438,7 +1619,7 @@ function operationHandle(state) {
|
|
|
1438
1619
|
setContext: (attrs) => {
|
|
1439
1620
|
if (!state.sealed) {
|
|
1440
1621
|
state.attributes = merge(state.attributes, attrs);
|
|
1441
|
-
_optionalChain([_api.trace, 'access',
|
|
1622
|
+
_optionalChain([_api.trace, 'access', _53 => _53.getActiveSpan, 'call', _54 => _54(), 'optionalAccess', _55 => _55.setAttributes, 'call', _56 => _56(traceAttributes(state))]);
|
|
1442
1623
|
}
|
|
1443
1624
|
},
|
|
1444
1625
|
outcome: (status, message) => setOutcome(state, status, message),
|
|
@@ -1486,7 +1667,7 @@ function emitSummary(state, options = {}) {
|
|
|
1486
1667
|
_nullishCoalesce(state.message, () => ( `${state.name}: ${state.outcome}`)),
|
|
1487
1668
|
{
|
|
1488
1669
|
...operationAttributes(state),
|
|
1489
|
-
...err
|
|
1670
|
+
...isError(err) ? {
|
|
1490
1671
|
"exception.type": err.name,
|
|
1491
1672
|
"exception.stacktrace": _nullishCoalesce(err.stack, () => ( ""))
|
|
1492
1673
|
} : {}
|
|
@@ -1498,7 +1679,7 @@ function emitSummary(state, options = {}) {
|
|
|
1498
1679
|
}
|
|
1499
1680
|
function reportExplicitFailure(state) {
|
|
1500
1681
|
if (state.outcome === "failed" && state.explicitOutcome && !state.errorThrown)
|
|
1501
|
-
_optionalChain([config, 'optionalAccess',
|
|
1682
|
+
_optionalChain([shared, 'access', _57 => _57.config, 'optionalAccess', _58 => _58.reportOutcome, 'call', _59 => _59(state.name, _nullishCoalesce(state.message, () => ( "Operation failed")), {
|
|
1502
1683
|
...traceAttributes(state),
|
|
1503
1684
|
"autter.outcome.stack": _nullishCoalesce(state.reportingStack, () => ( ""))
|
|
1504
1685
|
})]);
|
|
@@ -1506,7 +1687,7 @@ function reportExplicitFailure(state) {
|
|
|
1506
1687
|
function startOperation(name, fn, attributes, options, internal = {}) {
|
|
1507
1688
|
const parent = _nullishCoalesce(internal.forkParent, () => ( local.getStore()));
|
|
1508
1689
|
const carrier = options.from ? parseCarrier(options.from) : null;
|
|
1509
|
-
const traceparent = _optionalChain([carrier, 'optionalAccess',
|
|
1690
|
+
const traceparent = _optionalChain([carrier, 'optionalAccess', _60 => _60.traceparent]) ? parseTraceparent(carrier.traceparent) : null;
|
|
1510
1691
|
const linked = internal.forkParent !== void 0 || parent && !parent.sealed;
|
|
1511
1692
|
const state = newState(
|
|
1512
1693
|
name,
|
|
@@ -1518,9 +1699,10 @@ function startOperation(name, fn, attributes, options, internal = {}) {
|
|
|
1518
1699
|
...traceparent ? { parentTraceId: traceparent.traceId } : {}
|
|
1519
1700
|
} : {
|
|
1520
1701
|
...linked && parent ? { parentId: parent.id, base: parent.attributes } : {},
|
|
1521
|
-
..._optionalChain([parent, 'optionalAccess',
|
|
1702
|
+
..._optionalChain([parent, 'optionalAccess', _61 => _61.requestId]) ? { requestId: parent.requestId } : {}
|
|
1522
1703
|
}
|
|
1523
1704
|
);
|
|
1705
|
+
if (linked && parent) state.breadcrumbs = parent.breadcrumbs ??= new BreadcrumbTrail();
|
|
1524
1706
|
const operation = operationHandle(state);
|
|
1525
1707
|
const run = () => local.run(state, async () => {
|
|
1526
1708
|
let thrown;
|
|
@@ -1530,16 +1712,17 @@ function startOperation(name, fn, attributes, options, internal = {}) {
|
|
|
1530
1712
|
state.outcome = "failed";
|
|
1531
1713
|
thrown = error;
|
|
1532
1714
|
noteOperationError(error, true, state);
|
|
1533
|
-
|
|
1715
|
+
rememberThrownBreadcrumbs(error, state);
|
|
1716
|
+
_optionalChain([shared, 'access', _62 => _62.config, 'optionalAccess', _63 => _63.captureThrown, 'optionalCall', _64 => _64(error)]);
|
|
1534
1717
|
throw error;
|
|
1535
1718
|
} finally {
|
|
1536
|
-
_optionalChain([_api.trace, 'access',
|
|
1719
|
+
_optionalChain([_api.trace, 'access', _65 => _65.getActiveSpan, 'call', _66 => _66(), 'optionalAccess', _67 => _67.setAttributes, 'call', _68 => _68({
|
|
1537
1720
|
...traceAttributes(state),
|
|
1538
1721
|
"autter.operation.outcome": state.outcome,
|
|
1539
1722
|
"autter.operation.kind": state.kind
|
|
1540
1723
|
})]);
|
|
1541
1724
|
if (state.outcome === "failed" && !thrown)
|
|
1542
|
-
_optionalChain([config, 'optionalAccess',
|
|
1725
|
+
_optionalChain([shared, 'access', _69 => _69.config, 'optionalAccess', _70 => _70.reportOutcome, 'call', _71 => _71(
|
|
1543
1726
|
state.name,
|
|
1544
1727
|
_nullishCoalesce(state.message, () => ( "Operation failed")),
|
|
1545
1728
|
{
|
|
@@ -1560,14 +1743,14 @@ function startOperation(name, fn, attributes, options, internal = {}) {
|
|
|
1560
1743
|
}
|
|
1561
1744
|
}
|
|
1562
1745
|
] : [];
|
|
1563
|
-
const promise = _optionalChain([config, 'optionalAccess',
|
|
1746
|
+
const promise = _optionalChain([shared, 'access', _72 => _72.config, 'optionalAccess', _73 => _73.run]) ? shared.config.run(state.name, run, traceAttributes(state), links) : run();
|
|
1564
1747
|
if (!options.waitUntil) return promise;
|
|
1565
1748
|
const waitUntil = options.waitUntil;
|
|
1566
1749
|
return promise.finally(() => {
|
|
1567
1750
|
try {
|
|
1568
1751
|
waitUntil(flushRuntimeLogs().catch(() => {
|
|
1569
1752
|
}));
|
|
1570
|
-
} catch (
|
|
1753
|
+
} catch (e20) {
|
|
1571
1754
|
}
|
|
1572
1755
|
});
|
|
1573
1756
|
}
|
|
@@ -1583,7 +1766,7 @@ var runtimeContext = {
|
|
|
1583
1766
|
const state = currentOperation();
|
|
1584
1767
|
if (!state) return;
|
|
1585
1768
|
state.attributes = merge(state.attributes, attributes);
|
|
1586
|
-
_optionalChain([_api.trace, 'access',
|
|
1769
|
+
_optionalChain([_api.trace, 'access', _74 => _74.getActiveSpan, 'call', _75 => _75(), 'optionalAccess', _76 => _76.setAttributes, 'call', _77 => _77(traceAttributes(state))]);
|
|
1587
1770
|
},
|
|
1588
1771
|
/** Set the outcome explicitly (wins over status/thrown-error rules). */
|
|
1589
1772
|
outcome(status, message) {
|
|
@@ -1606,11 +1789,11 @@ var runtimeContext = {
|
|
|
1606
1789
|
},
|
|
1607
1790
|
/** Current operation id. */
|
|
1608
1791
|
get id() {
|
|
1609
|
-
return _optionalChain([local, 'access',
|
|
1792
|
+
return _optionalChain([local, 'access', _78 => _78.getStore, 'call', _79 => _79(), 'optionalAccess', _80 => _80.id]);
|
|
1610
1793
|
},
|
|
1611
1794
|
/** Current request id (inherited by child operations and forks). */
|
|
1612
1795
|
get requestId() {
|
|
1613
|
-
return _optionalChain([local, 'access',
|
|
1796
|
+
return _optionalChain([local, 'access', _81 => _81.getStore, 'call', _82 => _82(), 'optionalAccess', _83 => _83.requestId]);
|
|
1614
1797
|
},
|
|
1615
1798
|
/**
|
|
1616
1799
|
* Run `fn` as a child operation whose parent link is captured NOW, so it
|
|
@@ -1624,7 +1807,7 @@ var runtimeContext = {
|
|
|
1624
1807
|
carrier() {
|
|
1625
1808
|
const state = local.getStore();
|
|
1626
1809
|
if (!state) return void 0;
|
|
1627
|
-
const span = _optionalChain([_api.trace, 'access',
|
|
1810
|
+
const span = _optionalChain([_api.trace, 'access', _84 => _84.getActiveSpan, 'call', _85 => _85(), 'optionalAccess', _86 => _86.spanContext, 'call', _87 => _87()]);
|
|
1628
1811
|
const traceparent = span ? formatTraceparent(span.traceId, span.spanId, (span.traceFlags & 1) === 1) : void 0;
|
|
1629
1812
|
return createCarrier({
|
|
1630
1813
|
op: state.id,
|
|
@@ -1634,6 +1817,95 @@ var runtimeContext = {
|
|
|
1634
1817
|
}
|
|
1635
1818
|
};
|
|
1636
1819
|
|
|
1820
|
+
// src/breadcrumbs.ts
|
|
1821
|
+
var INVALID_TRACE_ID = "00000000000000000000000000000000";
|
|
1822
|
+
var MAX_TRACE_TRAILS = 200;
|
|
1823
|
+
var trails = _chunk4MVWIRBIcjs.sharedSlot.call(void 0, "breadcrumbs", () => ({
|
|
1824
|
+
byTrace: /* @__PURE__ */ new Map(),
|
|
1825
|
+
process: new BreadcrumbTrail(),
|
|
1826
|
+
thrown: /* @__PURE__ */ new WeakMap()
|
|
1827
|
+
}));
|
|
1828
|
+
var byTrace = trails.byTrace;
|
|
1829
|
+
var processTrail = trails.process;
|
|
1830
|
+
var thrownTrails = trails.thrown;
|
|
1831
|
+
function redact2(attributes) {
|
|
1832
|
+
return _nullishCoalesce(_optionalChain([loggerConfigured, 'call', _88 => _88(), 'optionalAccess', _89 => _89.redact, 'call', _90 => _90(attributes)]), () => ( redactAttributes(attributes)));
|
|
1833
|
+
}
|
|
1834
|
+
function trailFor(create, state = local.getStore()) {
|
|
1835
|
+
if (state) {
|
|
1836
|
+
if (!state.breadcrumbs && create) state.breadcrumbs = new BreadcrumbTrail();
|
|
1837
|
+
return state.breadcrumbs;
|
|
1838
|
+
}
|
|
1839
|
+
const traceId = _optionalChain([_api.trace, 'access', _91 => _91.getActiveSpan, 'call', _92 => _92(), 'optionalAccess', _93 => _93.spanContext, 'call', _94 => _94(), 'access', _95 => _95.traceId]);
|
|
1840
|
+
if (traceId && traceId !== INVALID_TRACE_ID) {
|
|
1841
|
+
let trail = byTrace.get(traceId);
|
|
1842
|
+
if (!trail && create) {
|
|
1843
|
+
trail = new BreadcrumbTrail();
|
|
1844
|
+
byTrace.set(traceId, trail);
|
|
1845
|
+
if (byTrace.size > MAX_TRACE_TRAILS) {
|
|
1846
|
+
const oldest = byTrace.keys().next().value;
|
|
1847
|
+
if (oldest !== void 0) byTrace.delete(oldest);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
return trail;
|
|
1851
|
+
}
|
|
1852
|
+
return processTrail;
|
|
1853
|
+
}
|
|
1854
|
+
function addBreadcrumb(input) {
|
|
1855
|
+
try {
|
|
1856
|
+
const crumb = normalizeBreadcrumb(input, redact2);
|
|
1857
|
+
if (!crumb) return;
|
|
1858
|
+
_optionalChain([trailFor, 'call', _96 => _96(true), 'optionalAccess', _97 => _97.add, 'call', _98 => _98(crumb)]);
|
|
1859
|
+
_chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "breadcrumbs");
|
|
1860
|
+
} catch (e21) {
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
function recordLogBreadcrumb(level, message, attributes, state) {
|
|
1864
|
+
try {
|
|
1865
|
+
const data = {};
|
|
1866
|
+
let count = 0;
|
|
1867
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
1868
|
+
if (count >= 10) break;
|
|
1869
|
+
if (/^(?:exception|autter)\./.test(key)) continue;
|
|
1870
|
+
if (value === null || ["string", "number", "boolean"].includes(typeof value)) {
|
|
1871
|
+
data[key] = value;
|
|
1872
|
+
count++;
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
const crumb = normalizeBreadcrumb({ type: "log", level, message, data }, redact2);
|
|
1876
|
+
if (crumb) _optionalChain([trailFor, 'call', _99 => _99(true, state), 'optionalAccess', _100 => _100.add, 'call', _101 => _101(crumb)]);
|
|
1877
|
+
} catch (e22) {
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
function attributeBudget() {
|
|
1881
|
+
const limit = Number(
|
|
1882
|
+
_nullishCoalesce(process.env.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, () => ( process.env.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT))
|
|
1883
|
+
);
|
|
1884
|
+
return Number.isFinite(limit) && limit > 0 ? Math.min(BREADCRUMBS_ATTRIBUTE_MAX_CHARS, limit) : BREADCRUMBS_ATTRIBUTE_MAX_CHARS;
|
|
1885
|
+
}
|
|
1886
|
+
function rememberThrownBreadcrumbs(error, state) {
|
|
1887
|
+
if (state.breadcrumbs && error !== null && (typeof error === "object" || typeof error === "function"))
|
|
1888
|
+
thrownTrails.set(error, state.breadcrumbs);
|
|
1889
|
+
}
|
|
1890
|
+
function breadcrumbEventAttributes(scrub, error) {
|
|
1891
|
+
try {
|
|
1892
|
+
const thrown = error !== null && typeof error === "object" ? thrownTrails.get(error) : void 0;
|
|
1893
|
+
const trail = _nullishCoalesce(thrown, () => ( trailFor(false)));
|
|
1894
|
+
if (!_optionalChain([trail, 'optionalAccess', _102 => _102.size])) return {};
|
|
1895
|
+
const json = breadcrumbsAttribute(trail.list(), scrub, attributeBudget());
|
|
1896
|
+
return json ? { [BREADCRUMBS_ATTRIBUTE]: json } : {};
|
|
1897
|
+
} catch (e23) {
|
|
1898
|
+
return {};
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
|
|
1903
|
+
|
|
1904
|
+
|
|
1905
|
+
|
|
1906
|
+
|
|
1907
|
+
|
|
1908
|
+
|
|
1637
1909
|
|
|
1638
1910
|
|
|
1639
1911
|
|
|
@@ -1677,4 +1949,4 @@ var runtimeContext = {
|
|
|
1677
1949
|
|
|
1678
1950
|
|
|
1679
1951
|
|
|
1680
|
-
exports.redactAttributes = redactAttributes; exports.redactText = redactText; exports.makeRedactor = makeRedactor; exports.CODE_PATTERN = CODE_PATTERN; exports.RuntimeError = RuntimeError; exports.defineRuntimeErrors = defineRuntimeErrors; exports.isRuntimeErrorLike = isRuntimeErrorLike; exports.errorCodeOf = errorCodeOf; exports.errorAttributes = errorAttributes; exports.errorInternal = errorInternal; exports.toClientError = toClientError; exports.responseStatusOf = responseStatusOf; exports.isSummary = isSummary; exports.DEFAULT_REQUEST_ID_HEADER = DEFAULT_REQUEST_ID_HEADER; exports.resolveRequestId = resolveRequestId; exports.normalizeRoutePath = normalizeRoutePath; exports.compileIgnore = compileIgnore; exports.requestOutcome = requestOutcome; exports.parseUserAgent = parseUserAgent; exports.otlpSink = otlpSink; exports.consoleSink = consoleSink; exports.fileSink = fileSink; exports.memorySink = memorySink; exports.local = local; exports.currentOperation = currentOperation; exports.configureRuntimeLogger = configureRuntimeLogger; exports.addRuntimeSink = addRuntimeSink; exports.notifyException = notifyException; exports.runtimeLogStats = runtimeLogStats; exports.flushRuntimeLogs = flushRuntimeLogs; exports.shutdownRuntimeLogger = shutdownRuntimeLogger; exports.noteOperationError = noteOperationError; exports.recordOperationAiUsage = recordOperationAiUsage; exports.createRuntimeLogger = createRuntimeLogger; exports.runtimeLogger = runtimeLogger; exports.captureExceptionAsLog = captureExceptionAsLog; exports.createRequestState = createRequestState; exports.emitSummary = emitSummary; exports.reportExplicitFailure = reportExplicitFailure; exports.withRuntimeOperation = withRuntimeOperation; exports.runInBackground = runInBackground; exports.runtimeContext = runtimeContext;
|
|
1952
|
+
exports.redactAttributes = redactAttributes; exports.redactText = redactText; exports.makeRedactor = makeRedactor; exports.CODE_PATTERN = CODE_PATTERN; exports.RuntimeError = RuntimeError; exports.defineRuntimeErrors = defineRuntimeErrors; exports.isError = isError; exports.isRuntimeErrorLike = isRuntimeErrorLike; exports.errorCodeOf = errorCodeOf; exports.errorAttributes = errorAttributes; exports.errorInternal = errorInternal; exports.toClientError = toClientError; exports.responseStatusOf = responseStatusOf; exports.isSummary = isSummary; exports.DEFAULT_REQUEST_ID_HEADER = DEFAULT_REQUEST_ID_HEADER; exports.resolveRequestId = resolveRequestId; exports.normalizeRoutePath = normalizeRoutePath; exports.compileIgnore = compileIgnore; exports.requestOutcome = requestOutcome; exports.parseUserAgent = parseUserAgent; exports.sanitizeBreadcrumbs = sanitizeBreadcrumbs; exports.fingerprintValues = fingerprintValues; exports.fingerprintEventAttributes = fingerprintEventAttributes; exports.splitFingerprint = splitFingerprint; exports.addBreadcrumb = addBreadcrumb; exports.breadcrumbEventAttributes = breadcrumbEventAttributes; exports.otlpSink = otlpSink; exports.consoleSink = consoleSink; exports.fileSink = fileSink; exports.memorySink = memorySink; exports.local = local; exports.currentOperation = currentOperation; exports.configureRuntimeLogger = configureRuntimeLogger; exports.addRuntimeSink = addRuntimeSink; exports.notifyException = notifyException; exports.runtimeLogStats = runtimeLogStats; exports.flushRuntimeLogs = flushRuntimeLogs; exports.shutdownRuntimeLogger = shutdownRuntimeLogger; exports.noteOperationError = noteOperationError; exports.recordOperationAiUsage = recordOperationAiUsage; exports.createRuntimeLogger = createRuntimeLogger; exports.runtimeLogger = runtimeLogger; exports.captureExceptionAsLog = captureExceptionAsLog; exports.createRequestState = createRequestState; exports.emitSummary = emitSummary; exports.reportExplicitFailure = reportExplicitFailure; exports.withRuntimeOperation = withRuntimeOperation; exports.runInBackground = runInBackground; exports.runtimeContext = runtimeContext;
|