brass-runtime 1.17.0 → 1.18.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.
Files changed (120) hide show
  1. package/README.md +36 -3
  2. package/dist/agent/cli/main.cjs +31 -32
  3. package/dist/agent/cli/main.js +3 -4
  4. package/dist/agent/cli/main.mjs +3 -4
  5. package/dist/agent/index.cjs +4 -5
  6. package/dist/agent/index.d.ts +1 -1
  7. package/dist/agent/index.js +3 -4
  8. package/dist/agent/index.mjs +3 -4
  9. package/dist/{chunk-7X3K5RMS.js → chunk-22HZQG5F.js} +9 -11
  10. package/dist/{chunk-GLE2WY7Z.cjs → chunk-2JHJ4YHS.cjs} +417 -124
  11. package/dist/{chunk-Q2I37RP3.cjs → chunk-2OW6IFY2.cjs} +44 -323
  12. package/dist/{chunk-7ZPEZ57L.cjs → chunk-5LC7V2OZ.cjs} +18 -20
  13. package/dist/{chunk-AGR5B2BC.cjs → chunk-5RZ7YITF.cjs} +564 -12
  14. package/dist/{chunk-DNFJLJMW.mjs → chunk-6MLAZPBL.mjs} +48 -24
  15. package/dist/{chunk-EJ6BPYVR.mjs → chunk-6V2AWT4R.mjs} +1 -1
  16. package/dist/{chunk-3AYM6WPJ.js → chunk-7DU7IQHK.js} +20 -299
  17. package/dist/{chunk-SK7UZRNI.mjs → chunk-7GBJYOX7.mjs} +528 -23
  18. package/dist/chunk-7TKI527D.cjs +123 -0
  19. package/dist/{chunk-52OB2ROS.js → chunk-7VQLEN37.js} +2 -4
  20. package/dist/{chunk-KH4SYAOS.mjs → chunk-B5FKOLTB.mjs} +20 -299
  21. package/dist/{chunk-FHQGHPMO.mjs → chunk-BC6Q6BCO.mjs} +2 -4
  22. package/dist/{chunk-4P2HHGAX.mjs → chunk-COOW7BJX.mjs} +32 -11
  23. package/dist/{chunk-2HQTDLHF.mjs → chunk-EEN5OTCR.mjs} +555 -3
  24. package/dist/{chunk-KZJQ723N.cjs → chunk-EICAJDNX.cjs} +13 -15
  25. package/dist/chunk-ELIECDYN.cjs +33 -0
  26. package/dist/{chunk-GYM3LLGS.mjs → chunk-H626ZTDZ.mjs} +399 -106
  27. package/dist/{chunk-C3MDXTRZ.js → chunk-HCJ4S3YB.js} +48 -24
  28. package/dist/{chunk-7JIJOVCT.js → chunk-IPSMXUWA.js} +2 -4
  29. package/dist/{chunk-4ROBZFL6.cjs → chunk-J6DUHITE.cjs} +6 -8
  30. package/dist/{chunk-6RY2FFN4.mjs → chunk-JWIEMBE6.mjs} +9 -11
  31. package/dist/{chunk-PD4EJTQC.cjs → chunk-KNTJ7FQB.cjs} +5 -5
  32. package/dist/chunk-KTGDLBLD.mjs +123 -0
  33. package/dist/chunk-LSYQ3C2M.js +33 -0
  34. package/dist/{chunk-RKGKFN2A.js → chunk-OW5VHAOE.js} +1 -1
  35. package/dist/{chunk-EOC4UHBS.mjs → chunk-RBHNOKH4.mjs} +2 -2
  36. package/dist/{chunk-6IXXWIUM.js → chunk-S4HXADU4.js} +555 -3
  37. package/dist/{chunk-FH2X7BVP.js → chunk-TTSPIU3U.js} +399 -106
  38. package/dist/{chunk-5QC7LRZ3.js → chunk-UAKAF32U.js} +2 -2
  39. package/dist/{chunk-CZIVE6NT.cjs → chunk-UUMKZJRJ.cjs} +48 -24
  40. package/dist/{chunk-MBEJI5HF.mjs → chunk-WCBNXPN6.mjs} +2 -4
  41. package/dist/{chunk-52PPNNI4.cjs → chunk-WGE2FEZE.cjs} +2 -2
  42. package/dist/{chunk-WBGRHGBP.cjs → chunk-WI7GZF3B.cjs} +114 -93
  43. package/dist/chunk-WUDHOZIH.js +6234 -0
  44. package/dist/{chunk-F6XWZQY4.cjs → chunk-WVSZOPGQ.cjs} +583 -78
  45. package/dist/chunk-XPIMJQYS.cjs +6234 -0
  46. package/dist/{chunk-VWIPB6I5.js → chunk-YGR2IN4R.js} +528 -23
  47. package/dist/chunk-YM3EDNYD.js +123 -0
  48. package/dist/chunk-YWLLH27R.mjs +33 -0
  49. package/dist/{chunk-BKK77SBA.js → chunk-YZ5LQ32F.js} +32 -11
  50. package/dist/chunk-Z3ZZMQUZ.mjs +6234 -0
  51. package/dist/core/index.cjs +37 -9
  52. package/dist/core/index.d.ts +19 -152
  53. package/dist/core/index.js +86 -58
  54. package/dist/core/index.mjs +86 -58
  55. package/dist/defaultClient-Cid0JoUR.d.ts +1648 -0
  56. package/dist/{effect-DIUHZ9IN.d.ts → effect-DnGUuhw6.d.ts} +22 -1
  57. package/dist/http/index.cjs +206 -59
  58. package/dist/http/index.d.ts +55 -819
  59. package/dist/http/index.js +220 -73
  60. package/dist/http/index.mjs +220 -73
  61. package/dist/http/testing.cjs +31 -10
  62. package/dist/http/testing.d.ts +16 -5
  63. package/dist/http/testing.js +29 -8
  64. package/dist/http/testing.mjs +29 -8
  65. package/dist/index.cjs +116 -88
  66. package/dist/index.d.ts +9 -8
  67. package/dist/index.js +87 -59
  68. package/dist/index.mjs +87 -59
  69. package/dist/{schedule-CK3Ml_7p.d.ts → layer-D2LFcBVx.d.ts} +176 -2
  70. package/dist/observability/index.cjs +20 -7
  71. package/dist/observability/index.d.ts +32 -8
  72. package/dist/observability/index.js +19 -6
  73. package/dist/observability/index.mjs +19 -6
  74. package/dist/perf/cli.cjs +26 -28
  75. package/dist/perf/cli.js +11 -13
  76. package/dist/perf/cli.mjs +11 -13
  77. package/dist/perf/index.cjs +13 -15
  78. package/dist/perf/index.js +11 -13
  79. package/dist/perf/index.mjs +11 -13
  80. package/dist/schema/index.cjs +2 -2
  81. package/dist/schema/index.js +1 -1
  82. package/dist/schema/index.mjs +1 -1
  83. package/dist/{server-D6JZ15_e.d.ts → server-Bf1zNYZk.d.ts} +5 -5
  84. package/dist/{stream-B4oK9JFP.d.ts → stream-I7bkvF7a.d.ts} +1 -1
  85. package/dist/{tracer-Hwt1cl7h.d.ts → tracer-DF83nLn6.d.ts} +2 -2
  86. package/dist/{tracing-DqbTKGcf.d.ts → tracing-CWV4gT0u.d.ts} +1 -1
  87. package/docs/README.md +2 -0
  88. package/docs/ai/PUBLIC_API.md +28 -7
  89. package/docs/articles/brass-runtime-http-observability.md +467 -0
  90. package/docs/frameworks/angular.md +51 -0
  91. package/docs/frameworks/express.md +58 -0
  92. package/docs/frameworks/fastify.md +49 -0
  93. package/docs/frameworks/nestjs.md +53 -0
  94. package/docs/frameworks/nextjs.md +55 -0
  95. package/docs/frameworks/react.md +44 -0
  96. package/docs/frameworks/vanilla.md +56 -0
  97. package/docs/guides/layers.md +130 -0
  98. package/docs/http-recipes.md +31 -1
  99. package/docs/http.md +50 -1
  100. package/docs/observability.md +132 -0
  101. package/docs/performance-profiler.md +6 -2
  102. package/docs/recipes/layers.md +46 -2
  103. package/docs/recipes/testing.md +25 -0
  104. package/package.json +6 -2
  105. package/dist/chunk-3LOYJFRR.cjs +0 -300
  106. package/dist/chunk-3Y2RIUMM.js +0 -300
  107. package/dist/chunk-5EC274J5.cjs +0 -2874
  108. package/dist/chunk-5VRJNBLZ.mjs +0 -2874
  109. package/dist/chunk-62AZW6UT.cjs +0 -313
  110. package/dist/chunk-74ZTY6CP.js +0 -2871
  111. package/dist/chunk-7CMJS3QE.mjs +0 -2871
  112. package/dist/chunk-A2OM6NEH.mjs +0 -194
  113. package/dist/chunk-B33ICAKP.js +0 -313
  114. package/dist/chunk-JF5WGYJJ.cjs +0 -194
  115. package/dist/chunk-KN32XNTH.mjs +0 -313
  116. package/dist/chunk-KQLYONSE.cjs +0 -2871
  117. package/dist/chunk-L2SYFEBS.js +0 -194
  118. package/dist/chunk-MIIYDLGM.js +0 -2874
  119. package/dist/chunk-PWC3RBQE.mjs +0 -300
  120. package/dist/client-CZHU674n.d.ts +0 -820
