@autter/runtime-node 1.6.1 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -45,11 +45,11 @@
45
45
 
46
46
 
47
47
 
48
- var _chunkUXTIMS3Gcjs = require('./chunk-UXTIMS3G.cjs');
49
48
 
49
+ var _chunk37W7YYXOcjs = require('./chunk-37W7YYXO.cjs');
50
50
 
51
- var _chunk7OTD2YPTcjs = require('./chunk-7OTD2YPT.cjs');
52
51
 
52
+ var _chunk7H3FCV4Pcjs = require('./chunk-7H3FCV4P.cjs');
53
53
 
54
54
 
55
55
 
@@ -70,7 +70,8 @@ var _chunk7OTD2YPTcjs = require('./chunk-7OTD2YPT.cjs');
70
70
 
71
71
 
72
72
 
73
- var _chunk4MVWIRBIcjs = require('./chunk-4MVWIRBI.cjs');
73
+
74
+ var _chunkMOZOUEMAcjs = require('./chunk-MOZOUEMA.cjs');
74
75
 
75
76
  // src/relay.ts
76
77
  var IpWindow = (_class = class {
@@ -224,7 +225,7 @@ function relayContext(raw, redactor) {
224
225
  return Array.isArray(bounded) ? {} : { context: redactor(bounded) };
225
226
  }
226
227
  function relayBreadcrumbs(raw, redactor) {
227
- const breadcrumbs = _chunkUXTIMS3Gcjs.sanitizeBreadcrumbs.call(void 0, raw, redactor);
228
+ const breadcrumbs = _chunk37W7YYXOcjs.sanitizeBreadcrumbs.call(void 0, raw, redactor);
228
229
  return breadcrumbs ? { breadcrumbs } : {};
229
230
  }
230
231
  var DEBUG_ID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
@@ -241,10 +242,10 @@ function relayDebugIds(raw, redactor) {
241
242
  return count ? { debugIds } : {};
242
243
  }
243
244
  function relayFingerprint(raw, redactor) {
244
- const values = _chunkUXTIMS3Gcjs.fingerprintValues.call(void 0, raw, redactor.text);
245
+ const values = _chunk37W7YYXOcjs.fingerprintValues.call(void 0, raw, redactor.text);
245
246
  return values ? { fingerprint: Array.isArray(raw) ? values : values[0] } : {};
246
247
  }
247
- var defaultRelayRedactor = _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, true);
248
+ var defaultRelayRedactor = _chunk37W7YYXOcjs.makeRedactor.call(void 0, true);
248
249
  function sanitizeBrowserPayload(raw, redactor = defaultRelayRedactor) {
249
250
  if (typeof raw !== "object" || raw === null) return null;
250
251
  const p = raw;
@@ -293,7 +294,7 @@ function forward(payload, opts) {
293
294
  const endpoint = (_nullishCoalesce(opts.endpoint, () => ( DEFAULT_ENDPOINT))).replace(/\/$/, "");
294
295
  const url = `${endpoint}/v1/browser`;
295
296
  const compat = opts.compatCheck !== false;
296
- if (compat) _chunk4MVWIRBIcjs.ensureCompatConfigured.call(void 0, endpoint);
297
+ if (compat) _chunkMOZOUEMAcjs.ensureCompatConfigured.call(void 0, endpoint);
297
298
  void fetch(url, {
298
299
  method: "POST",
299
300
  headers: {
@@ -307,12 +308,12 @@ function forward(payload, opts) {
307
308
  const types = new Set(
308
309
  (_nullishCoalesce(payload.events, () => ( []))).map((e) => String(e.type))
309
310
  );
310
- _chunk4MVWIRBIcjs.observeIngesterResponse.call(void 0, { status: response.status, headers: response.headers });
311
- for (const feature of _chunk4MVWIRBIcjs.featuresForBrowserEvents.call(void 0, types)) _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, feature);
311
+ _chunkMOZOUEMAcjs.observeIngesterResponse.call(void 0, { status: response.status, headers: response.headers });
312
+ for (const feature of _chunkMOZOUEMAcjs.featuresForBrowserEvents.call(void 0, types)) _chunkMOZOUEMAcjs.noteCompatFeature.call(void 0, feature);
312
313
  if ((_nullishCoalesce(payload.events, () => ( []))).some((e) => e.traceId)) {
313
- _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "browser_trace_propagation");
314
+ _chunkMOZOUEMAcjs.noteCompatFeature.call(void 0, "browser_trace_propagation");
314
315
  }
315
- _chunk4MVWIRBIcjs.noteRelayRejection.call(void 0, types, response.status, response.headers);
316
+ _chunkMOZOUEMAcjs.noteRelayRejection.call(void 0, types, response.status, response.headers);
316
317
  }).catch((err) => {
317
318
  (_nullishCoalesce(opts.onError, () => ( ((e) => console.warn("autter relay forward failed:", e)))))(
318
319
  err
@@ -321,7 +322,7 @@ function forward(payload, opts) {
321
322
  }
322
323
  function createBrowserRelayFetchHandler(opts) {
323
324
  const maxBody = _nullishCoalesce(opts.maxBodyBytes, () => ( DEFAULT_MAX_BODY));
324
- const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, opts.redact);
325
+ const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunk37W7YYXOcjs.makeRedactor.call(void 0, opts.redact);
325
326
  const limiter = opts.perIpRateLimit === false ? null : new IpWindow(_nullishCoalesce(opts.perIpRateLimit, () => ( 120)));
326
327
  return async (request) => {
327
328
  if (request.method !== "POST") {
@@ -368,7 +369,7 @@ function createBrowserRelayFetchHandler(opts) {
368
369
  }
369
370
  function createBrowserRelayHandler(opts) {
370
371
  const maxBody = _nullishCoalesce(opts.maxBodyBytes, () => ( DEFAULT_MAX_BODY));
371
- const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, opts.redact);
372
+ const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunk37W7YYXOcjs.makeRedactor.call(void 0, opts.redact);
372
373
  const limiter = opts.perIpRateLimit === false ? null : new IpWindow(_nullishCoalesce(opts.perIpRateLimit, () => ( 120)));
373
374
  function respond(res, status, body) {
374
375
  res.statusCode = status;
@@ -441,6 +442,9 @@ function createBrowserRelayHandler(opts) {
441
442
  }
442
443
 
443
444
  // src/server.ts
445
+ var _events = require('events');
446
+ var _module = require('module');
447
+ var _path = require('path');
444
448
  var _http = require('http');
445
449
  var _crypto = require('crypto');
446
450
 
@@ -742,7 +746,7 @@ var _async_hooks = require('async_hooks');
742
746
 
743
747
  var REQUEST_STATE = /* @__PURE__ */ Symbol.for("autter.runtime.request");
744
748
  var BOUND = /* @__PURE__ */ Symbol.for("autter.runtime.bound");
745
- var CAPTURED = _chunk4MVWIRBIcjs.sharedSlot.call(void 0, "requests", () => ({ captured: /* @__PURE__ */ new WeakSet() })).captured;
749
+ var CAPTURED = _chunkMOZOUEMAcjs.sharedSlot.call(void 0, "requests", () => ({ captured: /* @__PURE__ */ new WeakSet() })).captured;
746
750
  var capturer = () => {
747
751
  };
748
752
  function setRequestExceptionCapturer(fn) {
@@ -765,7 +769,7 @@ function expressRouteOf(req) {
765
769
  return route.startsWith("/") ? route : null;
766
770
  }
767
771
  function defaultShouldCapture(error) {
768
- return error instanceof _chunkUXTIMS3Gcjs.RuntimeError || _chunkUXTIMS3Gcjs.errorCodeOf.call(void 0, error) !== void 0 || _chunkUXTIMS3Gcjs.responseStatusOf.call(void 0, error) >= 500;
772
+ return error instanceof _chunk37W7YYXOcjs.RuntimeError || _chunk37W7YYXOcjs.errorCodeOf.call(void 0, error) !== void 0 || _chunk37W7YYXOcjs.responseStatusOf.call(void 0, error) >= 500;
769
773
  }
770
774
  function onRequestSpan(fn) {
771
775
  const active = _api.context.active();
@@ -789,7 +793,7 @@ function captureAtBoundary(error, state, rule = void 0, attributes) {
789
793
  markCaptured(error);
790
794
  try {
791
795
  const run = () => onRequestSpan(() => capturer(error, attributes));
792
- if (state && !state.sealed) _chunkUXTIMS3Gcjs.local.run(state, run);
796
+ if (state && !state.sealed) _chunk37W7YYXOcjs.local.run(state, run);
793
797
  else run();
794
798
  } catch (e15) {
795
799
  }
@@ -807,7 +811,7 @@ function captureRequestError(error, attributes) {
807
811
  }
808
812
  return;
809
813
  }
810
- captureAtBoundary(error, _chunkUXTIMS3Gcjs.currentOperation.call(void 0, ), true, attributes);
814
+ captureAtBoundary(error, _chunk37W7YYXOcjs.currentOperation.call(void 0, ), true, attributes);
811
815
  }
812
816
  function bindEmitter(emitter, state) {
813
817
  const target = emitter;
@@ -819,7 +823,7 @@ function bindEmitter(emitter, state) {
819
823
  let wrapped = wrappers.get(listener);
820
824
  if (!wrapped) {
821
825
  wrapped = function(...args) {
822
- return _chunkUXTIMS3Gcjs.local.run(
826
+ return _chunk37W7YYXOcjs.local.run(
823
827
  state,
824
828
  () => listener.apply(this, args)
825
829
  );
@@ -886,7 +890,7 @@ function pathOf(req) {
886
890
  function finishRequest(state, input) {
887
891
  if (state.sealed) return;
888
892
  state.name = (_nullishCoalesce(input.name, () => ( `${input.method} ${input.route}`))).slice(0, 200);
889
- state.outcome = _chunkUXTIMS3Gcjs.requestOutcome.call(void 0, {
893
+ state.outcome = _chunk37W7YYXOcjs.requestOutcome.call(void 0, {
890
894
  ...state.explicitOutcome ? { explicit: state.outcome } : {},
891
895
  ...state.error !== void 0 ? { error: state.error } : {},
892
896
  ...state.errorThrown ? { thrown: true } : {},
@@ -899,10 +903,10 @@ function finishRequest(state, input) {
899
903
  const remote = _api.trace.wrapSpanContext(input.span);
900
904
  _api.context.with(
901
905
  _api.trace.setSpan(_api.context.active(), remote),
902
- () => _chunkUXTIMS3Gcjs.reportExplicitFailure.call(void 0, state)
906
+ () => _chunk37W7YYXOcjs.reportExplicitFailure.call(void 0, state)
903
907
  );
904
- } else _chunkUXTIMS3Gcjs.reportExplicitFailure.call(void 0, state);
905
- _chunkUXTIMS3Gcjs.emitSummary.call(void 0, state, {
908
+ } else _chunk37W7YYXOcjs.reportExplicitFailure.call(void 0, state);
909
+ _chunk37W7YYXOcjs.emitSummary.call(void 0, state, {
906
910
  http: {
907
911
  "http.request.method": input.method,
908
912
  "http.route": input.route,
@@ -913,14 +917,14 @@ function finishRequest(state, input) {
913
917
  });
914
918
  }
915
919
  function beginNodeRequest(req, res, options, route) {
916
- const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkUXTIMS3Gcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
917
- const requestId = _chunkUXTIMS3Gcjs.resolveRequestId.call(void 0,
920
+ const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunk37W7YYXOcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
921
+ const requestId = _chunk37W7YYXOcjs.resolveRequestId.call(void 0,
918
922
  options.trustRequestId === false ? void 0 : req.headers[header]
919
923
  );
920
924
  const method = (_nullishCoalesce(req.method, () => ( "GET"))).toUpperCase();
921
925
  const path = pathOf(req);
922
- const state = _chunkUXTIMS3Gcjs.createRequestState.call(void 0, {
923
- name: `${method} ${_chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, path)}`,
926
+ const state = _chunk37W7YYXOcjs.createRequestState.call(void 0, {
927
+ name: `${method} ${_chunk37W7YYXOcjs.normalizeRoutePath.call(void 0, path)}`,
924
928
  requestId,
925
929
  req,
926
930
  res
@@ -944,7 +948,7 @@ function beginNodeRequest(req, res, options, route) {
944
948
  const done = () => {
945
949
  finishRequest(state, {
946
950
  method,
947
- route: _nullishCoalesce(_nullishCoalesce(_optionalChain([route, 'optionalCall', _20 => _20()]), () => ( expressRouteOf(req))), () => ( _chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, path))),
951
+ route: _nullishCoalesce(_nullishCoalesce(_optionalChain([route, 'optionalCall', _20 => _20()]), () => ( expressRouteOf(req))), () => ( _chunk37W7YYXOcjs.normalizeRoutePath.call(void 0, path))),
948
952
  status: res.statusCode,
949
953
  aborted: !finished,
950
954
  ...spanContext ? { span: spanContext } : {}
@@ -958,50 +962,50 @@ function beginNodeRequest(req, res, options, route) {
958
962
  return state;
959
963
  }
960
964
  function autterRequests(options = {}) {
961
- const ignored = _chunkUXTIMS3Gcjs.compileIgnore.call(void 0, options.ignore);
965
+ const ignored = _chunk37W7YYXOcjs.compileIgnore.call(void 0, options.ignore);
962
966
  return function autterRequestsMiddleware(req, res, next) {
963
967
  if (req[REQUEST_STATE] || ignored(pathOf(req))) {
964
968
  next();
965
969
  return;
966
970
  }
967
971
  const state = beginNodeRequest(req, res, options);
968
- _chunkUXTIMS3Gcjs.local.run(state, () => next());
972
+ _chunk37W7YYXOcjs.local.run(state, () => next());
969
973
  };
970
974
  }
971
975
  function autterErrorResponse(options = {}) {
972
976
  return function autterErrorResponseMiddleware(error, req, res, next) {
973
977
  const state = req[REQUEST_STATE];
974
- if (state) _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error, true, state);
978
+ if (state) _chunk37W7YYXOcjs.noteOperationError.call(void 0, error, true, state);
975
979
  captureAtBoundary(error, state, options.capture);
976
980
  if (res.headersSent) {
977
981
  next(error);
978
982
  return;
979
983
  }
980
- const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkUXTIMS3Gcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
984
+ const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunk37W7YYXOcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
981
985
  const inbound = _optionalChain([req, 'access', _21 => _21.headers, 'optionalAccess', _22 => _22[header]]);
982
986
  const requestId = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _23 => _23.requestId]), () => ( (typeof inbound === "string" ? inbound.slice(0, 128) : void 0)));
983
- res.statusCode = _chunkUXTIMS3Gcjs.responseStatusOf.call(void 0, error);
987
+ res.statusCode = _chunk37W7YYXOcjs.responseStatusOf.call(void 0, error);
984
988
  res.setHeader("content-type", "application/json; charset=utf-8");
985
- res.end(JSON.stringify(_chunkUXTIMS3Gcjs.toClientError.call(void 0, error, requestId)));
989
+ res.end(JSON.stringify(_chunk37W7YYXOcjs.toClientError.call(void 0, error, requestId)));
986
990
  };
987
991
  }
988
992
  var RESOURCE = /* @__PURE__ */ Symbol.for("autter.runtime.resource");
989
993
  function autterFastify(fastify, options, done) {
990
994
  const opts = _nullishCoalesce(options, () => ( {}));
991
- const header = (_nullishCoalesce(opts.requestIdHeader, () => ( _chunkUXTIMS3Gcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
992
- const ignored = _chunkUXTIMS3Gcjs.compileIgnore.call(void 0, opts.ignore);
995
+ const header = (_nullishCoalesce(opts.requestIdHeader, () => ( _chunk37W7YYXOcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
996
+ const ignored = _chunk37W7YYXOcjs.compileIgnore.call(void 0, opts.ignore);
993
997
  const stateOf = (request) => request[REQUEST_STATE];
994
998
  fastify.addHook("onRequest", ((request, reply, next) => {
995
999
  if (ignored(request.url) || request.raw[REQUEST_STATE]) {
996
1000
  next();
997
1001
  return;
998
1002
  }
999
- const requestId = _chunkUXTIMS3Gcjs.resolveRequestId.call(void 0,
1003
+ const requestId = _chunk37W7YYXOcjs.resolveRequestId.call(void 0,
1000
1004
  opts.trustRequestId === false ? void 0 : request.headers[header]
1001
1005
  );
1002
1006
  const method = String(_nullishCoalesce(request.method, () => ( "GET"))).toUpperCase();
1003
- const state = _chunkUXTIMS3Gcjs.createRequestState.call(void 0, {
1004
- name: `${method} ${_chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, request.url)}`,
1007
+ const state = _chunk37W7YYXOcjs.createRequestState.call(void 0, {
1008
+ name: `${method} ${_chunk37W7YYXOcjs.normalizeRoutePath.call(void 0, request.url)}`,
1005
1009
  requestId,
1006
1010
  req: request.raw,
1007
1011
  res: reply.raw
@@ -1021,7 +1025,7 @@ function autterFastify(fastify, options, done) {
1021
1025
  let finished = false;
1022
1026
  const finish = (aborted) => finishRequest(state, {
1023
1027
  method,
1024
- route: _nullishCoalesce(_nullishCoalesce(_optionalChain([request, 'access', _28 => _28.routeOptions, 'optionalAccess', _29 => _29.url]), () => ( request.routerPath)), () => ( _chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, request.url))),
1028
+ route: _nullishCoalesce(_nullishCoalesce(_optionalChain([request, 'access', _28 => _28.routeOptions, 'optionalAccess', _29 => _29.url]), () => ( request.routerPath)), () => ( _chunk37W7YYXOcjs.normalizeRoutePath.call(void 0, request.url))),
1025
1029
  status: reply.raw.statusCode || reply.statusCode,
1026
1030
  aborted,
1027
1031
  ...spanContext ? { span: spanContext } : {}
@@ -1031,7 +1035,7 @@ function autterFastify(fastify, options, done) {
1031
1035
  finish(false);
1032
1036
  });
1033
1037
  reply.raw.once("close", () => finish(!finished));
1034
- _chunkUXTIMS3Gcjs.local.run(state, () => {
1038
+ _chunk37W7YYXOcjs.local.run(state, () => {
1035
1039
  request[RESOURCE] = new (0, _async_hooks.AsyncResource)("autter-request");
1036
1040
  next();
1037
1041
  });
@@ -1053,7 +1057,7 @@ function autterFastify(fastify, options, done) {
1053
1057
  }));
1054
1058
  fastify.addHook("onError", ((request, _reply, error, next) => {
1055
1059
  const state = stateOf(request);
1056
- if (state) _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error, true, state);
1060
+ if (state) _chunk37W7YYXOcjs.noteOperationError.call(void 0, error, true, state);
1057
1061
  captureAtBoundary(error, state);
1058
1062
  next();
1059
1063
  }));
@@ -1084,8 +1088,8 @@ function withHeaders(response, header, requestId) {
1084
1088
  }
1085
1089
  }
1086
1090
  function withRuntimeRequest(handler, options = {}) {
1087
- const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkUXTIMS3Gcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
1088
- const ignored = _chunkUXTIMS3Gcjs.compileIgnore.call(void 0, options.ignore);
1091
+ const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunk37W7YYXOcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
1092
+ const ignored = _chunk37W7YYXOcjs.compileIgnore.call(void 0, options.ignore);
1089
1093
  return async (request, ...rest) => {
1090
1094
  let pathname = "/";
1091
1095
  try {
@@ -1093,12 +1097,12 @@ function withRuntimeRequest(handler, options = {}) {
1093
1097
  } catch (e22) {
1094
1098
  }
1095
1099
  if (ignored(pathname)) return handler(request, ...rest);
1096
- const requestId = _chunkUXTIMS3Gcjs.resolveRequestId.call(void 0,
1100
+ const requestId = _chunk37W7YYXOcjs.resolveRequestId.call(void 0,
1097
1101
  options.trustRequestId === false ? void 0 : request.headers.get(header)
1098
1102
  );
1099
1103
  const method = String(_nullishCoalesce(request.method, () => ( "GET"))).toUpperCase();
1100
- const route = _nullishCoalesce(options.route, () => ( _chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, pathname)));
1101
- const state = _chunkUXTIMS3Gcjs.createRequestState.call(void 0, {
1104
+ const route = _nullishCoalesce(options.route, () => ( _chunk37W7YYXOcjs.normalizeRoutePath.call(void 0, pathname)));
1105
+ const state = _chunk37W7YYXOcjs.createRequestState.call(void 0, {
1102
1106
  name: `${method} ${_nullishCoalesce(options.name, () => ( route))}`,
1103
1107
  requestId,
1104
1108
  req: request
@@ -1112,11 +1116,11 @@ function withRuntimeRequest(handler, options = {}) {
1112
1116
  const spanContext = _optionalChain([span, 'optionalAccess', _32 => _32.spanContext, 'call', _33 => _33()]);
1113
1117
  let status = 500;
1114
1118
  try {
1115
- const response = await _chunkUXTIMS3Gcjs.local.run(state, async () => {
1119
+ const response = await _chunk37W7YYXOcjs.local.run(state, async () => {
1116
1120
  try {
1117
1121
  return await handler(request, ...rest);
1118
1122
  } catch (error) {
1119
- _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error, true, state);
1123
+ _chunk37W7YYXOcjs.noteOperationError.call(void 0, error, true, state);
1120
1124
  captureAtBoundary(error, state, true);
1121
1125
  throw error;
1122
1126
  }
@@ -1135,7 +1139,7 @@ function withRuntimeRequest(handler, options = {}) {
1135
1139
  });
1136
1140
  if (options.waitUntil) {
1137
1141
  try {
1138
- options.waitUntil(_chunkUXTIMS3Gcjs.flushRuntimeLogs.call(void 0, ).catch(() => {
1142
+ options.waitUntil(_chunk37W7YYXOcjs.flushRuntimeLogs.call(void 0, ).catch(() => {
1139
1143
  }));
1140
1144
  } catch (e23) {
1141
1145
  }
@@ -1147,7 +1151,7 @@ function startHookRequest(res) {
1147
1151
  const req = res.req;
1148
1152
  if (!req || req[REQUEST_STATE]) return;
1149
1153
  const state = beginNodeRequest(req, res, {});
1150
- _chunkUXTIMS3Gcjs.local.enterWith(state);
1154
+ _chunk37W7YYXOcjs.local.enterWith(state);
1151
1155
  }
1152
1156
 
1153
1157
  // src/unhandled-rejections.ts
@@ -1276,11 +1280,45 @@ function installUnhandledRejectionCapture(capture, mode = unhandledRejectionsMod
1276
1280
  };
1277
1281
  }
1278
1282
 
1283
+ // src/route-label.ts
1284
+
1285
+ var ours = /* @__PURE__ */ new WeakMap();
1286
+ var RAW_PATH_SPAN_TYPES = /* @__PURE__ */ new Set(["BaseServer.renderToResponse"]);
1287
+ function noteFrameworkRoute(parent, attributes) {
1288
+ const route = _optionalChain([attributes, 'optionalAccess', _42 => _42["next.route"]]);
1289
+ if (typeof route !== "string" || !route.startsWith("/")) return;
1290
+ if (RAW_PATH_SPAN_TYPES.has(String(_nullishCoalesce(_optionalChain([attributes, 'optionalAccess', _43 => _43["next.span_type"]]), () => ( ""))))) return;
1291
+ const rpc = _core.getRPCMetadata.call(void 0, parent);
1292
+ if (!rpc || rpc.type !== _core.RPCType.HTTP) return;
1293
+ const mine = ours.get(rpc);
1294
+ if (rpc.route !== void 0 && rpc.route !== mine) return;
1295
+ if (mine !== void 0 && mine.includes("[") && !route.includes("[")) return;
1296
+ if (mine !== void 0 && (route === `${mine}/route` || route === `${mine}/page`)) return;
1297
+ rpc.route = route;
1298
+ ours.set(rpc, route);
1299
+ }
1300
+ var RouteLabelSampler = class {
1301
+ constructor(delegate) {
1302
+ this.delegate = delegate;
1303
+ }
1304
+
1305
+ shouldSample(ctx, traceId, spanName, spanKind, attributes, links) {
1306
+ try {
1307
+ noteFrameworkRoute(ctx, attributes);
1308
+ } catch (e29) {
1309
+ }
1310
+ return this.delegate.shouldSample(ctx, traceId, spanName, spanKind, attributes, links);
1311
+ }
1312
+ toString() {
1313
+ return `RouteLabel(${this.delegate.toString()})`;
1314
+ }
1315
+ };
1316
+
1279
1317
  // src/server.ts
1280
- var S = _chunk4MVWIRBIcjs.sharedSlot.call(void 0, "server", () => ({
1318
+ var S = _chunkMOZOUEMAcjs.sharedSlot.call(void 0, "server", () => ({
1281
1319
  active: null,
1282
1320
  alwaysOnProvider: null,
1283
- redactor: _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, true),
1321
+ redactor: _chunk37W7YYXOcjs.makeRedactor.call(void 0, true),
1284
1322
  loggerOnlyCapture: null,
1285
1323
  hookRequests: false
1286
1324
  }));
@@ -1380,7 +1418,7 @@ var ErrorTraceRetentionProcessor = (_class2 = class {
1380
1418
  this.retainErrors = retainErrors;
1381
1419
  this.slowThresholdMs = slowThresholdMs;
1382
1420
  this.sweeper = setInterval(() => this.sweep(), RETENTION_SWEEP_INTERVAL_MS);
1383
- _optionalChain([this, 'access', _42 => _42.sweeper, 'access', _43 => _43.unref, 'optionalCall', _44 => _44()]);
1421
+ _optionalChain([this, 'access', _44 => _44.sweeper, 'access', _45 => _45.unref, 'optionalCall', _46 => _46()]);
1384
1422
  }
1385
1423
 
1386
1424
 
@@ -1411,7 +1449,7 @@ var ErrorTraceRetentionProcessor = (_class2 = class {
1411
1449
  }
1412
1450
  /** Promote the active trace, if any — called on captured errors. */
1413
1451
  retainActiveTrace() {
1414
- const active = _optionalChain([_api.trace, 'access', _45 => _45.getActiveSpan, 'call', _46 => _46(), 'optionalAccess', _47 => _47.spanContext, 'call', _48 => _48()]);
1452
+ const active = _optionalChain([_api.trace, 'access', _47 => _47.getActiveSpan, 'call', _48 => _48(), 'optionalAccess', _49 => _49.spanContext, 'call', _50 => _50()]);
1415
1453
  if (!active || (active.traceFlags & _api.TraceFlags.SAMPLED) !== 0) return;
1416
1454
  const entry = this.entryFor(active.traceId);
1417
1455
  if (entry.retained) return;
@@ -1532,15 +1570,15 @@ async function runLlmSpan(tracer, info, fn) {
1532
1570
  return result;
1533
1571
  } catch (err) {
1534
1572
  recordError(span, err);
1535
- if (_chunkUXTIMS3Gcjs.isError.call(void 0, err)) span.setAttribute("error.type", err.name);
1573
+ if (_chunk37W7YYXOcjs.isError.call(void 0, err)) span.setAttribute("error.type", err.name);
1536
1574
  throw err;
1537
1575
  } finally {
1538
1576
  span.end();
1539
- _chunkUXTIMS3Gcjs.recordOperationAiUsage.call(void 0, { ...usage, model: _nullishCoalesce(responseModel, () => ( info.model)) });
1577
+ _chunk37W7YYXOcjs.recordOperationAiUsage.call(void 0, { ...usage, model: _nullishCoalesce(responseModel, () => ( info.model)) });
1540
1578
  }
1541
1579
  }
1542
1580
  function recordLlmCall(tracer, call) {
1543
- _chunkUXTIMS3Gcjs.recordOperationAiUsage.call(void 0, { ...call, model: call.model });
1581
+ _chunk37W7YYXOcjs.recordOperationAiUsage.call(void 0, { ...call, model: call.model });
1544
1582
  const durationMs = Math.max(0, _nullishCoalesce(call.durationMs, () => ( 0)));
1545
1583
  const endTime = /* @__PURE__ */ new Date();
1546
1584
  const startTime = new Date(endTime.getTime() - durationMs);
@@ -1554,7 +1592,7 @@ function recordLlmCall(tracer, call) {
1554
1592
  );
1555
1593
  if (call.error !== void 0 && call.error !== null) {
1556
1594
  recordError(span, call.error);
1557
- if (_chunkUXTIMS3Gcjs.isError.call(void 0, call.error)) {
1595
+ if (_chunk37W7YYXOcjs.isError.call(void 0, call.error)) {
1558
1596
  span.setAttribute("error.type", call.error.name);
1559
1597
  }
1560
1598
  } else {
@@ -1565,7 +1603,7 @@ function recordLlmCall(tracer, call) {
1565
1603
  async function runWithSpan(tracer, name, fn, attributes, links) {
1566
1604
  const span = tracer.startSpan(name, {
1567
1605
  attributes,
1568
- ..._optionalChain([links, 'optionalAccess', _49 => _49.length]) ? { links } : {}
1606
+ ..._optionalChain([links, 'optionalAccess', _51 => _51.length]) ? { links } : {}
1569
1607
  });
1570
1608
  try {
1571
1609
  const result = await _api.context.with(
@@ -1582,14 +1620,14 @@ async function runWithSpan(tracer, name, fn, attributes, links) {
1582
1620
  }
1583
1621
  }
1584
1622
  function recordError(span, err) {
1585
- const isErr = _chunkUXTIMS3Gcjs.isError.call(void 0, err);
1623
+ const isErr = _chunk37W7YYXOcjs.isError.call(void 0, err);
1586
1624
  const message = S.redactor.text(isErr ? err.message : String(err));
1587
1625
  if (isErr) {
1588
1626
  span.addEvent("exception", {
1589
1627
  "exception.type": err.name,
1590
1628
  "exception.message": message,
1591
1629
  ...err.stack ? { "exception.stacktrace": S.redactor.text(err.stack) } : {},
1592
- ..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text, err)
1630
+ ..._chunk37W7YYXOcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text, err)
1593
1631
  });
1594
1632
  }
1595
1633
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message });
@@ -1597,28 +1635,44 @@ function recordError(span, err) {
1597
1635
  function redactWithActive(attributes) {
1598
1636
  return S.redactor(attributes);
1599
1637
  }
1600
- function captureExpressRoute(_span, response) {
1638
+ function patchLoadedHttpModules() {
1639
+ try {
1640
+ const load = _module.createRequire.call(void 0, _path.join.call(void 0, process.cwd(), "autter-runtime-http.cjs"));
1641
+ load("http");
1642
+ load("https");
1643
+ } catch (e30) {
1644
+ }
1645
+ }
1646
+ var METRIC_ROUTE_ATTR = "autter.metric_has_route";
1647
+ function captureRequestRoute(span, response) {
1601
1648
  if (!(response instanceof _http.ServerResponse)) return;
1602
1649
  const rpcMetadata = _core.getRPCMetadata.call(void 0, _api.context.active());
1603
- if (_optionalChain([rpcMetadata, 'optionalAccess', _50 => _50.type]) !== _core.RPCType.HTTP) return;
1650
+ if (_optionalChain([rpcMetadata, 'optionalAccess', _52 => _52.type]) !== _core.RPCType.HTTP) return;
1651
+ let failed = false;
1652
+ response.on(_events.errorMonitor, () => {
1653
+ failed = true;
1654
+ });
1604
1655
  const setRoute = () => {
1605
1656
  if (rpcMetadata.route) return;
1606
1657
  const route = expressRouteOf(response.req);
1607
1658
  if (route) rpcMetadata.route = route;
1608
1659
  };
1609
1660
  response.prependListener("finish", setRoute);
1610
- response.prependListener("close", setRoute);
1661
+ response.prependListener("close", () => {
1662
+ setRoute();
1663
+ if (rpcMetadata.route && !failed) span.setAttribute(METRIC_ROUTE_ATTR, true);
1664
+ });
1611
1665
  if (S.hookRequests) startHookRequest(response);
1612
1666
  }
1613
1667
  function structuredErrorAttributes(error) {
1614
- const attrs = { ..._chunkUXTIMS3Gcjs.errorAttributes.call(void 0, error, { causes: false }) };
1615
- const internal = _chunkUXTIMS3Gcjs.errorInternal.call(void 0, error);
1668
+ const attrs = { ..._chunk37W7YYXOcjs.errorAttributes.call(void 0, error, { causes: false }) };
1669
+ const internal = _chunk37W7YYXOcjs.errorInternal.call(void 0, error);
1616
1670
  if (internal) {
1617
1671
  try {
1618
1672
  attrs["autter.error.internal"] = JSON.stringify(
1619
1673
  S.redactor(internal)
1620
1674
  ).slice(0, 4e3);
1621
- } catch (e29) {
1675
+ } catch (e31) {
1622
1676
  }
1623
1677
  }
1624
1678
  return attrs;
@@ -1630,9 +1684,9 @@ function initAutterServer(options) {
1630
1684
  ""
1631
1685
  );
1632
1686
  const headers = { authorization: `Bearer ${options.apiKey}` };
1633
- const redactor = _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
1687
+ const redactor = _chunk37W7YYXOcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
1634
1688
  const queryPolicy = makeUrlQueryPolicy(options.keepQueryParams);
1635
- const traceExporter = () => new (0, _chunk4MVWIRBIcjs.CountingExporter)(
1689
+ const traceExporter = () => new (0, _chunkMOZOUEMAcjs.CountingExporter)(
1636
1690
  new RedactingSpanExporter(
1637
1691
  new (0, _exportertraceotlphttp.OTLPTraceExporter)({ url: `${endpoint}/v1/traces`, headers }),
1638
1692
  () => redactor,
@@ -1640,11 +1694,11 @@ function initAutterServer(options) {
1640
1694
  )
1641
1695
  );
1642
1696
  const environment = _nullishCoalesce(_nullishCoalesce(options.environment, () => ( process.env.NODE_ENV)), () => ( "production"));
1643
- if (_chunk4MVWIRBIcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunk4MVWIRBIcjs.setDebugMode.call(void 0, true);
1644
- _chunk4MVWIRBIcjs.debugLog.call(void 0, `initialising service=${options.service} endpoint=${endpoint}`);
1697
+ if (_chunkMOZOUEMAcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunkMOZOUEMAcjs.setDebugMode.call(void 0, true);
1698
+ _chunkMOZOUEMAcjs.debugLog.call(void 0, `initialising service=${options.service} endpoint=${endpoint}`);
1645
1699
  S.redactor = redactor;
1646
- const distro = _nullishCoalesce(options.distro, () => ( _chunk4MVWIRBIcjs.SDK_IDENTITY));
1647
- _chunk4MVWIRBIcjs.configureCompatCheck.call(void 0, { endpoint, enabled: options.compatCheck !== false, sdk: distro });
1700
+ const distro = _nullishCoalesce(options.distro, () => ( _chunkMOZOUEMAcjs.SDK_IDENTITY));
1701
+ _chunkMOZOUEMAcjs.configureCompatCheck.call(void 0, { endpoint, enabled: options.compatCheck !== false, sdk: distro });
1648
1702
  const resource = new (0, _resources.Resource)({
1649
1703
  [_semanticconventions.ATTR_SERVICE_NAME]: options.service,
1650
1704
  "service.instance.id": (options.instanceId || process.env.AUTTER_RUNTIME_INSTANCE_ID || _crypto.randomUUID.call(void 0, )).slice(0, 128),
@@ -1656,9 +1710,16 @@ function initAutterServer(options) {
1656
1710
  "telemetry.distro.version": distro.version,
1657
1711
  // Tells the ingester request metrics arrive on the metrics pipe, so
1658
1712
  // it must not also fold our server spans into usage rollups (that
1659
- // would double-count every sampled request).
1660
- "autter.metrics_wired": true
1713
+ // would double-count every sampled request)...
1714
+ "autter.metrics_wired": true,
1715
+ // ...for the requests whose metric carries their route: those
1716
+ // request spans say so (`autter.metric_has_route`, see
1717
+ // captureRequestRoute). Ingesters honour metrics_wired only with
1718
+ // this, so an older SDK, whose Next.js metrics have no route, keeps
1719
+ // its span-fed per-route counts.
1720
+ "autter.metrics_routes": true
1661
1721
  });
1722
+ const errorFilter = _chunk37W7YYXOcjs.createErrorFilter.call(void 0, { ignoreErrors: options.ignoreErrors, sampleRate: options.sampleRate });
1662
1723
  const rootSampler = new (0, _sdktracebase.TraceIdRatioBasedSampler)(_nullishCoalesce(options.traceSampleRate, () => ( 0.01)));
1663
1724
  const headSampler = new (0, _sdktracebase.ParentBasedSampler)({
1664
1725
  root: rootSampler,
@@ -1674,6 +1735,7 @@ function initAutterServer(options) {
1674
1735
  const retainTraces = retainOnError || slowThresholdMs > 0;
1675
1736
  let sampler = retainTraces ? new RecordUnsampledSampler(headSampler) : headSampler;
1676
1737
  if (options.llmTracing !== false) sampler = new LlmAwareSampler(sampler);
1738
+ sampler = new RouteLabelSampler(sampler);
1677
1739
  const errorTraceBuffer = retainTraces ? new ErrorTraceRetentionProcessor(
1678
1740
  new (0, _sdktracebase.BatchSpanProcessor)(traceExporter(), { scheduledDelayMillis: 2e3 }),
1679
1741
  retainOnError,
@@ -1712,15 +1774,16 @@ function initAutterServer(options) {
1712
1774
  ) })
1713
1775
  ],
1714
1776
  instrumentations: [
1715
- new (0, _instrumentationhttp.HttpInstrumentation)({ responseHook: captureExpressRoute }),
1777
+ new (0, _instrumentationhttp.HttpInstrumentation)({ responseHook: captureRequestRoute }),
1716
1778
  ..._nullishCoalesce(options.instrumentations, () => ( []))
1717
1779
  ]
1718
1780
  });
1719
1781
  sdk.start();
1782
+ patchLoadedHttpModules();
1720
1783
  const stopMemoryMetrics = options.memoryMetrics === false ? null : startMemoryMetrics();
1721
- _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "endpoint_latency");
1722
- if (stopMemoryMetrics) _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "memory_metrics");
1723
- if (options.llmTracing !== false) _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "llm_calls");
1784
+ _chunkMOZOUEMAcjs.noteCompatFeature.call(void 0, "endpoint_latency");
1785
+ if (stopMemoryMetrics) _chunkMOZOUEMAcjs.noteCompatFeature.call(void 0, "memory_metrics");
1786
+ if (options.llmTracing !== false) _chunkMOZOUEMAcjs.noteCompatFeature.call(void 0, "llm_calls");
1724
1787
  const alwaysOnProvider = new (0, _sdktracebase.BasicTracerProvider)({
1725
1788
  resource,
1726
1789
  sampler: new (0, _sdktracebase.AlwaysOnSampler)(),
@@ -1732,25 +1795,35 @@ function initAutterServer(options) {
1732
1795
  const processTracer = alwaysOnProvider.getTracer("autter-processes");
1733
1796
  const llmTracer = alwaysOnProvider.getTracer("autter-llm");
1734
1797
  function captureException2(error, attributes) {
1735
- _optionalChain([errorTraceBuffer, 'optionalAccess', _51 => _51.retainActiveTrace, 'call', _52 => _52()]);
1736
- _chunk4MVWIRBIcjs.telemetryStats.markCaptured();
1737
- const isErr = _chunkUXTIMS3Gcjs.isError.call(void 0, error);
1798
+ const isErrValue = _chunk37W7YYXOcjs.isError.call(void 0, error);
1799
+ const reported = errorFilter({
1800
+ type: isErrValue ? String(_nullishCoalesce(error.name, () => ( ""))) : "Error",
1801
+ message: isErrValue ? String(_nullishCoalesce(error.message, () => ( ""))) : String(error),
1802
+ crash: _optionalChain([attributes, 'optionalAccess', _53 => _53["autter.unhandled"]]) === true || _optionalChain([attributes, 'optionalAccess', _54 => _54["autter.unhandled_rejection"]]) === true
1803
+ });
1804
+ if (!reported) {
1805
+ markCaptured(error);
1806
+ return;
1807
+ }
1808
+ _optionalChain([errorTraceBuffer, 'optionalAccess', _55 => _55.retainActiveTrace, 'call', _56 => _56()]);
1809
+ _chunkMOZOUEMAcjs.telemetryStats.markCaptured();
1810
+ const isErr = _chunk37W7YYXOcjs.isError.call(void 0, error);
1738
1811
  const message = redactor.text(isErr ? error.message : String(error));
1739
1812
  const stackText = isErr && error.stack ? redactor.text(error.stack) : "";
1740
- const split = _chunkUXTIMS3Gcjs.splitFingerprint.call(void 0, attributes);
1741
- const fingerprint = _chunkUXTIMS3Gcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redactor.text);
1742
- if (fingerprint["autter.fingerprint"]) _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "fingerprint_override");
1813
+ const split = _chunk37W7YYXOcjs.splitFingerprint.call(void 0, attributes);
1814
+ const fingerprint = _chunk37W7YYXOcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redactor.text);
1815
+ if (fingerprint["autter.fingerprint"]) _chunkMOZOUEMAcjs.noteCompatFeature.call(void 0, "fingerprint_override");
1743
1816
  const redacted = redactor(split.attributes);
1744
1817
  const activeSpan = _api.trace.getActiveSpan();
1745
- const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _53 => _53.isRecording, 'call', _54 => _54()]) === true;
1818
+ const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _57 => _57.isRecording, 'call', _58 => _58()]) === true;
1746
1819
  const span = reuseActive ? activeSpan : errorTracer.startSpan(isErr ? error.name : "Error");
1747
1820
  const structured = structuredErrorAttributes(error);
1748
- const causes = _chunkUXTIMS3Gcjs.errorAttributes.call(void 0, error);
1821
+ const causes = _chunk37W7YYXOcjs.errorAttributes.call(void 0, error);
1749
1822
  const declared = {
1750
1823
  ...Object.fromEntries(Object.entries(causes).filter(([key]) => key !== "autter.error.internal")),
1751
1824
  ...fingerprint
1752
1825
  };
1753
- const requestId = _optionalChain([_chunkUXTIMS3Gcjs.currentOperation.call(void 0, ), 'optionalAccess', _55 => _55.requestId]);
1826
+ const requestId = _optionalChain([_chunk37W7YYXOcjs.currentOperation.call(void 0, ), 'optionalAccess', _59 => _59.requestId]);
1754
1827
  span.setAttributes({
1755
1828
  "autter.severity": "error",
1756
1829
  ...redacted,
@@ -1758,8 +1831,8 @@ function initAutterServer(options) {
1758
1831
  ...requestId ? { "autter.request.id": requestId } : {}
1759
1832
  });
1760
1833
  markCaptured(error);
1761
- _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error);
1762
- _chunkUXTIMS3Gcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
1834
+ _chunk37W7YYXOcjs.noteOperationError.call(void 0, error);
1835
+ _chunk37W7YYXOcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
1763
1836
  if (isErr && stackText) {
1764
1837
  span.addEvent("exception", {
1765
1838
  "exception.type": error.name,
@@ -1767,28 +1840,29 @@ function initAutterServer(options) {
1767
1840
  "exception.stacktrace": stackText,
1768
1841
  ...redacted["autter.handled"] === true ? { "autter.handled": true, "autter.sampled": redacted["autter.sampled"] === true } : {},
1769
1842
  ...declared,
1770
- ..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
1843
+ ..._chunk37W7YYXOcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
1771
1844
  });
1772
1845
  } else {
1773
- const stack = _optionalChain([new Error(), 'access', _56 => _56.stack, 'optionalAccess', _57 => _57.split, 'call', _58 => _58("\n"), 'access', _59 => _59.filter, 'call', _60 => _60((line, i) => i === 0 || !line.includes("captureException")), 'access', _61 => _61.join, 'call', _62 => _62("\n")]);
1846
+ const stack = _optionalChain([new Error(), 'access', _60 => _60.stack, 'optionalAccess', _61 => _61.split, 'call', _62 => _62("\n"), 'access', _63 => _63.filter, 'call', _64 => _64((line, i) => i === 0 || !line.includes("captureException")), 'access', _65 => _65.join, 'call', _66 => _66("\n")]);
1774
1847
  span.addEvent("exception", {
1775
1848
  "exception.type": isErr ? error.name : "Error",
1776
1849
  "exception.message": message,
1777
1850
  ...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
1778
1851
  ...redacted["autter.handled"] === true ? { "autter.handled": true, "autter.sampled": redacted["autter.sampled"] === true } : {},
1779
1852
  ...declared,
1780
- ..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
1853
+ ..._chunk37W7YYXOcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
1781
1854
  });
1782
1855
  }
1783
1856
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message });
1784
1857
  if (!reuseActive) span.end();
1785
1858
  }
1786
1859
  function captureMessage2(message, severity = "warning", attributes) {
1860
+ if (!errorFilter({ type: "Message", message: String(message), severity })) return;
1787
1861
  if (severity === "error" || severity === "fatal") {
1788
- _optionalChain([errorTraceBuffer, 'optionalAccess', _63 => _63.retainActiveTrace, 'call', _64 => _64()]);
1862
+ _optionalChain([errorTraceBuffer, 'optionalAccess', _67 => _67.retainActiveTrace, 'call', _68 => _68()]);
1789
1863
  }
1790
- _chunk4MVWIRBIcjs.telemetryStats.markCaptured();
1791
- const stack = _optionalChain([new Error(), 'access', _65 => _65.stack, 'optionalAccess', _66 => _66.split, 'call', _67 => _67("\n"), 'access', _68 => _68.filter, 'call', _69 => _69((line, i) => i === 0 || !line.includes("captureMessage")), 'access', _70 => _70.join, 'call', _71 => _71("\n")]);
1864
+ _chunkMOZOUEMAcjs.telemetryStats.markCaptured();
1865
+ const stack = _optionalChain([new Error(), 'access', _69 => _69.stack, 'optionalAccess', _70 => _70.split, 'call', _71 => _71("\n"), 'access', _72 => _72.filter, 'call', _73 => _73((line, i) => i === 0 || !line.includes("captureMessage")), 'access', _74 => _74.join, 'call', _75 => _75("\n")]);
1792
1866
  const safeMessage = redactor.text(message);
1793
1867
  const span = errorTracer.startSpan("Message", {
1794
1868
  attributes: { "autter.severity": severity, ...redactor(attributes) }
@@ -1798,16 +1872,17 @@ function initAutterServer(options) {
1798
1872
  "exception.message": safeMessage,
1799
1873
  ...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
1800
1874
  "autter.severity": severity,
1801
- ..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, redactor.text)
1875
+ ..._chunk37W7YYXOcjs.breadcrumbEventAttributes.call(void 0, redactor.text)
1802
1876
  });
1803
1877
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
1804
1878
  span.end();
1805
1879
  }
1806
1880
  function reportOutcome2(name, message, attributes) {
1807
- _optionalChain([errorTraceBuffer, 'optionalAccess', _72 => _72.retainActiveTrace, 'call', _73 => _73()]);
1808
- _chunk4MVWIRBIcjs.telemetryStats.markCaptured();
1881
+ if (!errorFilter({ type: "OutcomeFailure", message: `${name}: ${message}` })) return;
1882
+ _optionalChain([errorTraceBuffer, 'optionalAccess', _76 => _76.retainActiveTrace, 'call', _77 => _77()]);
1883
+ _chunkMOZOUEMAcjs.telemetryStats.markCaptured();
1809
1884
  const activeSpan = _api.trace.getActiveSpan();
1810
- const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _74 => _74.isRecording, 'call', _75 => _75()]) === true;
1885
+ const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _78 => _78.isRecording, 'call', _79 => _79()]) === true;
1811
1886
  const span = reuseActive ? activeSpan : errorTracer.startSpan("OutcomeFailure");
1812
1887
  const safeOutcome = redactor({ "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
1813
1888
  const safeName = String(_nullishCoalesce(safeOutcome["autter.outcome.name"], () => ( "operation")));
@@ -1821,7 +1896,7 @@ function initAutterServer(options) {
1821
1896
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
1822
1897
  if (!reuseActive) span.end();
1823
1898
  }
1824
- _chunkUXTIMS3Gcjs.configureRuntimeLogger.call(void 0, {
1899
+ _chunk37W7YYXOcjs.configureRuntimeLogger.call(void 0, {
1825
1900
  endpoint,
1826
1901
  apiKey: options.apiKey,
1827
1902
  service: options.service,
@@ -1833,7 +1908,7 @@ function initAutterServer(options) {
1833
1908
  run: (name, fn, attributes, links) => runWithSpan(processTracer, name, fn, redactor(attributes), links),
1834
1909
  reportOutcome: reportOutcome2
1835
1910
  });
1836
- S.hookRequests = _optionalChain([options, 'access', _76 => _76.logging, 'optionalAccess', _77 => _77.requests]) === true;
1911
+ S.hookRequests = _optionalChain([options, 'access', _80 => _80.logging, 'optionalAccess', _81 => _81.requests]) === true;
1837
1912
  let onCrash = null;
1838
1913
  let uninstallRejections = null;
1839
1914
  if (options.captureGlobalErrors !== false) {
@@ -1853,7 +1928,7 @@ function initAutterServer(options) {
1853
1928
  const flushTarget = {
1854
1929
  forceFlush: async () => {
1855
1930
  const results = await Promise.allSettled([
1856
- _chunkUXTIMS3Gcjs.flushRuntimeLogs.call(void 0, ),
1931
+ _chunk37W7YYXOcjs.flushRuntimeLogs.call(void 0, ),
1857
1932
  Promise.resolve().then(() => alwaysOnProvider.forceFlush()),
1858
1933
  Promise.resolve().then(() => mainSpanProcessor.forceFlush()),
1859
1934
  ...errorTraceBuffer ? [Promise.resolve().then(() => errorTraceBuffer.forceFlush())] : [],
@@ -1867,10 +1942,10 @@ function initAutterServer(options) {
1867
1942
  }
1868
1943
  }
1869
1944
  };
1870
- _chunk4MVWIRBIcjs.registerFlushTarget.call(void 0, "active-server", flushTarget);
1945
+ _chunkMOZOUEMAcjs.registerFlushTarget.call(void 0, "active-server", flushTarget);
1871
1946
  let autoFlushHandle = null;
1872
1947
  if (options.autoFlush !== false) {
1873
- autoFlushHandle = _chunk4MVWIRBIcjs.installAutterAutoFlush.call(void 0, );
1948
+ autoFlushHandle = _chunkMOZOUEMAcjs.installAutterAutoFlush.call(void 0, );
1874
1949
  }
1875
1950
  const server = {
1876
1951
  captureException: captureException2,
@@ -1880,22 +1955,22 @@ function initAutterServer(options) {
1880
1955
  withLlmCall: (info, fn) => runLlmSpan(llmTracer, info, fn),
1881
1956
  trackLlmCall: (call) => recordLlmCall(llmTracer, call),
1882
1957
  shutdown: async () => {
1883
- const logShutdown = await Promise.allSettled([_chunkUXTIMS3Gcjs.shutdownRuntimeLogger.call(void 0, )]);
1958
+ const logShutdown = await Promise.allSettled([_chunk37W7YYXOcjs.shutdownRuntimeLogger.call(void 0, )]);
1884
1959
  if (onCrash) process.off("uncaughtExceptionMonitor", onCrash);
1885
- _optionalChain([uninstallRejections, 'optionalCall', _78 => _78()]);
1886
- _optionalChain([stopMemoryMetrics, 'optionalCall', _79 => _79()]);
1960
+ _optionalChain([uninstallRejections, 'optionalCall', _82 => _82()]);
1961
+ _optionalChain([stopMemoryMetrics, 'optionalCall', _83 => _83()]);
1887
1962
  if (S.active === server) {
1888
1963
  S.active = null;
1889
1964
  S.alwaysOnProvider = null;
1890
1965
  S.hookRequests = false;
1891
- S.redactor = _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, true);
1966
+ S.redactor = _chunk37W7YYXOcjs.makeRedactor.call(void 0, true);
1892
1967
  }
1893
- _optionalChain([autoFlushHandle, 'optionalAccess', _80 => _80.dispose, 'call', _81 => _81()]);
1968
+ _optionalChain([autoFlushHandle, 'optionalAccess', _84 => _84.dispose, 'call', _85 => _85()]);
1894
1969
  autoFlushHandle = null;
1895
- _chunk4MVWIRBIcjs.unregisterFlushTargets.call(void 0, );
1896
- _chunk4MVWIRBIcjs.telemetryStats.markAllFlushed();
1970
+ _chunkMOZOUEMAcjs.unregisterFlushTargets.call(void 0, );
1971
+ _chunkMOZOUEMAcjs.telemetryStats.markAllFlushed();
1897
1972
  await Promise.allSettled([alwaysOnProvider.shutdown(), sdk.shutdown()]);
1898
- if (_optionalChain([logShutdown, 'access', _82 => _82[0], 'optionalAccess', _83 => _83.status]) === "rejected") throw logShutdown[0].reason;
1973
+ if (_optionalChain([logShutdown, 'access', _86 => _86[0], 'optionalAccess', _87 => _87.status]) === "rejected") throw logShutdown[0].reason;
1899
1974
  }
1900
1975
  };
1901
1976
  S.active = server;
@@ -1912,11 +1987,11 @@ function captureException(error, attributes) {
1912
1987
  return;
1913
1988
  }
1914
1989
  markCaptured(error);
1915
- _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error);
1916
- const split = _chunkUXTIMS3Gcjs.splitFingerprint.call(void 0, attributes);
1917
- const fingerprint = _chunkUXTIMS3Gcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, S.redactor.text);
1918
- _chunkUXTIMS3Gcjs.notifyException.call(void 0, error, { ...split.attributes, ...fingerprint });
1919
- const span = _api.trace.getTracer("autter-errors").startSpan(_chunkUXTIMS3Gcjs.isError.call(void 0, error) ? error.name : "Error", {
1990
+ _chunk37W7YYXOcjs.noteOperationError.call(void 0, error);
1991
+ const split = _chunk37W7YYXOcjs.splitFingerprint.call(void 0, attributes);
1992
+ const fingerprint = _chunk37W7YYXOcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, S.redactor.text);
1993
+ _chunk37W7YYXOcjs.notifyException.call(void 0, error, { ...split.attributes, ...fingerprint });
1994
+ const span = _api.trace.getTracer("autter-errors").startSpan(_chunk37W7YYXOcjs.isError.call(void 0, error) ? error.name : "Error", {
1920
1995
  attributes: { ...S.redactor(split.attributes), ...fingerprint }
1921
1996
  });
1922
1997
  recordError(span, error);
@@ -1931,7 +2006,7 @@ function serverActive() {
1931
2006
  setRequestExceptionCapturer((error, attributes) => captureException(error, attributes));
1932
2007
  setRequestSpanAnnotator((attributes) => {
1933
2008
  const span = _api.trace.getActiveSpan();
1934
- if (_optionalChain([span, 'optionalAccess', _84 => _84.isRecording, 'call', _85 => _85()])) span.setAttributes(S.redactor(_chunkUXTIMS3Gcjs.splitFingerprint.call(void 0, attributes).attributes));
2009
+ if (_optionalChain([span, 'optionalAccess', _88 => _88.isRecording, 'call', _89 => _89()])) span.setAttributes(S.redactor(_chunk37W7YYXOcjs.splitFingerprint.call(void 0, attributes).attributes));
1935
2010
  });
1936
2011
  function withProcessSpan(name, fn, attributes) {
1937
2012
  if (S.active) return S.active.withProcessSpan(name, fn, attributes);
@@ -1966,7 +2041,7 @@ function captureMessage(message, severity = "warning", attributes) {
1966
2041
  "exception.type": "Message",
1967
2042
  "exception.message": safeMessage,
1968
2043
  "autter.severity": severity,
1969
- ..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text)
2044
+ ..._chunk37W7YYXOcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text)
1970
2045
  });
1971
2046
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
1972
2047
  span.end();
@@ -1974,11 +2049,11 @@ function captureMessage(message, severity = "warning", attributes) {
1974
2049
  function reportOutcome(name, message, attributes) {
1975
2050
  if (S.active) return S.active.reportOutcome(name, message, attributes);
1976
2051
  const span = _api.trace.getTracer("autter-outcomes").startSpan("OutcomeFailure");
1977
- const safeOutcome = _chunkUXTIMS3Gcjs.redactAttributes.call(void 0, { "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
2052
+ const safeOutcome = _chunk37W7YYXOcjs.redactAttributes.call(void 0, { "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
1978
2053
  const safeName = String(_nullishCoalesce(safeOutcome["autter.outcome.name"], () => ( "operation")));
1979
2054
  const safeMessage = String(_nullishCoalesce(safeOutcome["autter.outcome.message"], () => ( "failed")));
1980
2055
  span.addEvent("autter.outcome", {
1981
- ..._chunkUXTIMS3Gcjs.redactAttributes.call(void 0, attributes),
2056
+ ..._chunk37W7YYXOcjs.redactAttributes.call(void 0, attributes),
1982
2057
  "autter.outcome.status": "error",
1983
2058
  "autter.outcome.name": safeName,
1984
2059
  "autter.outcome.message": safeMessage
@@ -1987,7 +2062,7 @@ function reportOutcome(name, message, attributes) {
1987
2062
  span.end();
1988
2063
  }
1989
2064
  function makeSafeCapture(options) {
1990
- const clean = (attributes) => attributes ? { ..._chunkUXTIMS3Gcjs.redactAttributes.call(void 0, attributes, options) } : void 0;
2065
+ const clean = (attributes) => attributes ? { ..._chunk37W7YYXOcjs.redactAttributes.call(void 0, attributes, options) } : void 0;
1991
2066
  return {
1992
2067
  captureException: (error, attributes) => captureException(error, clean(attributes)),
1993
2068
  captureMessage: (message, severity, attributes) => captureMessage(message, _nullishCoalesce(severity, () => ( "warning")), clean(attributes))
@@ -2014,7 +2089,7 @@ async function emitLlmSelftestTrace() {
2014
2089
  attributes: { "autter.selftest": true }
2015
2090
  },
2016
2091
  (llm) => {
2017
- traceId = _nullishCoalesce(_optionalChain([_api.trace, 'access', _86 => _86.getActiveSpan, 'call', _87 => _87(), 'optionalAccess', _88 => _88.spanContext, 'call', _89 => _89(), 'access', _90 => _90.traceId]), () => ( ""));
2092
+ traceId = _nullishCoalesce(_optionalChain([_api.trace, 'access', _90 => _90.getActiveSpan, 'call', _91 => _91(), 'optionalAccess', _92 => _92.spanContext, 'call', _93 => _93(), 'access', _94 => _94.traceId]), () => ( ""));
2018
2093
  llm.setUsage({ inputTokens: 1, outputTokens: 1 });
2019
2094
  llm.setCost(0);
2020
2095
  }
@@ -2042,7 +2117,7 @@ var CALL_METHODS = /* @__PURE__ */ new Set([
2042
2117
  // openai beta structured outputs
2043
2118
  ]);
2044
2119
  function detectProvider(client) {
2045
- const name = _nullishCoalesce(_optionalChain([client, 'access', _91 => _91.constructor, 'optionalAccess', _92 => _92.name, 'optionalAccess', _93 => _93.toLowerCase, 'call', _94 => _94()]), () => ( ""));
2120
+ const name = _nullishCoalesce(_optionalChain([client, 'access', _95 => _95.constructor, 'optionalAccess', _96 => _96.name, 'optionalAccess', _97 => _97.toLowerCase, 'call', _98 => _98()]), () => ( ""));
2046
2121
  for (const known of ["openai", "anthropic", "mistral", "groq", "cohere"]) {
2047
2122
  if (name.includes(known)) return known;
2048
2123
  }
@@ -2050,7 +2125,7 @@ function detectProvider(client) {
2050
2125
  const baseUrl = String(
2051
2126
  _nullishCoalesce(_nullishCoalesce(client.baseURL, () => ( client.baseUrl)), () => ( ""))
2052
2127
  );
2053
- const host = _nullishCoalesce(_optionalChain([baseUrl, 'access', _95 => _95.match, 'call', _96 => _96(/https?:\/\/([^/]+)/), 'optionalAccess', _97 => _97[1]]), () => ( ""));
2128
+ const host = _nullishCoalesce(_optionalChain([baseUrl, 'access', _99 => _99.match, 'call', _100 => _100(/https?:\/\/([^/]+)/), 'optionalAccess', _101 => _101[1]]), () => ( ""));
2054
2129
  if (host.includes("openai")) return "openai";
2055
2130
  if (host.includes("anthropic")) return "anthropic";
2056
2131
  if (host.includes("googleapis")) return "google";
@@ -2060,13 +2135,13 @@ function detectProvider(client) {
2060
2135
  }
2061
2136
  function extractUsage(result) {
2062
2137
  const r = result;
2063
- const usage = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _98 => _98.usage]), () => ( _optionalChain([r, 'optionalAccess', _99 => _99.message, 'optionalAccess', _100 => _100.usage])));
2064
- const meta = _optionalChain([r, 'optionalAccess', _101 => _101.usageMetadata]);
2065
- const details = _optionalChain([usage, 'optionalAccess', _102 => _102.prompt_tokens_details]);
2066
- const cached = _nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _103 => _103.cache_read_input_tokens]), () => ( (typeof _optionalChain([details, 'optionalAccess', _104 => _104.cached_tokens]) === "number" ? details.cached_tokens : void 0))), () => ( _optionalChain([meta, 'optionalAccess', _105 => _105.cachedContentTokenCount])));
2067
- const input = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _106 => _106.prompt_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _107 => _107.input_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _108 => _108.promptTokenCount]))), () => ( void 0));
2068
- const output = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _109 => _109.completion_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _110 => _110.output_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _111 => _111.candidatesTokenCount]))), () => ( void 0));
2069
- const responseModel = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _112 => _112.model]), () => ( _optionalChain([r, 'optionalAccess', _113 => _113.modelVersion])));
2138
+ const usage = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _102 => _102.usage]), () => ( _optionalChain([r, 'optionalAccess', _103 => _103.message, 'optionalAccess', _104 => _104.usage])));
2139
+ const meta = _optionalChain([r, 'optionalAccess', _105 => _105.usageMetadata]);
2140
+ const details = _optionalChain([usage, 'optionalAccess', _106 => _106.prompt_tokens_details]);
2141
+ const cached = _nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _107 => _107.cache_read_input_tokens]), () => ( (typeof _optionalChain([details, 'optionalAccess', _108 => _108.cached_tokens]) === "number" ? details.cached_tokens : void 0))), () => ( _optionalChain([meta, 'optionalAccess', _109 => _109.cachedContentTokenCount])));
2142
+ const input = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _110 => _110.prompt_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _111 => _111.input_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _112 => _112.promptTokenCount]))), () => ( void 0));
2143
+ const output = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _113 => _113.completion_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _114 => _114.output_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _115 => _115.candidatesTokenCount]))), () => ( void 0));
2144
+ const responseModel = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _116 => _116.model]), () => ( _optionalChain([r, 'optionalAccess', _117 => _117.modelVersion])));
2070
2145
  return {
2071
2146
  inputTokens: typeof input === "number" ? input : void 0,
2072
2147
  outputTokens: typeof output === "number" ? output : void 0,
@@ -2075,7 +2150,7 @@ function extractUsage(result) {
2075
2150
  };
2076
2151
  }
2077
2152
  function rollUp(model, usage) {
2078
- _chunkUXTIMS3Gcjs.recordOperationAiUsage.call(void 0, {
2153
+ _chunk37W7YYXOcjs.recordOperationAiUsage.call(void 0, {
2079
2154
  model: _nullishCoalesce(usage.responseModel, () => ( model)),
2080
2155
  ...usage.inputTokens !== void 0 ? { inputTokens: usage.inputTokens } : {},
2081
2156
  ...usage.outputTokens !== void 0 ? { outputTokens: usage.outputTokens } : {},
@@ -2159,10 +2234,10 @@ function wrapStream(stream, span, model) {
2159
2234
  });
2160
2235
  }
2161
2236
  function instrumentLlmClient(client, options) {
2162
- const provider = (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _114 => _114.provider]), () => ( detectProvider(client)))).toLowerCase();
2237
+ const provider = (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _118 => _118.provider]), () => ( detectProvider(client)))).toLowerCase();
2163
2238
  const proxied = /* @__PURE__ */ new WeakMap();
2164
2239
  function resolveUserId() {
2165
- return typeof _optionalChain([options, 'optionalAccess', _115 => _115.userId]) === "function" ? options.userId() : _optionalChain([options, 'optionalAccess', _116 => _116.userId]);
2240
+ return typeof _optionalChain([options, 'optionalAccess', _119 => _119.userId]) === "function" ? options.userId() : _optionalChain([options, 'optionalAccess', _120 => _120.userId]);
2166
2241
  }
2167
2242
  function traceCall(fn, self, callPath, args) {
2168
2243
  const request = args[0];
@@ -2176,7 +2251,7 @@ function instrumentLlmClient(client, options) {
2176
2251
  "gen_ai.system": provider,
2177
2252
  "gen_ai.request.model": request.model,
2178
2253
  ...userId ? { "autter.user_id": userId } : {},
2179
- ...redactWithActive(_optionalChain([options, 'optionalAccess', _117 => _117.attributes]))
2254
+ ...redactWithActive(_optionalChain([options, 'optionalAccess', _121 => _121.attributes]))
2180
2255
  }
2181
2256
  });
2182
2257
  let result;
@@ -2300,9 +2375,9 @@ ${frames.join("\n")}`;
2300
2375
  function recordBoundaryError(error, req, rule) {
2301
2376
  try {
2302
2377
  const state = requestStateOf(req);
2303
- if (state) _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error, false, state);
2378
+ if (state) _chunk37W7YYXOcjs.noteOperationError.call(void 0, error, false, state);
2304
2379
  captureAtBoundary(error, state, rule);
2305
- } catch (e30) {
2380
+ } catch (e32) {
2306
2381
  }
2307
2382
  }
2308
2383
  function autterErrorHandler(options = {}) {
@@ -2312,12 +2387,12 @@ function autterErrorHandler(options = {}) {
2312
2387
  };
2313
2388
  }
2314
2389
  function autterFastifyErrors(fastify, options, done) {
2315
- const rule = _optionalChain([options, 'optionalAccess', _118 => _118.capture]);
2390
+ const rule = _optionalChain([options, 'optionalAccess', _122 => _122.capture]);
2316
2391
  fastify.addHook("onError", ((request, _reply, error, next) => {
2317
- recordBoundaryError(error, _optionalChain([request, 'optionalAccess', _119 => _119.raw]), rule);
2392
+ recordBoundaryError(error, _optionalChain([request, 'optionalAccess', _123 => _123.raw]), rule);
2318
2393
  next();
2319
2394
  }));
2320
- _optionalChain([done, 'optionalCall', _120 => _120()]);
2395
+ _optionalChain([done, 'optionalCall', _124 => _124()]);
2321
2396
  }
2322
2397
  autterFastifyErrors[/* @__PURE__ */ Symbol.for("skip-override")] = true;
2323
2398
  autterFastifyErrors[/* @__PURE__ */ Symbol.for("fastify.display-name")] = "autter-runtime-errors";
@@ -2326,7 +2401,7 @@ function autterKoa(options = {}) {
2326
2401
  try {
2327
2402
  await next();
2328
2403
  } catch (error) {
2329
- recordBoundaryError(error, _optionalChain([ctx, 'optionalAccess', _121 => _121.req]), options.capture);
2404
+ recordBoundaryError(error, _optionalChain([ctx, 'optionalAccess', _125 => _125.req]), options.capture);
2330
2405
  throw error;
2331
2406
  }
2332
2407
  };
@@ -2337,7 +2412,7 @@ function autterKoa(options = {}) {
2337
2412
 
2338
2413
 
2339
2414
 
2340
- var L = _chunk4MVWIRBIcjs.sharedSlot.call(void 0, "logging", () => ({ active: null }));
2415
+ var L = _chunkMOZOUEMAcjs.sharedSlot.call(void 0, "logging", () => ({ active: null }));
2341
2416
  function initAutterLogging(options) {
2342
2417
  if (L.active) return L.active;
2343
2418
  if (serverActive()) {
@@ -2346,29 +2421,37 @@ function initAutterLogging(options) {
2346
2421
  );
2347
2422
  return {
2348
2423
  captureException,
2349
- flush: _chunkUXTIMS3Gcjs.flushRuntimeLogs,
2424
+ flush: _chunk37W7YYXOcjs.flushRuntimeLogs,
2350
2425
  shutdown: async () => {
2351
2426
  }
2352
2427
  };
2353
2428
  }
2354
- if (_chunk4MVWIRBIcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunk4MVWIRBIcjs.setDebugMode.call(void 0, true);
2429
+ if (_chunkMOZOUEMAcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunkMOZOUEMAcjs.setDebugMode.call(void 0, true);
2355
2430
  const endpoint = (_nullishCoalesce(options.endpoint, () => ( "https://otlp.autter.dev"))).replace(/\/$/, "");
2356
2431
  const environment = _nullishCoalesce(_nullishCoalesce(options.environment, () => ( process.env.NODE_ENV)), () => ( "production"));
2357
- const redact = _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
2432
+ const redact = _chunk37W7YYXOcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
2358
2433
  const mode = _nullishCoalesce(options.exceptions, () => ( "auto"));
2359
- _chunk4MVWIRBIcjs.debugLog.call(void 0, `initialising logger-only service=${options.service} endpoint=${endpoint}`);
2434
+ _chunkMOZOUEMAcjs.debugLog.call(void 0, `initialising logger-only service=${options.service} endpoint=${endpoint}`);
2435
+ const errorFilter = _chunk37W7YYXOcjs.createErrorFilter.call(void 0, { ignoreErrors: options.ignoreErrors, sampleRate: options.sampleRate });
2360
2436
  function captureException2(error, attributes) {
2361
2437
  markCaptured(error);
2362
- const split = _chunkUXTIMS3Gcjs.splitFingerprint.call(void 0, attributes);
2363
- const fingerprint = _chunkUXTIMS3Gcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redact.text);
2438
+ const isErrValue = _chunk37W7YYXOcjs.isError.call(void 0, error);
2439
+ const reported = errorFilter({
2440
+ type: isErrValue ? String(_nullishCoalesce(error.name, () => ( ""))) : "Error",
2441
+ message: isErrValue ? String(_nullishCoalesce(error.message, () => ( ""))) : String(error),
2442
+ crash: _optionalChain([attributes, 'optionalAccess', _126 => _126["autter.unhandled"]]) === true || _optionalChain([attributes, 'optionalAccess', _127 => _127["autter.unhandled_rejection"]]) === true
2443
+ });
2444
+ if (!reported) return;
2445
+ const split = _chunk37W7YYXOcjs.splitFingerprint.call(void 0, attributes);
2446
+ const fingerprint = _chunk37W7YYXOcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redact.text);
2364
2447
  const redacted = redact(split.attributes);
2365
2448
  const span = _api.trace.getActiveSpan();
2366
- if (mode === "auto" && _optionalChain([span, 'optionalAccess', _122 => _122.isRecording, 'call', _123 => _123()])) {
2367
- _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error);
2368
- _chunkUXTIMS3Gcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
2449
+ if (mode === "auto" && _optionalChain([span, 'optionalAccess', _128 => _128.isRecording, 'call', _129 => _129()])) {
2450
+ _chunk37W7YYXOcjs.noteOperationError.call(void 0, error);
2451
+ _chunk37W7YYXOcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
2369
2452
  span.setAttributes({ "autter.severity": "error", ...redacted, ...structuredErrorAttributes(error) });
2370
- const declared = { ..._chunkUXTIMS3Gcjs.errorAttributes.call(void 0, error), ...fingerprint };
2371
- if (_chunkUXTIMS3Gcjs.isError.call(void 0, error)) {
2453
+ const declared = { ..._chunk37W7YYXOcjs.errorAttributes.call(void 0, error), ...fingerprint };
2454
+ if (_chunk37W7YYXOcjs.isError.call(void 0, error)) {
2372
2455
  span.addEvent("exception", {
2373
2456
  "exception.type": error.name,
2374
2457
  "exception.message": error.message,
@@ -2384,15 +2467,15 @@ function initAutterLogging(options) {
2384
2467
  }
2385
2468
  span.setStatus({
2386
2469
  code: _api.SpanStatusCode.ERROR,
2387
- message: _chunkUXTIMS3Gcjs.isError.call(void 0, error) ? error.message : String(error)
2470
+ message: _chunk37W7YYXOcjs.isError.call(void 0, error) ? error.message : String(error)
2388
2471
  });
2389
2472
  return;
2390
2473
  }
2391
- _chunkUXTIMS3Gcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
2392
- _chunkUXTIMS3Gcjs.captureExceptionAsLog.call(void 0, error, { ...redacted, ...fingerprint });
2474
+ _chunk37W7YYXOcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
2475
+ _chunk37W7YYXOcjs.captureExceptionAsLog.call(void 0, error, { ...redacted, ...fingerprint });
2393
2476
  }
2394
2477
  const captured = /* @__PURE__ */ new WeakSet();
2395
- _chunkUXTIMS3Gcjs.configureRuntimeLogger.call(void 0, {
2478
+ _chunk37W7YYXOcjs.configureRuntimeLogger.call(void 0, {
2396
2479
  endpoint,
2397
2480
  apiKey: _nullishCoalesce(options.apiKey, () => ( "")),
2398
2481
  service: options.service,
@@ -2401,7 +2484,7 @@ function initAutterLogging(options) {
2401
2484
  ...options.logging ? { options: options.logging } : {},
2402
2485
  redact,
2403
2486
  reportOutcome: (name, message, attributes) => {
2404
- _chunkUXTIMS3Gcjs.runtimeLogger.error(message, {
2487
+ _chunk37W7YYXOcjs.runtimeLogger.error(message, {
2405
2488
  ...attributes,
2406
2489
  "autter.outcome.name": name.slice(0, 200),
2407
2490
  "autter.outcome.message": message.slice(0, 1e3)
@@ -2428,21 +2511,21 @@ function initAutterLogging(options) {
2428
2511
  (reason) => captureException2(reason, { "autter.unhandled_rejection": true })
2429
2512
  );
2430
2513
  }
2431
- _chunk4MVWIRBIcjs.registerFlushTarget.call(void 0, "logging", { forceFlush: () => _chunkUXTIMS3Gcjs.flushRuntimeLogs.call(void 0, ) });
2432
- let autoFlushHandle = options.autoFlush === false ? null : _chunk4MVWIRBIcjs.installAutterAutoFlush.call(void 0, );
2514
+ _chunkMOZOUEMAcjs.registerFlushTarget.call(void 0, "logging", { forceFlush: () => _chunk37W7YYXOcjs.flushRuntimeLogs.call(void 0, ) });
2515
+ let autoFlushHandle = options.autoFlush === false ? null : _chunkMOZOUEMAcjs.installAutterAutoFlush.call(void 0, );
2433
2516
  const handle = {
2434
2517
  captureException: captureException2,
2435
- flush: _chunkUXTIMS3Gcjs.flushRuntimeLogs,
2518
+ flush: _chunk37W7YYXOcjs.flushRuntimeLogs,
2436
2519
  shutdown: async () => {
2437
2520
  process.off("uncaughtExceptionMonitor", onCrash);
2438
- _optionalChain([uninstallRejections, 'optionalCall', _124 => _124()]);
2521
+ _optionalChain([uninstallRejections, 'optionalCall', _130 => _130()]);
2439
2522
  uninstallRejections = null;
2440
2523
  setLoggerOnlyCapture(null);
2441
- _optionalChain([autoFlushHandle, 'optionalAccess', _125 => _125.dispose, 'call', _126 => _126()]);
2524
+ _optionalChain([autoFlushHandle, 'optionalAccess', _131 => _131.dispose, 'call', _132 => _132()]);
2442
2525
  autoFlushHandle = null;
2443
- _chunk4MVWIRBIcjs.unregisterFlushTargets.call(void 0, );
2526
+ _chunkMOZOUEMAcjs.unregisterFlushTargets.call(void 0, );
2444
2527
  if (L.active === handle) L.active = null;
2445
- await _chunkUXTIMS3Gcjs.shutdownRuntimeLogger.call(void 0, );
2528
+ await _chunk37W7YYXOcjs.shutdownRuntimeLogger.call(void 0, );
2446
2529
  }
2447
2530
  };
2448
2531
  L.active = handle;
@@ -2451,7 +2534,7 @@ function initAutterLogging(options) {
2451
2534
 
2452
2535
  // src/enrichers.ts
2453
2536
  function headerOf(req, name) {
2454
- const headers = _optionalChain([req, 'optionalAccess', _127 => _127.headers]);
2537
+ const headers = _optionalChain([req, 'optionalAccess', _133 => _133.headers]);
2455
2538
  if (!headers) return void 0;
2456
2539
  if (typeof headers.get === "function") {
2457
2540
  return _nullishCoalesce(headers.get(name), () => ( void 0));
@@ -2464,7 +2547,7 @@ function enrichUserAgent() {
2464
2547
  return (event, { req }) => {
2465
2548
  const ua = headerOf(req, "user-agent");
2466
2549
  if (!ua) return;
2467
- const info = _chunkUXTIMS3Gcjs.parseUserAgent.call(void 0, ua);
2550
+ const info = _chunk37W7YYXOcjs.parseUserAgent.call(void 0, ua);
2468
2551
  if (info.browser) event.attributes["user_agent.browser"] = info.browser;
2469
2552
  if (info.os) event.attributes["user_agent.os"] = info.os;
2470
2553
  event.attributes["user_agent.device"] = info.device;
@@ -2476,7 +2559,7 @@ function enrichRequestSize() {
2476
2559
  const request = Number(headerOf(req, "content-length"));
2477
2560
  if (Number.isFinite(request) && request >= 0)
2478
2561
  event.attributes["http.request.body.size"] = request;
2479
- const raw = _optionalChain([res, 'optionalAccess', _128 => _128.getHeader, 'optionalCall', _129 => _129(
2562
+ const raw = _optionalChain([res, 'optionalAccess', _134 => _134.getHeader, 'optionalCall', _135 => _135(
2480
2563
  "content-length"
2481
2564
  )]);
2482
2565
  const response = Number(raw);
@@ -2494,7 +2577,7 @@ var COUNTRY_HEADERS = [
2494
2577
  function enrichEdgeGeo() {
2495
2578
  return (event, { req }) => {
2496
2579
  for (const name of COUNTRY_HEADERS) {
2497
- const value = _optionalChain([headerOf, 'call', _130 => _130(req, name), 'optionalAccess', _131 => _131.trim, 'call', _132 => _132(), 'access', _133 => _133.toUpperCase, 'call', _134 => _134()]);
2580
+ const value = _optionalChain([headerOf, 'call', _136 => _136(req, name), 'optionalAccess', _137 => _137.trim, 'call', _138 => _138(), 'access', _139 => _139.toUpperCase, 'call', _140 => _140()]);
2498
2581
  if (value && /^[A-Z]{2}$/.test(value) && value !== "XX" && value !== "T1") {
2499
2582
  event.attributes["geo.country.iso_code"] = value;
2500
2583
  return;
@@ -2528,9 +2611,9 @@ var COMMIT_VARS = [
2528
2611
  "SOURCE_VERSION"
2529
2612
  ];
2530
2613
  function enrichDeployment(env = process.env) {
2531
- const pick = (names) => names.map((name) => _optionalChain([env, 'access', _135 => _135[name], 'optionalAccess', _136 => _136.trim, 'call', _137 => _137()])).find((value) => value);
2532
- const region = _optionalChain([pick, 'call', _138 => _138(REGION_VARS), 'optionalAccess', _139 => _139.slice, 'call', _140 => _140(0, 64)]);
2533
- const commit = _optionalChain([pick, 'call', _141 => _141(COMMIT_VARS), 'optionalAccess', _142 => _142.slice, 'call', _143 => _143(0, 64)]);
2614
+ const pick = (names) => names.map((name) => _optionalChain([env, 'access', _141 => _141[name], 'optionalAccess', _142 => _142.trim, 'call', _143 => _143()])).find((value) => value);
2615
+ const region = _optionalChain([pick, 'call', _144 => _144(REGION_VARS), 'optionalAccess', _145 => _145.slice, 'call', _146 => _146(0, 64)]);
2616
+ const commit = _optionalChain([pick, 'call', _147 => _147(COMMIT_VARS), 'optionalAccess', _148 => _148.slice, 'call', _149 => _149(0, 64)]);
2534
2617
  return (event) => {
2535
2618
  if (region) event.attributes["deployment.region"] = region;
2536
2619
  if (commit) event.attributes["deployment.commit"] = commit;
@@ -2591,4 +2674,4 @@ function enrichDeployment(env = process.env) {
2591
2674
 
2592
2675
 
2593
2676
 
2594
- exports.CODE_PATTERN = _chunkUXTIMS3Gcjs.CODE_PATTERN; exports.COMPAT_MANIFEST = _chunk4MVWIRBIcjs.COMPAT_MANIFEST; exports.INGESTER_VERSION_HEADER = _chunk4MVWIRBIcjs.INGESTER_VERSION_HEADER; exports.RuntimeError = _chunkUXTIMS3Gcjs.RuntimeError; exports.SDK_IDENTITY = _chunk4MVWIRBIcjs.SDK_IDENTITY; exports.addBreadcrumb = _chunkUXTIMS3Gcjs.addBreadcrumb; exports.autterErrorHandler = autterErrorHandler; exports.autterErrorResponse = autterErrorResponse; exports.autterFastify = autterFastify; exports.autterFastifyErrors = autterFastifyErrors; exports.autterKoa = autterKoa; exports.autterRequests = autterRequests; exports.captureException = captureException; exports.captureMessage = captureMessage; exports.captureRequestError = captureRequestError; exports.consoleSink = _chunkUXTIMS3Gcjs.consoleSink; exports.createBrowserRelayFetchHandler = createBrowserRelayFetchHandler; exports.createBrowserRelayHandler = createBrowserRelayHandler; exports.createRuntimeLogger = _chunkUXTIMS3Gcjs.createRuntimeLogger; exports.defineRuntimeErrors = _chunkUXTIMS3Gcjs.defineRuntimeErrors; exports.emitLlmSelftestTrace = emitLlmSelftestTrace; exports.enrichDeployment = enrichDeployment; exports.enrichEdgeGeo = enrichEdgeGeo; exports.enrichRequestSize = enrichRequestSize; exports.enrichUserAgent = enrichUserAgent; exports.errorAttributes = _chunkUXTIMS3Gcjs.errorAttributes; exports.evaluateCompat = _chunk4MVWIRBIcjs.evaluateCompat; exports.fetchIngesterCompat = _chunk4MVWIRBIcjs.fetchIngesterCompat; exports.fileSink = _chunkUXTIMS3Gcjs.fileSink; exports.flushRuntimeLogs = _chunkUXTIMS3Gcjs.flushRuntimeLogs; exports.initAutterLogging = initAutterLogging; exports.initAutterServer = initAutterServer; exports.installAutterAutoFlush = _chunk4MVWIRBIcjs.installAutterAutoFlush; exports.instrumentLlmClient = instrumentLlmClient; exports.isRuntimeErrorLike = _chunkUXTIMS3Gcjs.isRuntimeErrorLike; exports.makeSafeCapture = makeSafeCapture; exports.otlpSink = _chunkUXTIMS3Gcjs.otlpSink; exports.redactAttributes = _chunkUXTIMS3Gcjs.redactAttributes; exports.redactText = _chunkUXTIMS3Gcjs.redactText; exports.reportOutcome = reportOutcome; exports.runDoctor = _chunk7OTD2YPTcjs.runDoctor; exports.runInBackground = _chunkUXTIMS3Gcjs.runInBackground; exports.runtimeContext = _chunkUXTIMS3Gcjs.runtimeContext; exports.runtimeLogStats = _chunkUXTIMS3Gcjs.runtimeLogStats; exports.runtimeLogger = _chunkUXTIMS3Gcjs.runtimeLogger; exports.sanitizeBrowserPayload = sanitizeBrowserPayload; exports.startCaughtExceptionSampler = startCaughtExceptionSampler; exports.toClientError = _chunkUXTIMS3Gcjs.toClientError; exports.trackLlmCall = trackLlmCall; exports.unhandledRejectionsMode = unhandledRejectionsMode; exports.withLlmCall = withLlmCall; exports.withProcessSpan = withProcessSpan; exports.withRuntimeOperation = _chunkUXTIMS3Gcjs.withRuntimeOperation; exports.withRuntimeRequest = withRuntimeRequest;
2677
+ exports.CODE_PATTERN = _chunk37W7YYXOcjs.CODE_PATTERN; exports.COMPAT_MANIFEST = _chunkMOZOUEMAcjs.COMPAT_MANIFEST; exports.INGESTER_VERSION_HEADER = _chunkMOZOUEMAcjs.INGESTER_VERSION_HEADER; exports.RuntimeError = _chunk37W7YYXOcjs.RuntimeError; exports.SDK_IDENTITY = _chunkMOZOUEMAcjs.SDK_IDENTITY; exports.addBreadcrumb = _chunk37W7YYXOcjs.addBreadcrumb; exports.autterErrorHandler = autterErrorHandler; exports.autterErrorResponse = autterErrorResponse; exports.autterFastify = autterFastify; exports.autterFastifyErrors = autterFastifyErrors; exports.autterKoa = autterKoa; exports.autterRequests = autterRequests; exports.captureException = captureException; exports.captureMessage = captureMessage; exports.captureRequestError = captureRequestError; exports.consoleSink = _chunk37W7YYXOcjs.consoleSink; exports.createBrowserRelayFetchHandler = createBrowserRelayFetchHandler; exports.createBrowserRelayHandler = createBrowserRelayHandler; exports.createRuntimeLogger = _chunk37W7YYXOcjs.createRuntimeLogger; exports.defineRuntimeErrors = _chunk37W7YYXOcjs.defineRuntimeErrors; exports.emitLlmSelftestTrace = emitLlmSelftestTrace; exports.enrichDeployment = enrichDeployment; exports.enrichEdgeGeo = enrichEdgeGeo; exports.enrichRequestSize = enrichRequestSize; exports.enrichUserAgent = enrichUserAgent; exports.errorAttributes = _chunk37W7YYXOcjs.errorAttributes; exports.evaluateCompat = _chunkMOZOUEMAcjs.evaluateCompat; exports.fetchIngesterCompat = _chunkMOZOUEMAcjs.fetchIngesterCompat; exports.fileSink = _chunk37W7YYXOcjs.fileSink; exports.flushRuntimeLogs = _chunk37W7YYXOcjs.flushRuntimeLogs; exports.initAutterLogging = initAutterLogging; exports.initAutterServer = initAutterServer; exports.installAutterAutoFlush = _chunkMOZOUEMAcjs.installAutterAutoFlush; exports.instrumentLlmClient = instrumentLlmClient; exports.isRuntimeErrorLike = _chunk37W7YYXOcjs.isRuntimeErrorLike; exports.makeSafeCapture = makeSafeCapture; exports.otlpSink = _chunk37W7YYXOcjs.otlpSink; exports.redactAttributes = _chunk37W7YYXOcjs.redactAttributes; exports.redactText = _chunk37W7YYXOcjs.redactText; exports.reportOutcome = reportOutcome; exports.runDoctor = _chunk7H3FCV4Pcjs.runDoctor; exports.runInBackground = _chunk37W7YYXOcjs.runInBackground; exports.runtimeContext = _chunk37W7YYXOcjs.runtimeContext; exports.runtimeLogStats = _chunk37W7YYXOcjs.runtimeLogStats; exports.runtimeLogger = _chunk37W7YYXOcjs.runtimeLogger; exports.sanitizeBrowserPayload = sanitizeBrowserPayload; exports.startCaughtExceptionSampler = startCaughtExceptionSampler; exports.toClientError = _chunk37W7YYXOcjs.toClientError; exports.trackLlmCall = trackLlmCall; exports.unhandledRejectionsMode = unhandledRejectionsMode; exports.withLlmCall = withLlmCall; exports.withProcessSpan = withProcessSpan; exports.withRuntimeOperation = _chunk37W7YYXOcjs.withRuntimeOperation; exports.withRuntimeRequest = withRuntimeRequest;