@@ -29,6 +29,7 @@ function formatConfigError(error) {
29
29
  }
30
30
  var ok = (data) => ({ success: true, data });
31
31
  var fail = (issues) => ({ success: false, issues });
32
+ var EMPTY_PATH = Object.freeze([]);
32
33
  var receivedKind = (value) => {
33
34
  if (value === null) return "null";
34
35
  if (value === void 0) return "undefined";
@@ -37,12 +38,16 @@ var receivedKind = (value) => {
37
38
  return typeof value;
38
39
  };
39
40
  var pathLabel = (path) => path.length === 0 ? "$" : path.reduce((acc, part) => typeof part === "number" ? `${acc}[${part}]` : `${acc}.${part}`, "$");
40
- var makeSchemaIssue = (path, expected, received, message) => ({
41
- path,
42
- expected,
43
- received: receivedKind(received),
44
- message: _nullishCoalesce(message, () => ( `Expected ${expected} at ${pathLabel(path)}, received ${receivedKind(received)}`))
45
- });
41
+ var makeSchemaIssue = (path, expected, received, message) => {
42
+ const issuePath = path.length === 0 ? EMPTY_PATH : [...path];
43
+ const receivedLabel = receivedKind(received);
44
+ return {
45
+ path: issuePath,
46
+ expected,
47
+ received: receivedLabel,
48
+ message: _nullishCoalesce(message, () => ( `Expected ${expected} at ${pathLabel(issuePath)}, received ${receivedLabel}`))
49
+ };
50
+ };
46
51
  function formatIssues(issues) {
47
52
  if (issues.length === 0) return "Validation failed";
48
53
  const preview = issues.slice(0, 3).map((issue) => `${pathLabel(issue.path)}: ${issue.message}`).join("; ");
@@ -55,9 +60,9 @@ function makeSchema(kind, isOptional, parser, name) {
55
60
  name,
56
61
  isOptional,
57
62
  _parse: parser,
58
- safeParse: (input) => parser(input, []),
63
+ safeParse: (input) => parser(input, EMPTY_PATH),
59
64
  parse: (input) => {
60
- const result = parser(input, []);
65
+ const result = parser(input, EMPTY_PATH);
61
66
  if (result.success) return result.data;
62
67
  throw new SchemaValidationException(result.issues);
63
68
  },
@@ -212,50 +217,65 @@ function arraySchema(item) {
212
217
  return makeSchema("array", false, (input, path) => {
213
218
  if (!Array.isArray(input)) return fail([makeSchemaIssue(path, "array", input)]);
214
219
  const out = [];
215
- const issues = [];
216
- input.forEach((value, index) => {
217
- const result = item._parse(value, [...path, index]);
220
+ const childPath = path.length === 0 ? [] : [...path];
221
+ let issues;
222
+ for (let index = 0; index < input.length; index += 1) {
223
+ if (!(index in input)) continue;
224
+ childPath.push(index);
225
+ const result = item._parse(input[index], childPath);
226
+ childPath.pop();
218
227
  if (result.success) {
219
228
  out.push(result.data);
220
229
  } else {
230
+ issues ??= [];
221
231
  issues.push(...result.issues);
222
232
  }
223
- });
224
- return issues.length > 0 ? fail(issues) : ok(out);
233
+ }
234
+ return issues ? fail(issues) : ok(out);
225
235
  });
226
236
  }
227
237
  function objectSchema(shape, options = {}) {
228
238
  const unknownKeys = _nullishCoalesce(options.unknownKeys, () => ( "strip"));
239
+ const shapeEntries = Object.entries(shape);
240
+ const knownKeys = unknownKeys === "strict" ? new Set(shapeEntries.map(([key]) => key)) : void 0;
229
241
  return makeSchema("object", false, (input, path) => {
230
242
  if (typeof input !== "object" || input === null || Array.isArray(input)) {
231
243
  return fail([makeSchemaIssue(path, _nullishCoalesce(options.name, () => ( "object")), input)]);
232
244
  }
233
245
  const source = input;
234
246
  const out = unknownKeys === "passthrough" ? { ...source } : {};
235
- const issues = [];
236
- const knownKeys = new Set(Object.keys(shape));
237
- for (const [key, fieldSchema] of Object.entries(shape)) {
247
+ const childPath = path.length === 0 ? [] : [...path];
248
+ let issues;
249
+ for (const [key, fieldSchema] of shapeEntries) {
250
+ childPath.push(key);
238
251
  if (!(key in source)) {
239
252
  if (!fieldSchema.isOptional) {
240
- issues.push(makeSchemaIssue([...path, key], _nullishCoalesce(fieldSchema.name, () => ( fieldSchema.kind)), void 0, "Required field is missing"));
253
+ issues ??= [];
254
+ issues.push(makeSchemaIssue(childPath, _nullishCoalesce(fieldSchema.name, () => ( fieldSchema.kind)), void 0, "Required field is missing"));
241
255
  }
256
+ childPath.pop();
242
257
  continue;
243
258
  }
244
- const result = fieldSchema._parse(source[key], [...path, key]);
259
+ const result = fieldSchema._parse(source[key], childPath);
260
+ childPath.pop();
245
261
  if (result.success) {
246
262
  out[key] = result.data;
247
263
  } else {
264
+ issues ??= [];
248
265
  issues.push(...result.issues);
249
266
  }
250
267
  }
251
- if (unknownKeys === "strict") {
268
+ if (knownKeys) {
252
269
  for (const key of Object.keys(source)) {
253
270
  if (!knownKeys.has(key)) {
254
- issues.push(makeSchemaIssue([...path, key], "known key", source[key], "Unknown key is not allowed"));
271
+ childPath.push(key);
272
+ issues ??= [];
273
+ issues.push(makeSchemaIssue(childPath, "known key", source[key], "Unknown key is not allowed"));
274
+ childPath.pop();
255
275
  }
256
276
  }
257
277
  }
258
- return issues.length > 0 ? fail(issues) : ok(out);
278
+ return issues ? fail(issues) : ok(out);
259
279
  }, options.name);
260
280
  }
261
281
  function recordSchema(valueSchema) {
@@ -264,16 +284,20 @@ function recordSchema(valueSchema) {
264
284
  return fail([makeSchemaIssue(path, "record", input)]);
265
285
  }
266
286
  const out = {};
267
- const issues = [];
287
+ const childPath = path.length === 0 ? [] : [...path];
288
+ let issues;
268
289
  for (const [key, value] of Object.entries(input)) {
269
- const result = valueSchema._parse(value, [...path, key]);
290
+ childPath.push(key);
291
+ const result = valueSchema._parse(value, childPath);
292
+ childPath.pop();
270
293
  if (result.success) {
271
294
  out[key] = result.data;
272
295
  } else {
296
+ issues ??= [];
273
297
  issues.push(...result.issues);
274
298
  }
275
299
  }
276
- return issues.length > 0 ? fail(issues) : ok(out);
300
+ return issues ? fail(issues) : ok(out);
277
301
  });
278
302
  }
279
303
  function unionSchema(members) {
@@ -2,11 +2,9 @@ import {
2
2
  race
3
3
  } from "./chunk-B5JD23U7.mjs";
4
4
  import {
5
+ fromPromiseAbortable,
5
6
  withScopeAsync
6
- } from "./chunk-A2OM6NEH.mjs";
7
- import {
8
- fromPromiseAbortable
9
- } from "./chunk-GYM3LLGS.mjs";
7
+ } from "./chunk-H626ZTDZ.mjs";
10
8
  import {
11
9
  Cause,
12
10
  Exit,
@@ -1,6 +1,6 @@
1
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; var _class2;
2
2
 
3
- var _chunkGLE2WY7Zcjs = require('./chunk-GLE2WY7Z.cjs');
3
+ var _chunk2JHJ4YHScjs = require('./chunk-2JHJ4YHS.cjs');
4
4
 
5
5
 
6
6
  var _chunkMVGUEJ5Zcjs = require('./chunk-MVGUEJ5Z.cjs');
@@ -164,7 +164,7 @@ var EventBus = (_class = class {
164
164
  subscribe(handler, perSubscriberCapacity = 2048) {
165
165
  this.subs.push({
166
166
  handler,
167
- q: _chunkGLE2WY7Zcjs.makeBoundedRingBuffer.call(void 0, perSubscriberCapacity, perSubscriberCapacity, this.options),
167
+ q: _chunk2JHJ4YHScjs.makeBoundedRingBuffer.call(void 0, perSubscriberCapacity, perSubscriberCapacity, this.options),
168
168
  dropped: 0
169
169
  });
170
170
  return () => {
@@ -2,14 +2,14 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk52PPNNI4cjs = require('./chunk-52PPNNI4.cjs');
5
+ var _chunkWGE2FEZEcjs = require('./chunk-WGE2FEZE.cjs');
6
6
 
7
7
 
8
8
 
9
9
 
10
10
 
11
11
 
12
- var _chunkGLE2WY7Zcjs = require('./chunk-GLE2WY7Z.cjs');
12
+ var _chunk2JHJ4YHScjs = require('./chunk-2JHJ4YHS.cjs');
13
13
 
14
14
 
15
15
 
@@ -20,7 +20,7 @@ var _chunkMVGUEJ5Zcjs = require('./chunk-MVGUEJ5Z.cjs');
20
20
 
21
21
 
22
22
 
23
- var _chunkCZIVE6NTcjs = require('./chunk-CZIVE6NT.cjs');
23
+ var _chunkUUMKZJRJcjs = require('./chunk-UUMKZJRJ.cjs');
24
24
 
25
25
  // src/observability/health.ts
26
26
  function snapshotRuntimeHealth(options = {}) {
@@ -796,10 +796,10 @@ function makeOtlpHttpLogExporter(source, options) {
796
796
  }
797
797
  function logEffect(level, message, fields = {}) {
798
798
  return _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => {
799
- const fiber = _chunkGLE2WY7Zcjs.getCurrentFiber.call(void 0, );
799
+ const fiber = _chunk2JHJ4YHScjs.getCurrentFiber.call(void 0, );
800
800
  const runtime = _optionalChain([fiber, 'optionalAccess', _34 => _34.runtime]);
801
801
  if (!runtime) return;
802
- const inherited = _optionalChain([fiber, 'access', _35 => _35.fiberContext, 'optionalAccess', _36 => _36.log]) ? _chunkGLE2WY7Zcjs.ctxToObject.call(void 0, fiber.fiberContext.log) : {};
802
+ const inherited = _optionalChain([fiber, 'access', _35 => _35.fiberContext, 'optionalAccess', _36 => _36.log]) ? _chunk2JHJ4YHScjs.ctxToObject.call(void 0, fiber.fiberContext.log) : {};
803
803
  runtime.log(level, message, { ...inherited, ...fields });
804
804
  });
805
805
  }
@@ -815,11 +815,11 @@ function withLogContext(patch, effect) {
815
815
  }
816
816
  function startLogContext(patch) {
817
817
  return _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => {
818
- const fiber = _chunkGLE2WY7Zcjs.getCurrentFiber.call(void 0, );
818
+ const fiber = _chunk2JHJ4YHScjs.getCurrentFiber.call(void 0, );
819
819
  if (!_optionalChain([fiber, 'optionalAccess', _37 => _37.fiberContext])) return void 0;
820
- const previous = _nullishCoalesce(fiber.fiberContext.log, () => ( _chunkGLE2WY7Zcjs.emptyContext));
820
+ const previous = _nullishCoalesce(fiber.fiberContext.log, () => ( _chunk2JHJ4YHScjs.emptyContext));
821
821
  const state = { fiber, previous, ended: false };
822
- fiber.fiberContext = { ...fiber.fiberContext, log: _chunkGLE2WY7Zcjs.ctxExtend.call(void 0, previous, patch) };
822
+ fiber.fiberContext = { ...fiber.fiberContext, log: _chunk2JHJ4YHScjs.ctxExtend.call(void 0, previous, patch) };
823
823
  _optionalChain([fiber, 'access', _38 => _38.addFinalizer, 'optionalCall', _39 => _39(() => restoreLogContext(state))]);
824
824
  return state;
825
825
  });
@@ -881,24 +881,25 @@ function normalizeLogAttributes(fields) {
881
881
  }
882
882
 
883
883
  // src/observability/sampling.ts
884
- var alwaysOnSampler = {
884
+ var TRACE_SAMPLER_RATIO = /* @__PURE__ */ Symbol.for("brass-runtime.traceSampler.ratio");
885
+ var alwaysOnSampler = withRatio({
885
886
  shouldSample: () => true
886
- };
887
- var alwaysOffSampler = {
887
+ }, 1);
888
+ var alwaysOffSampler = withRatio({
888
889
  shouldSample: () => false
889
- };
890
+ }, 0);
890
891
  function ratioSampler(ratio2) {
891
892
  const bounded = clampRatio(ratio2);
892
893
  if (bounded >= 1) return alwaysOnSampler;
893
894
  if (bounded <= 0) return alwaysOffSampler;
894
- return {
895
+ return withRatio({
895
896
  shouldSample: (input) => traceRatio(input.traceId) < bounded
896
- };
897
+ }, bounded);
897
898
  }
898
899
  function makeTraceSampler(options = {}) {
899
900
  const fallback = _nullishCoalesce(options.sampler, () => ( ratioSampler(_nullishCoalesce(options.ratio, () => ( 1)))));
900
901
  const rules = _nullishCoalesce(options.rules, () => ( []));
901
- return {
902
+ const sampler = {
902
903
  shouldSample(input) {
903
904
  for (const rule of rules) {
904
905
  if (!samplingRuleMatches(rule, input)) continue;
@@ -908,6 +909,8 @@ function makeTraceSampler(options = {}) {
908
909
  return shouldSampleWith(fallback, input);
909
910
  }
910
911
  };
912
+ const fallbackRatio = samplerRatio(fallback);
913
+ return rules.length === 0 && fallbackRatio !== void 0 ? withRatio(sampler, fallbackRatio) : sampler;
911
914
  }
912
915
  function resolveTraceSampling(config) {
913
916
  if (config === false) {
@@ -942,6 +945,22 @@ function matchText(pattern, value) {
942
945
  function isTraceSampler(value) {
943
946
  return typeof value === "function" || typeof value === "object" && value !== null && typeof value.shouldSample === "function";
944
947
  }
948
+ function samplerRatio(sampler) {
949
+ if (!sampler || typeof sampler === "function") return void 0;
950
+ const ratio2 = sampler[TRACE_SAMPLER_RATIO];
951
+ return typeof ratio2 === "number" && Number.isFinite(ratio2) ? ratio2 : void 0;
952
+ }
953
+ function withRatio(sampler, ratio2) {
954
+ try {
955
+ Object.defineProperty(sampler, TRACE_SAMPLER_RATIO, {
956
+ configurable: false,
957
+ enumerable: false,
958
+ value: ratio2
959
+ });
960
+ } catch (e6) {
961
+ }
962
+ return sampler;
963
+ }
945
964
  function traceRatio(traceId) {
946
965
  const normalized = normalizeTraceId(traceId);
947
966
  const head = normalized.slice(0, 8);
@@ -975,7 +994,7 @@ function spanLink(trace, attributes) {
975
994
  };
976
995
  }
977
996
  function currentSpanLink(attributes) {
978
- const fiber = _chunkGLE2WY7Zcjs.getCurrentFiber.call(void 0, );
997
+ const fiber = _chunk2JHJ4YHScjs.getCurrentFiber.call(void 0, );
979
998
  const trace = _optionalChain([fiber, 'optionalAccess', _46 => _46.fiberContext, 'optionalAccess', _47 => _47.trace]);
980
999
  return _optionalChain([trace, 'optionalAccess', _48 => _48.traceId]) && _optionalChain([trace, 'optionalAccess', _49 => _49.spanId]) ? spanLink(trace, attributes) : void 0;
981
1000
  }
@@ -990,13 +1009,13 @@ function withBaggage(baggage, effect) {
990
1009
  );
991
1010
  }
992
1011
  function currentBaggage() {
993
- const fiber = _chunkGLE2WY7Zcjs.getCurrentFiber.call(void 0, );
1012
+ const fiber = _chunk2JHJ4YHScjs.getCurrentFiber.call(void 0, );
994
1013
  const baggage = _optionalChain([fiber, 'optionalAccess', _50 => _50.fiberContext, 'optionalAccess', _51 => _51.trace, 'optionalAccess', _52 => _52.baggage]);
995
1014
  return baggage ? { ...baggage } : void 0;
996
1015
  }
997
1016
  function spanEvent(name, attributes = {}) {
998
1017
  return _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => {
999
- const fiber = _chunkGLE2WY7Zcjs.getCurrentFiber.call(void 0, );
1018
+ const fiber = _chunk2JHJ4YHScjs.getCurrentFiber.call(void 0, );
1000
1019
  const trace = _optionalChain([fiber, 'optionalAccess', _53 => _53.fiberContext, 'optionalAccess', _54 => _54.trace]);
1001
1020
  if (!_optionalChain([fiber, 'optionalAccess', _55 => _55.runtime]) || !trace || trace.sampled === false) return;
1002
1021
  fiber.runtime.hooks.emit(
@@ -1030,7 +1049,7 @@ function makeOtlpHttpSpanExporter(source, options) {
1030
1049
  }
1031
1050
  function startSpan(name, options) {
1032
1051
  return _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => {
1033
- const fiber = _chunkGLE2WY7Zcjs.getCurrentFiber.call(void 0, );
1052
+ const fiber = _chunk2JHJ4YHScjs.getCurrentFiber.call(void 0, );
1034
1053
  const runtime = _optionalChain([fiber, 'optionalAccess', _56 => _56.runtime]);
1035
1054
  if (!_optionalChain([fiber, 'optionalAccess', _57 => _57.fiberContext]) || !runtime) return void 0;
1036
1055
  const previousTrace = _nullishCoalesce(fiber.fiberContext.trace, () => ( null));
@@ -1113,7 +1132,7 @@ function spanContext(fiber, trace) {
1113
1132
  }
1114
1133
  function startBaggage(baggage) {
1115
1134
  return _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => {
1116
- const fiber = _chunkGLE2WY7Zcjs.getCurrentFiber.call(void 0, );
1135
+ const fiber = _chunk2JHJ4YHScjs.getCurrentFiber.call(void 0, );
1117
1136
  if (!_optionalChain([fiber, 'optionalAccess', _76 => _76.fiberContext])) return void 0;
1118
1137
  const previousTrace = _nullishCoalesce(fiber.fiberContext.trace, () => ( null));
1119
1138
  if (!previousTrace) return void 0;
@@ -1447,7 +1466,7 @@ function sanitizeHttpTarget(url) {
1447
1466
  try {
1448
1467
  const parsed = new URL(url, "http://local");
1449
1468
  return `${parsed.pathname}${parsed.search ? "?[REDACTED]" : ""}`;
1450
- } catch (e6) {
1469
+ } catch (e7) {
1451
1470
  const [withoutHash] = url.split("#", 1);
1452
1471
  const queryIndex = withoutHash.indexOf("?");
1453
1472
  return queryIndex < 0 ? withoutHash : `${withoutHash.slice(0, queryIndex)}?[REDACTED]`;
@@ -1455,54 +1474,54 @@ function sanitizeHttpTarget(url) {
1455
1474
  }
1456
1475
 
1457
1476
  // src/observability/configValidation.ts
1458
- var fn = _chunkCZIVE6NTcjs.Schema.custom((value) => typeof value === "function", "function");
1459
- var object = _chunkCZIVE6NTcjs.Schema.custom(
1477
+ var fn = _chunkUUMKZJRJcjs.Schema.custom((value) => typeof value === "function", "function");
1478
+ var object = _chunkUUMKZJRJcjs.Schema.custom(
1460
1479
  (value) => typeof value === "object" && value !== null && !Array.isArray(value),
1461
1480
  "object"
1462
1481
  );
1463
- var falseOrObject = _chunkCZIVE6NTcjs.Schema.union([_chunkCZIVE6NTcjs.Schema.literal(false), object]);
1464
- var ratio = _chunkCZIVE6NTcjs.Schema.number({ min: 0, max: 1 });
1465
- var logLevel = _chunkCZIVE6NTcjs.Schema.enum(["debug", "info", "warn", "error"]);
1466
- var retryOptions = _chunkCZIVE6NTcjs.Schema.object({
1467
- attempts: _chunkCZIVE6NTcjs.Schema.number({ min: 0, int: true }).optional(),
1468
- initialDelayMs: _chunkCZIVE6NTcjs.Schema.number({ min: 0, int: true }).optional(),
1469
- maxDelayMs: _chunkCZIVE6NTcjs.Schema.number({ min: 0, int: true }).optional(),
1470
- jitterRatio: _chunkCZIVE6NTcjs.Schema.number({ min: 0, max: 1 }).optional(),
1482
+ var falseOrObject = _chunkUUMKZJRJcjs.Schema.union([_chunkUUMKZJRJcjs.Schema.literal(false), object]);
1483
+ var ratio = _chunkUUMKZJRJcjs.Schema.number({ min: 0, max: 1 });
1484
+ var logLevel = _chunkUUMKZJRJcjs.Schema.enum(["debug", "info", "warn", "error"]);
1485
+ var retryOptions = _chunkUUMKZJRJcjs.Schema.object({
1486
+ attempts: _chunkUUMKZJRJcjs.Schema.number({ min: 0, int: true }).optional(),
1487
+ initialDelayMs: _chunkUUMKZJRJcjs.Schema.number({ min: 0, int: true }).optional(),
1488
+ maxDelayMs: _chunkUUMKZJRJcjs.Schema.number({ min: 0, int: true }).optional(),
1489
+ jitterRatio: _chunkUUMKZJRJcjs.Schema.number({ min: 0, max: 1 }).optional(),
1471
1490
  sleep: fn.optional()
1472
1491
  }, { unknownKeys: "passthrough" });
1473
- var pipelineOptions = _chunkCZIVE6NTcjs.Schema.object({
1474
- maxQueueSize: _chunkCZIVE6NTcjs.Schema.number({ min: 0, int: true }).optional(),
1475
- batchSize: _chunkCZIVE6NTcjs.Schema.number({ min: 1, int: true }).optional(),
1476
- timeoutMs: _chunkCZIVE6NTcjs.Schema.number({ min: 0, int: true }).optional(),
1492
+ var pipelineOptions = _chunkUUMKZJRJcjs.Schema.object({
1493
+ maxQueueSize: _chunkUUMKZJRJcjs.Schema.number({ min: 0, int: true }).optional(),
1494
+ batchSize: _chunkUUMKZJRJcjs.Schema.number({ min: 1, int: true }).optional(),
1495
+ timeoutMs: _chunkUUMKZJRJcjs.Schema.number({ min: 0, int: true }).optional(),
1477
1496
  retry: retryOptions.optional(),
1478
- dropPolicy: _chunkCZIVE6NTcjs.Schema.enum(["drop-oldest", "drop-newest"]).optional(),
1479
- shutdownTimeoutMs: _chunkCZIVE6NTcjs.Schema.number({ min: 0, int: true }).optional()
1497
+ dropPolicy: _chunkUUMKZJRJcjs.Schema.enum(["drop-oldest", "drop-newest"]).optional(),
1498
+ shutdownTimeoutMs: _chunkUUMKZJRJcjs.Schema.number({ min: 0, int: true }).optional()
1480
1499
  }, { unknownKeys: "passthrough" });
1481
- var otlpOptions = _chunkCZIVE6NTcjs.Schema.object({
1482
- metricsUrl: _chunkCZIVE6NTcjs.Schema.string().optional(),
1483
- tracesUrl: _chunkCZIVE6NTcjs.Schema.string().optional(),
1484
- logsUrl: _chunkCZIVE6NTcjs.Schema.string().optional(),
1485
- headers: _chunkCZIVE6NTcjs.Schema.record(_chunkCZIVE6NTcjs.Schema.string()).optional(),
1500
+ var otlpOptions = _chunkUUMKZJRJcjs.Schema.object({
1501
+ metricsUrl: _chunkUUMKZJRJcjs.Schema.string().optional(),
1502
+ tracesUrl: _chunkUUMKZJRJcjs.Schema.string().optional(),
1503
+ logsUrl: _chunkUUMKZJRJcjs.Schema.string().optional(),
1504
+ headers: _chunkUUMKZJRJcjs.Schema.record(_chunkUUMKZJRJcjs.Schema.string()).optional(),
1486
1505
  fetch: fn.optional(),
1487
- timeoutMs: _chunkCZIVE6NTcjs.Schema.number({ min: 1, int: true }).optional(),
1506
+ timeoutMs: _chunkUUMKZJRJcjs.Schema.number({ min: 1, int: true }).optional(),
1488
1507
  retry: retryOptions.optional(),
1489
1508
  pipeline: pipelineOptions.optional()
1490
1509
  }, { unknownKeys: "passthrough" });
1491
- var samplingOptions = _chunkCZIVE6NTcjs.Schema.union([
1492
- _chunkCZIVE6NTcjs.Schema.literal(false),
1510
+ var samplingOptions = _chunkUUMKZJRJcjs.Schema.union([
1511
+ _chunkUUMKZJRJcjs.Schema.literal(false),
1493
1512
  ratio,
1494
1513
  fn,
1495
- _chunkCZIVE6NTcjs.Schema.object({
1514
+ _chunkUUMKZJRJcjs.Schema.object({
1496
1515
  ratio: ratio.optional(),
1497
- rules: _chunkCZIVE6NTcjs.Schema.array(object).optional(),
1498
- sampler: _chunkCZIVE6NTcjs.Schema.union([fn, object]).optional(),
1499
- respectRemoteSampled: _chunkCZIVE6NTcjs.Schema.boolean().optional(),
1500
- forceSampleOnError: _chunkCZIVE6NTcjs.Schema.boolean().optional()
1516
+ rules: _chunkUUMKZJRJcjs.Schema.array(object).optional(),
1517
+ sampler: _chunkUUMKZJRJcjs.Schema.union([fn, object]).optional(),
1518
+ respectRemoteSampled: _chunkUUMKZJRJcjs.Schema.boolean().optional(),
1519
+ forceSampleOnError: _chunkUUMKZJRJcjs.Schema.boolean().optional()
1501
1520
  }, { unknownKeys: "passthrough" })
1502
1521
  ]);
1503
- var observabilityOptions = _chunkCZIVE6NTcjs.Schema.object({
1504
- serviceName: _chunkCZIVE6NTcjs.Schema.string({ minLength: 1 }).optional(),
1505
- serviceVersion: _chunkCZIVE6NTcjs.Schema.string({ minLength: 1 }).optional(),
1522
+ var observabilityOptions = _chunkUUMKZJRJcjs.Schema.object({
1523
+ serviceName: _chunkUUMKZJRJcjs.Schema.string({ minLength: 1 }).optional(),
1524
+ serviceVersion: _chunkUUMKZJRJcjs.Schema.string({ minLength: 1 }).optional(),
1506
1525
  resource: object.optional(),
1507
1526
  eventBus: object.optional(),
1508
1527
  metrics: falseOrObject.optional(),
@@ -1510,62 +1529,64 @@ var observabilityOptions = _chunkCZIVE6NTcjs.Schema.object({
1510
1529
  traces: falseOrObject.optional(),
1511
1530
  sampling: samplingOptions.optional(),
1512
1531
  redaction: falseOrObject.optional(),
1513
- cardinality: _chunkCZIVE6NTcjs.Schema.union([
1514
- _chunkCZIVE6NTcjs.Schema.literal(false),
1515
- _chunkCZIVE6NTcjs.Schema.object({
1516
- maxValuesPerLabel: _chunkCZIVE6NTcjs.Schema.number({ min: 1, int: true }).optional(),
1517
- overflowValue: _chunkCZIVE6NTcjs.Schema.string({ minLength: 1 }).optional()
1532
+ cardinality: _chunkUUMKZJRJcjs.Schema.union([
1533
+ _chunkUUMKZJRJcjs.Schema.literal(false),
1534
+ _chunkUUMKZJRJcjs.Schema.object({
1535
+ maxValuesPerLabel: _chunkUUMKZJRJcjs.Schema.number({ min: 1, int: true }).optional(),
1536
+ overflowValue: _chunkUUMKZJRJcjs.Schema.string({ minLength: 1 }).optional()
1518
1537
  }, { unknownKeys: "passthrough" })
1519
1538
  ]).optional(),
1520
1539
  otlp: otlpOptions.optional(),
1521
- flushIntervalMs: _chunkCZIVE6NTcjs.Schema.number({ min: 1, int: true }).optional(),
1522
- autoStart: _chunkCZIVE6NTcjs.Schema.boolean().optional(),
1540
+ flushIntervalMs: _chunkUUMKZJRJcjs.Schema.number({ min: 1, int: true }).optional(),
1541
+ autoStart: _chunkUUMKZJRJcjs.Schema.boolean().optional(),
1523
1542
  traceSeed: object.optional(),
1524
1543
  childName: fn.optional(),
1525
1544
  onFlushError: fn.optional()
1526
1545
  }, { unknownKeys: "passthrough" });
1527
- var httpObservabilityOptions = _chunkCZIVE6NTcjs.Schema.object({
1546
+ var httpObservabilityOptions = _chunkUUMKZJRJcjs.Schema.object({
1528
1547
  metrics: falseOrObject.optional(),
1529
- logs: _chunkCZIVE6NTcjs.Schema.union([
1530
- _chunkCZIVE6NTcjs.Schema.literal(false),
1531
- _chunkCZIVE6NTcjs.Schema.object({
1532
- requestLevel: _chunkCZIVE6NTcjs.Schema.union([logLevel, _chunkCZIVE6NTcjs.Schema.literal(false)]).optional(),
1533
- responseLevel: _chunkCZIVE6NTcjs.Schema.union([logLevel, _chunkCZIVE6NTcjs.Schema.literal(false)]).optional(),
1534
- errorLevel: _chunkCZIVE6NTcjs.Schema.union([logLevel, _chunkCZIVE6NTcjs.Schema.literal(false)]).optional()
1548
+ logs: _chunkUUMKZJRJcjs.Schema.union([
1549
+ _chunkUUMKZJRJcjs.Schema.literal(false),
1550
+ _chunkUUMKZJRJcjs.Schema.object({
1551
+ requestLevel: _chunkUUMKZJRJcjs.Schema.union([logLevel, _chunkUUMKZJRJcjs.Schema.literal(false)]).optional(),
1552
+ responseLevel: _chunkUUMKZJRJcjs.Schema.union([logLevel, _chunkUUMKZJRJcjs.Schema.literal(false)]).optional(),
1553
+ errorLevel: _chunkUUMKZJRJcjs.Schema.union([logLevel, _chunkUUMKZJRJcjs.Schema.literal(false)]).optional()
1535
1554
  }, { unknownKeys: "passthrough" })
1536
1555
  ]).optional(),
1537
- spans: _chunkCZIVE6NTcjs.Schema.union([
1538
- _chunkCZIVE6NTcjs.Schema.literal(false),
1539
- _chunkCZIVE6NTcjs.Schema.object({
1540
- name: _chunkCZIVE6NTcjs.Schema.union([_chunkCZIVE6NTcjs.Schema.string({ minLength: 1 }), fn]).optional(),
1541
- attributes: _chunkCZIVE6NTcjs.Schema.union([object, fn]).optional()
1556
+ spans: _chunkUUMKZJRJcjs.Schema.union([
1557
+ _chunkUUMKZJRJcjs.Schema.literal(false),
1558
+ _chunkUUMKZJRJcjs.Schema.object({
1559
+ name: _chunkUUMKZJRJcjs.Schema.union([_chunkUUMKZJRJcjs.Schema.string({ minLength: 1 }), fn]).optional(),
1560
+ attributes: _chunkUUMKZJRJcjs.Schema.union([object, fn]).optional(),
1561
+ events: _chunkUUMKZJRJcjs.Schema.boolean().optional(),
1562
+ sampleRate: ratio.optional()
1542
1563
  }, { unknownKeys: "passthrough" })
1543
1564
  ]).optional(),
1544
- adaptiveLimiter: _chunkCZIVE6NTcjs.Schema.union([
1545
- _chunkCZIVE6NTcjs.Schema.boolean(),
1546
- _chunkCZIVE6NTcjs.Schema.object({
1547
- enabled: _chunkCZIVE6NTcjs.Schema.boolean().optional(),
1548
- includeKeyLabel: _chunkCZIVE6NTcjs.Schema.boolean().optional()
1565
+ adaptiveLimiter: _chunkUUMKZJRJcjs.Schema.union([
1566
+ _chunkUUMKZJRJcjs.Schema.boolean(),
1567
+ _chunkUUMKZJRJcjs.Schema.object({
1568
+ enabled: _chunkUUMKZJRJcjs.Schema.boolean().optional(),
1569
+ includeKeyLabel: _chunkUUMKZJRJcjs.Schema.boolean().optional()
1549
1570
  }, { unknownKeys: "passthrough" })
1550
1571
  ]).optional(),
1551
- policy: _chunkCZIVE6NTcjs.Schema.union([
1552
- _chunkCZIVE6NTcjs.Schema.boolean(),
1553
- _chunkCZIVE6NTcjs.Schema.object({
1554
- enabled: _chunkCZIVE6NTcjs.Schema.boolean().optional(),
1555
- labelKeys: _chunkCZIVE6NTcjs.Schema.array(_chunkCZIVE6NTcjs.Schema.enum(["preset", "lane", "poolKey", "dedupKey", "priority", "retry"])).optional()
1572
+ policy: _chunkUUMKZJRJcjs.Schema.union([
1573
+ _chunkUUMKZJRJcjs.Schema.boolean(),
1574
+ _chunkUUMKZJRJcjs.Schema.object({
1575
+ enabled: _chunkUUMKZJRJcjs.Schema.boolean().optional(),
1576
+ labelKeys: _chunkUUMKZJRJcjs.Schema.array(_chunkUUMKZJRJcjs.Schema.enum(["preset", "lane", "poolKey", "dedupKey", "priority", "retry"])).optional()
1556
1577
  }, { unknownKeys: "passthrough" })
1557
1578
  ]).optional(),
1558
- injectTraceHeaders: _chunkCZIVE6NTcjs.Schema.boolean().optional(),
1559
- includeHostLabel: _chunkCZIVE6NTcjs.Schema.boolean().optional(),
1560
- route: _chunkCZIVE6NTcjs.Schema.union([_chunkCZIVE6NTcjs.Schema.string({ minLength: 1 }), fn]).optional(),
1579
+ injectTraceHeaders: _chunkUUMKZJRJcjs.Schema.boolean().optional(),
1580
+ includeHostLabel: _chunkUUMKZJRJcjs.Schema.boolean().optional(),
1581
+ route: _chunkUUMKZJRJcjs.Schema.union([_chunkUUMKZJRJcjs.Schema.string({ minLength: 1 }), fn]).optional(),
1561
1582
  clock: fn.optional(),
1562
- durationBuckets: _chunkCZIVE6NTcjs.Schema.array(_chunkCZIVE6NTcjs.Schema.number({ min: 0 }).refine((n) => n > 0, "duration bucket must be > 0")).optional()
1583
+ durationBuckets: _chunkUUMKZJRJcjs.Schema.array(_chunkUUMKZJRJcjs.Schema.number({ min: 0 }).refine((n) => n > 0, "duration bucket must be > 0")).optional()
1563
1584
  }, { unknownKeys: "passthrough" });
1564
1585
  function validateObservabilityOptions(options) {
1565
- _chunkCZIVE6NTcjs.parseConfig.call(void 0, "ObservabilityOptions", observabilityOptions, options);
1586
+ _chunkUUMKZJRJcjs.parseConfig.call(void 0, "ObservabilityOptions", observabilityOptions, options);
1566
1587
  }
1567
1588
  function validateHttpObservabilityOptions(options) {
1568
- _chunkCZIVE6NTcjs.parseConfig.call(void 0, "HttpObservabilityOptions", httpObservabilityOptions, options);
1589
+ _chunkUUMKZJRJcjs.parseConfig.call(void 0, "HttpObservabilityOptions", httpObservabilityOptions, options);
1569
1590
  }
1570
1591
 
1571
1592
  // src/observability/setup.ts
@@ -1599,12 +1620,12 @@ function normalizeOtlpEndpoint(endpoint) {
1599
1620
  function makeObservability(options = {}) {
1600
1621
  validateObservabilityOptions(options);
1601
1622
  const serviceName = _nullishCoalesce(options.serviceName, () => ( "brass-runtime"));
1602
- const eventBus = _nullishCoalesce(options.eventBus, () => ( new (0, _chunk52PPNNI4cjs.EventBus)()));
1603
- const rawMetrics = _chunk52PPNNI4cjs.makeMetrics.call(void 0, );
1623
+ const eventBus = _nullishCoalesce(options.eventBus, () => ( new (0, _chunkWGE2FEZEcjs.EventBus)()));
1624
+ const rawMetrics = _chunkWGE2FEZEcjs.makeMetrics.call(void 0, );
1604
1625
  const metrics = options.cardinality === false ? rawMetrics : makeCardinalityLimitedMetrics(rawMetrics, _nullishCoalesce(options.cardinality, () => ( {})));
1605
1626
  const redactor = makeObservabilityRedactor(options.redaction);
1606
1627
  const traceOptions = options.traces && typeof options.traces === "object" ? options.traces : {};
1607
- const tracer = new (0, _chunk52PPNNI4cjs.InMemoryTracer)({
1628
+ const tracer = new (0, _chunkWGE2FEZEcjs.InMemoryTracer)({
1608
1629
  maxFinishedSpans: _nullishCoalesce(traceOptions.maxFinishedSpans, () => ( 1e4)),
1609
1630
  maxSpanAgeMs: _nullishCoalesce(traceOptions.maxSpanAgeMs, () => ( 10 * 6e4)),
1610
1631
  clock: traceOptions.clock,
@@ -1961,7 +1982,7 @@ function makeRequestObservabilityContext(observability, input = {}) {
1961
1982
  const env = observability.envForRequest(input);
1962
1983
  const attributes = requestSpanAttributes(input);
1963
1984
  const defaultSpanName = _nullishCoalesce(input.spanName, () => ( (input.method && input.route ? `${input.method} ${input.route}` : _nullishCoalesce(input.route, () => ( "request")))));
1964
- const makeRuntime = (extraEnv, options = {}) => new (0, _chunkGLE2WY7Zcjs.Runtime)({
1985
+ const makeRuntime = (extraEnv, options = {}) => new (0, _chunk2JHJ4YHScjs.Runtime)({
1965
1986
  ...options,
1966
1987
  env: mergeEnv(extraEnv, env),
1967
1988
  hooks: observability.hooks
@@ -1996,7 +2017,7 @@ function requestSpanAttributes(input) {
1996
2017
  function targetPath(target) {
1997
2018
  try {
1998
2019
  return new URL(target, "http://local").pathname;
1999
- } catch (e7) {
2020
+ } catch (e8) {
2000
2021
  return _nullishCoalesce(target.split("?", 1)[0], () => ( target));
2001
2022
  }
2002
2023
  }