@autter/runtime-node 1.7.0 → 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 _chunkRV4MJNM2cjs = require('./chunk-RV4MJNM2.cjs');
49
48
 
49
+ var _chunk37W7YYXOcjs = require('./chunk-37W7YYXO.cjs');
50
50
 
51
- var _chunkHKVFURYTcjs = require('./chunk-HKVFURYT.cjs');
52
51
 
52
+ var _chunk7H3FCV4Pcjs = require('./chunk-7H3FCV4P.cjs');
53
53
 
54
54
 
55
55
 
@@ -70,7 +70,8 @@ var _chunkHKVFURYTcjs = require('./chunk-HKVFURYT.cjs');
70
70
 
71
71
 
72
72
 
73
- var _chunkGYTQLITWcjs = require('./chunk-GYTQLITW.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 = _chunkRV4MJNM2cjs.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 = _chunkRV4MJNM2cjs.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 = _chunkRV4MJNM2cjs.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) _chunkGYTQLITWcjs.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
- _chunkGYTQLITWcjs.observeIngesterResponse.call(void 0, { status: response.status, headers: response.headers });
311
- for (const feature of _chunkGYTQLITWcjs.featuresForBrowserEvents.call(void 0, types)) _chunkGYTQLITWcjs.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
- _chunkGYTQLITWcjs.noteCompatFeature.call(void 0, "browser_trace_propagation");
314
+ _chunkMOZOUEMAcjs.noteCompatFeature.call(void 0, "browser_trace_propagation");
314
315
  }
315
- _chunkGYTQLITWcjs.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 : _chunkRV4MJNM2cjs.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 : _chunkRV4MJNM2cjs.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;
@@ -745,7 +746,7 @@ var _async_hooks = require('async_hooks');
745
746
 
746
747
  var REQUEST_STATE = /* @__PURE__ */ Symbol.for("autter.runtime.request");
747
748
  var BOUND = /* @__PURE__ */ Symbol.for("autter.runtime.bound");
748
- var CAPTURED = _chunkGYTQLITWcjs.sharedSlot.call(void 0, "requests", () => ({ captured: /* @__PURE__ */ new WeakSet() })).captured;
749
+ var CAPTURED = _chunkMOZOUEMAcjs.sharedSlot.call(void 0, "requests", () => ({ captured: /* @__PURE__ */ new WeakSet() })).captured;
749
750
  var capturer = () => {
750
751
  };
751
752
  function setRequestExceptionCapturer(fn) {
@@ -768,7 +769,7 @@ function expressRouteOf(req) {
768
769
  return route.startsWith("/") ? route : null;
769
770
  }
770
771
  function defaultShouldCapture(error) {
771
- return error instanceof _chunkRV4MJNM2cjs.RuntimeError || _chunkRV4MJNM2cjs.errorCodeOf.call(void 0, error) !== void 0 || _chunkRV4MJNM2cjs.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;
772
773
  }
773
774
  function onRequestSpan(fn) {
774
775
  const active = _api.context.active();
@@ -792,7 +793,7 @@ function captureAtBoundary(error, state, rule = void 0, attributes) {
792
793
  markCaptured(error);
793
794
  try {
794
795
  const run = () => onRequestSpan(() => capturer(error, attributes));
795
- if (state && !state.sealed) _chunkRV4MJNM2cjs.local.run(state, run);
796
+ if (state && !state.sealed) _chunk37W7YYXOcjs.local.run(state, run);
796
797
  else run();
797
798
  } catch (e15) {
798
799
  }
@@ -810,7 +811,7 @@ function captureRequestError(error, attributes) {
810
811
  }
811
812
  return;
812
813
  }
813
- captureAtBoundary(error, _chunkRV4MJNM2cjs.currentOperation.call(void 0, ), true, attributes);
814
+ captureAtBoundary(error, _chunk37W7YYXOcjs.currentOperation.call(void 0, ), true, attributes);
814
815
  }
815
816
  function bindEmitter(emitter, state) {
816
817
  const target = emitter;
@@ -822,7 +823,7 @@ function bindEmitter(emitter, state) {
822
823
  let wrapped = wrappers.get(listener);
823
824
  if (!wrapped) {
824
825
  wrapped = function(...args) {
825
- return _chunkRV4MJNM2cjs.local.run(
826
+ return _chunk37W7YYXOcjs.local.run(
826
827
  state,
827
828
  () => listener.apply(this, args)
828
829
  );
@@ -889,7 +890,7 @@ function pathOf(req) {
889
890
  function finishRequest(state, input) {
890
891
  if (state.sealed) return;
891
892
  state.name = (_nullishCoalesce(input.name, () => ( `${input.method} ${input.route}`))).slice(0, 200);
892
- state.outcome = _chunkRV4MJNM2cjs.requestOutcome.call(void 0, {
893
+ state.outcome = _chunk37W7YYXOcjs.requestOutcome.call(void 0, {
893
894
  ...state.explicitOutcome ? { explicit: state.outcome } : {},
894
895
  ...state.error !== void 0 ? { error: state.error } : {},
895
896
  ...state.errorThrown ? { thrown: true } : {},
@@ -902,10 +903,10 @@ function finishRequest(state, input) {
902
903
  const remote = _api.trace.wrapSpanContext(input.span);
903
904
  _api.context.with(
904
905
  _api.trace.setSpan(_api.context.active(), remote),
905
- () => _chunkRV4MJNM2cjs.reportExplicitFailure.call(void 0, state)
906
+ () => _chunk37W7YYXOcjs.reportExplicitFailure.call(void 0, state)
906
907
  );
907
- } else _chunkRV4MJNM2cjs.reportExplicitFailure.call(void 0, state);
908
- _chunkRV4MJNM2cjs.emitSummary.call(void 0, state, {
908
+ } else _chunk37W7YYXOcjs.reportExplicitFailure.call(void 0, state);
909
+ _chunk37W7YYXOcjs.emitSummary.call(void 0, state, {
909
910
  http: {
910
911
  "http.request.method": input.method,
911
912
  "http.route": input.route,
@@ -916,14 +917,14 @@ function finishRequest(state, input) {
916
917
  });
917
918
  }
918
919
  function beginNodeRequest(req, res, options, route) {
919
- const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkRV4MJNM2cjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
920
- const requestId = _chunkRV4MJNM2cjs.resolveRequestId.call(void 0,
920
+ const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunk37W7YYXOcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
921
+ const requestId = _chunk37W7YYXOcjs.resolveRequestId.call(void 0,
921
922
  options.trustRequestId === false ? void 0 : req.headers[header]
922
923
  );
923
924
  const method = (_nullishCoalesce(req.method, () => ( "GET"))).toUpperCase();
924
925
  const path = pathOf(req);
925
- const state = _chunkRV4MJNM2cjs.createRequestState.call(void 0, {
926
- name: `${method} ${_chunkRV4MJNM2cjs.normalizeRoutePath.call(void 0, path)}`,
926
+ const state = _chunk37W7YYXOcjs.createRequestState.call(void 0, {
927
+ name: `${method} ${_chunk37W7YYXOcjs.normalizeRoutePath.call(void 0, path)}`,
927
928
  requestId,
928
929
  req,
929
930
  res
@@ -947,7 +948,7 @@ function beginNodeRequest(req, res, options, route) {
947
948
  const done = () => {
948
949
  finishRequest(state, {
949
950
  method,
950
- route: _nullishCoalesce(_nullishCoalesce(_optionalChain([route, 'optionalCall', _20 => _20()]), () => ( expressRouteOf(req))), () => ( _chunkRV4MJNM2cjs.normalizeRoutePath.call(void 0, path))),
951
+ route: _nullishCoalesce(_nullishCoalesce(_optionalChain([route, 'optionalCall', _20 => _20()]), () => ( expressRouteOf(req))), () => ( _chunk37W7YYXOcjs.normalizeRoutePath.call(void 0, path))),
951
952
  status: res.statusCode,
952
953
  aborted: !finished,
953
954
  ...spanContext ? { span: spanContext } : {}
@@ -961,50 +962,50 @@ function beginNodeRequest(req, res, options, route) {
961
962
  return state;
962
963
  }
963
964
  function autterRequests(options = {}) {
964
- const ignored = _chunkRV4MJNM2cjs.compileIgnore.call(void 0, options.ignore);
965
+ const ignored = _chunk37W7YYXOcjs.compileIgnore.call(void 0, options.ignore);
965
966
  return function autterRequestsMiddleware(req, res, next) {
966
967
  if (req[REQUEST_STATE] || ignored(pathOf(req))) {
967
968
  next();
968
969
  return;
969
970
  }
970
971
  const state = beginNodeRequest(req, res, options);
971
- _chunkRV4MJNM2cjs.local.run(state, () => next());
972
+ _chunk37W7YYXOcjs.local.run(state, () => next());
972
973
  };
973
974
  }
974
975
  function autterErrorResponse(options = {}) {
975
976
  return function autterErrorResponseMiddleware(error, req, res, next) {
976
977
  const state = req[REQUEST_STATE];
977
- if (state) _chunkRV4MJNM2cjs.noteOperationError.call(void 0, error, true, state);
978
+ if (state) _chunk37W7YYXOcjs.noteOperationError.call(void 0, error, true, state);
978
979
  captureAtBoundary(error, state, options.capture);
979
980
  if (res.headersSent) {
980
981
  next(error);
981
982
  return;
982
983
  }
983
- const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkRV4MJNM2cjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
984
+ const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunk37W7YYXOcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
984
985
  const inbound = _optionalChain([req, 'access', _21 => _21.headers, 'optionalAccess', _22 => _22[header]]);
985
986
  const requestId = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _23 => _23.requestId]), () => ( (typeof inbound === "string" ? inbound.slice(0, 128) : void 0)));
986
- res.statusCode = _chunkRV4MJNM2cjs.responseStatusOf.call(void 0, error);
987
+ res.statusCode = _chunk37W7YYXOcjs.responseStatusOf.call(void 0, error);
987
988
  res.setHeader("content-type", "application/json; charset=utf-8");
988
- res.end(JSON.stringify(_chunkRV4MJNM2cjs.toClientError.call(void 0, error, requestId)));
989
+ res.end(JSON.stringify(_chunk37W7YYXOcjs.toClientError.call(void 0, error, requestId)));
989
990
  };
990
991
  }
991
992
  var RESOURCE = /* @__PURE__ */ Symbol.for("autter.runtime.resource");
992
993
  function autterFastify(fastify, options, done) {
993
994
  const opts = _nullishCoalesce(options, () => ( {}));
994
- const header = (_nullishCoalesce(opts.requestIdHeader, () => ( _chunkRV4MJNM2cjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
995
- const ignored = _chunkRV4MJNM2cjs.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);
996
997
  const stateOf = (request) => request[REQUEST_STATE];
997
998
  fastify.addHook("onRequest", ((request, reply, next) => {
998
999
  if (ignored(request.url) || request.raw[REQUEST_STATE]) {
999
1000
  next();
1000
1001
  return;
1001
1002
  }
1002
- const requestId = _chunkRV4MJNM2cjs.resolveRequestId.call(void 0,
1003
+ const requestId = _chunk37W7YYXOcjs.resolveRequestId.call(void 0,
1003
1004
  opts.trustRequestId === false ? void 0 : request.headers[header]
1004
1005
  );
1005
1006
  const method = String(_nullishCoalesce(request.method, () => ( "GET"))).toUpperCase();
1006
- const state = _chunkRV4MJNM2cjs.createRequestState.call(void 0, {
1007
- name: `${method} ${_chunkRV4MJNM2cjs.normalizeRoutePath.call(void 0, request.url)}`,
1007
+ const state = _chunk37W7YYXOcjs.createRequestState.call(void 0, {
1008
+ name: `${method} ${_chunk37W7YYXOcjs.normalizeRoutePath.call(void 0, request.url)}`,
1008
1009
  requestId,
1009
1010
  req: request.raw,
1010
1011
  res: reply.raw
@@ -1024,7 +1025,7 @@ function autterFastify(fastify, options, done) {
1024
1025
  let finished = false;
1025
1026
  const finish = (aborted) => finishRequest(state, {
1026
1027
  method,
1027
- route: _nullishCoalesce(_nullishCoalesce(_optionalChain([request, 'access', _28 => _28.routeOptions, 'optionalAccess', _29 => _29.url]), () => ( request.routerPath)), () => ( _chunkRV4MJNM2cjs.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))),
1028
1029
  status: reply.raw.statusCode || reply.statusCode,
1029
1030
  aborted,
1030
1031
  ...spanContext ? { span: spanContext } : {}
@@ -1034,7 +1035,7 @@ function autterFastify(fastify, options, done) {
1034
1035
  finish(false);
1035
1036
  });
1036
1037
  reply.raw.once("close", () => finish(!finished));
1037
- _chunkRV4MJNM2cjs.local.run(state, () => {
1038
+ _chunk37W7YYXOcjs.local.run(state, () => {
1038
1039
  request[RESOURCE] = new (0, _async_hooks.AsyncResource)("autter-request");
1039
1040
  next();
1040
1041
  });
@@ -1056,7 +1057,7 @@ function autterFastify(fastify, options, done) {
1056
1057
  }));
1057
1058
  fastify.addHook("onError", ((request, _reply, error, next) => {
1058
1059
  const state = stateOf(request);
1059
- if (state) _chunkRV4MJNM2cjs.noteOperationError.call(void 0, error, true, state);
1060
+ if (state) _chunk37W7YYXOcjs.noteOperationError.call(void 0, error, true, state);
1060
1061
  captureAtBoundary(error, state);
1061
1062
  next();
1062
1063
  }));
@@ -1087,8 +1088,8 @@ function withHeaders(response, header, requestId) {
1087
1088
  }
1088
1089
  }
1089
1090
  function withRuntimeRequest(handler, options = {}) {
1090
- const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkRV4MJNM2cjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
1091
- const ignored = _chunkRV4MJNM2cjs.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);
1092
1093
  return async (request, ...rest) => {
1093
1094
  let pathname = "/";
1094
1095
  try {
@@ -1096,12 +1097,12 @@ function withRuntimeRequest(handler, options = {}) {
1096
1097
  } catch (e22) {
1097
1098
  }
1098
1099
  if (ignored(pathname)) return handler(request, ...rest);
1099
- const requestId = _chunkRV4MJNM2cjs.resolveRequestId.call(void 0,
1100
+ const requestId = _chunk37W7YYXOcjs.resolveRequestId.call(void 0,
1100
1101
  options.trustRequestId === false ? void 0 : request.headers.get(header)
1101
1102
  );
1102
1103
  const method = String(_nullishCoalesce(request.method, () => ( "GET"))).toUpperCase();
1103
- const route = _nullishCoalesce(options.route, () => ( _chunkRV4MJNM2cjs.normalizeRoutePath.call(void 0, pathname)));
1104
- const state = _chunkRV4MJNM2cjs.createRequestState.call(void 0, {
1104
+ const route = _nullishCoalesce(options.route, () => ( _chunk37W7YYXOcjs.normalizeRoutePath.call(void 0, pathname)));
1105
+ const state = _chunk37W7YYXOcjs.createRequestState.call(void 0, {
1105
1106
  name: `${method} ${_nullishCoalesce(options.name, () => ( route))}`,
1106
1107
  requestId,
1107
1108
  req: request
@@ -1115,11 +1116,11 @@ function withRuntimeRequest(handler, options = {}) {
1115
1116
  const spanContext = _optionalChain([span, 'optionalAccess', _32 => _32.spanContext, 'call', _33 => _33()]);
1116
1117
  let status = 500;
1117
1118
  try {
1118
- const response = await _chunkRV4MJNM2cjs.local.run(state, async () => {
1119
+ const response = await _chunk37W7YYXOcjs.local.run(state, async () => {
1119
1120
  try {
1120
1121
  return await handler(request, ...rest);
1121
1122
  } catch (error) {
1122
- _chunkRV4MJNM2cjs.noteOperationError.call(void 0, error, true, state);
1123
+ _chunk37W7YYXOcjs.noteOperationError.call(void 0, error, true, state);
1123
1124
  captureAtBoundary(error, state, true);
1124
1125
  throw error;
1125
1126
  }
@@ -1138,7 +1139,7 @@ function withRuntimeRequest(handler, options = {}) {
1138
1139
  });
1139
1140
  if (options.waitUntil) {
1140
1141
  try {
1141
- options.waitUntil(_chunkRV4MJNM2cjs.flushRuntimeLogs.call(void 0, ).catch(() => {
1142
+ options.waitUntil(_chunk37W7YYXOcjs.flushRuntimeLogs.call(void 0, ).catch(() => {
1142
1143
  }));
1143
1144
  } catch (e23) {
1144
1145
  }
@@ -1150,7 +1151,7 @@ function startHookRequest(res) {
1150
1151
  const req = res.req;
1151
1152
  if (!req || req[REQUEST_STATE]) return;
1152
1153
  const state = beginNodeRequest(req, res, {});
1153
- _chunkRV4MJNM2cjs.local.enterWith(state);
1154
+ _chunk37W7YYXOcjs.local.enterWith(state);
1154
1155
  }
1155
1156
 
1156
1157
  // src/unhandled-rejections.ts
@@ -1314,10 +1315,10 @@ var RouteLabelSampler = class {
1314
1315
  };
1315
1316
 
1316
1317
  // src/server.ts
1317
- var S = _chunkGYTQLITWcjs.sharedSlot.call(void 0, "server", () => ({
1318
+ var S = _chunkMOZOUEMAcjs.sharedSlot.call(void 0, "server", () => ({
1318
1319
  active: null,
1319
1320
  alwaysOnProvider: null,
1320
- redactor: _chunkRV4MJNM2cjs.makeRedactor.call(void 0, true),
1321
+ redactor: _chunk37W7YYXOcjs.makeRedactor.call(void 0, true),
1321
1322
  loggerOnlyCapture: null,
1322
1323
  hookRequests: false
1323
1324
  }));
@@ -1569,15 +1570,15 @@ async function runLlmSpan(tracer, info, fn) {
1569
1570
  return result;
1570
1571
  } catch (err) {
1571
1572
  recordError(span, err);
1572
- if (_chunkRV4MJNM2cjs.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);
1573
1574
  throw err;
1574
1575
  } finally {
1575
1576
  span.end();
1576
- _chunkRV4MJNM2cjs.recordOperationAiUsage.call(void 0, { ...usage, model: _nullishCoalesce(responseModel, () => ( info.model)) });
1577
+ _chunk37W7YYXOcjs.recordOperationAiUsage.call(void 0, { ...usage, model: _nullishCoalesce(responseModel, () => ( info.model)) });
1577
1578
  }
1578
1579
  }
1579
1580
  function recordLlmCall(tracer, call) {
1580
- _chunkRV4MJNM2cjs.recordOperationAiUsage.call(void 0, { ...call, model: call.model });
1581
+ _chunk37W7YYXOcjs.recordOperationAiUsage.call(void 0, { ...call, model: call.model });
1581
1582
  const durationMs = Math.max(0, _nullishCoalesce(call.durationMs, () => ( 0)));
1582
1583
  const endTime = /* @__PURE__ */ new Date();
1583
1584
  const startTime = new Date(endTime.getTime() - durationMs);
@@ -1591,7 +1592,7 @@ function recordLlmCall(tracer, call) {
1591
1592
  );
1592
1593
  if (call.error !== void 0 && call.error !== null) {
1593
1594
  recordError(span, call.error);
1594
- if (_chunkRV4MJNM2cjs.isError.call(void 0, call.error)) {
1595
+ if (_chunk37W7YYXOcjs.isError.call(void 0, call.error)) {
1595
1596
  span.setAttribute("error.type", call.error.name);
1596
1597
  }
1597
1598
  } else {
@@ -1619,14 +1620,14 @@ async function runWithSpan(tracer, name, fn, attributes, links) {
1619
1620
  }
1620
1621
  }
1621
1622
  function recordError(span, err) {
1622
- const isErr = _chunkRV4MJNM2cjs.isError.call(void 0, err);
1623
+ const isErr = _chunk37W7YYXOcjs.isError.call(void 0, err);
1623
1624
  const message = S.redactor.text(isErr ? err.message : String(err));
1624
1625
  if (isErr) {
1625
1626
  span.addEvent("exception", {
1626
1627
  "exception.type": err.name,
1627
1628
  "exception.message": message,
1628
1629
  ...err.stack ? { "exception.stacktrace": S.redactor.text(err.stack) } : {},
1629
- ..._chunkRV4MJNM2cjs.breadcrumbEventAttributes.call(void 0, S.redactor.text, err)
1630
+ ..._chunk37W7YYXOcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text, err)
1630
1631
  });
1631
1632
  }
1632
1633
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message });
@@ -1664,8 +1665,8 @@ function captureRequestRoute(span, response) {
1664
1665
  if (S.hookRequests) startHookRequest(response);
1665
1666
  }
1666
1667
  function structuredErrorAttributes(error) {
1667
- const attrs = { ..._chunkRV4MJNM2cjs.errorAttributes.call(void 0, error, { causes: false }) };
1668
- const internal = _chunkRV4MJNM2cjs.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);
1669
1670
  if (internal) {
1670
1671
  try {
1671
1672
  attrs["autter.error.internal"] = JSON.stringify(
@@ -1683,9 +1684,9 @@ function initAutterServer(options) {
1683
1684
  ""
1684
1685
  );
1685
1686
  const headers = { authorization: `Bearer ${options.apiKey}` };
1686
- const redactor = _chunkRV4MJNM2cjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
1687
+ const redactor = _chunk37W7YYXOcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
1687
1688
  const queryPolicy = makeUrlQueryPolicy(options.keepQueryParams);
1688
- const traceExporter = () => new (0, _chunkGYTQLITWcjs.CountingExporter)(
1689
+ const traceExporter = () => new (0, _chunkMOZOUEMAcjs.CountingExporter)(
1689
1690
  new RedactingSpanExporter(
1690
1691
  new (0, _exportertraceotlphttp.OTLPTraceExporter)({ url: `${endpoint}/v1/traces`, headers }),
1691
1692
  () => redactor,
@@ -1693,11 +1694,11 @@ function initAutterServer(options) {
1693
1694
  )
1694
1695
  );
1695
1696
  const environment = _nullishCoalesce(_nullishCoalesce(options.environment, () => ( process.env.NODE_ENV)), () => ( "production"));
1696
- if (_chunkGYTQLITWcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunkGYTQLITWcjs.setDebugMode.call(void 0, true);
1697
- _chunkGYTQLITWcjs.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}`);
1698
1699
  S.redactor = redactor;
1699
- const distro = _nullishCoalesce(options.distro, () => ( _chunkGYTQLITWcjs.SDK_IDENTITY));
1700
- _chunkGYTQLITWcjs.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 });
1701
1702
  const resource = new (0, _resources.Resource)({
1702
1703
  [_semanticconventions.ATTR_SERVICE_NAME]: options.service,
1703
1704
  "service.instance.id": (options.instanceId || process.env.AUTTER_RUNTIME_INSTANCE_ID || _crypto.randomUUID.call(void 0, )).slice(0, 128),
@@ -1718,6 +1719,7 @@ function initAutterServer(options) {
1718
1719
  // its span-fed per-route counts.
1719
1720
  "autter.metrics_routes": true
1720
1721
  });
1722
+ const errorFilter = _chunk37W7YYXOcjs.createErrorFilter.call(void 0, { ignoreErrors: options.ignoreErrors, sampleRate: options.sampleRate });
1721
1723
  const rootSampler = new (0, _sdktracebase.TraceIdRatioBasedSampler)(_nullishCoalesce(options.traceSampleRate, () => ( 0.01)));
1722
1724
  const headSampler = new (0, _sdktracebase.ParentBasedSampler)({
1723
1725
  root: rootSampler,
@@ -1779,9 +1781,9 @@ function initAutterServer(options) {
1779
1781
  sdk.start();
1780
1782
  patchLoadedHttpModules();
1781
1783
  const stopMemoryMetrics = options.memoryMetrics === false ? null : startMemoryMetrics();
1782
- _chunkGYTQLITWcjs.noteCompatFeature.call(void 0, "endpoint_latency");
1783
- if (stopMemoryMetrics) _chunkGYTQLITWcjs.noteCompatFeature.call(void 0, "memory_metrics");
1784
- if (options.llmTracing !== false) _chunkGYTQLITWcjs.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");
1785
1787
  const alwaysOnProvider = new (0, _sdktracebase.BasicTracerProvider)({
1786
1788
  resource,
1787
1789
  sampler: new (0, _sdktracebase.AlwaysOnSampler)(),
@@ -1793,25 +1795,35 @@ function initAutterServer(options) {
1793
1795
  const processTracer = alwaysOnProvider.getTracer("autter-processes");
1794
1796
  const llmTracer = alwaysOnProvider.getTracer("autter-llm");
1795
1797
  function captureException2(error, attributes) {
1796
- _optionalChain([errorTraceBuffer, 'optionalAccess', _53 => _53.retainActiveTrace, 'call', _54 => _54()]);
1797
- _chunkGYTQLITWcjs.telemetryStats.markCaptured();
1798
- const isErr = _chunkRV4MJNM2cjs.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);
1799
1811
  const message = redactor.text(isErr ? error.message : String(error));
1800
1812
  const stackText = isErr && error.stack ? redactor.text(error.stack) : "";
1801
- const split = _chunkRV4MJNM2cjs.splitFingerprint.call(void 0, attributes);
1802
- const fingerprint = _chunkRV4MJNM2cjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redactor.text);
1803
- if (fingerprint["autter.fingerprint"]) _chunkGYTQLITWcjs.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");
1804
1816
  const redacted = redactor(split.attributes);
1805
1817
  const activeSpan = _api.trace.getActiveSpan();
1806
- const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _55 => _55.isRecording, 'call', _56 => _56()]) === true;
1818
+ const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _57 => _57.isRecording, 'call', _58 => _58()]) === true;
1807
1819
  const span = reuseActive ? activeSpan : errorTracer.startSpan(isErr ? error.name : "Error");
1808
1820
  const structured = structuredErrorAttributes(error);
1809
- const causes = _chunkRV4MJNM2cjs.errorAttributes.call(void 0, error);
1821
+ const causes = _chunk37W7YYXOcjs.errorAttributes.call(void 0, error);
1810
1822
  const declared = {
1811
1823
  ...Object.fromEntries(Object.entries(causes).filter(([key]) => key !== "autter.error.internal")),
1812
1824
  ...fingerprint
1813
1825
  };
1814
- const requestId = _optionalChain([_chunkRV4MJNM2cjs.currentOperation.call(void 0, ), 'optionalAccess', _57 => _57.requestId]);
1826
+ const requestId = _optionalChain([_chunk37W7YYXOcjs.currentOperation.call(void 0, ), 'optionalAccess', _59 => _59.requestId]);
1815
1827
  span.setAttributes({
1816
1828
  "autter.severity": "error",
1817
1829
  ...redacted,
@@ -1819,8 +1831,8 @@ function initAutterServer(options) {
1819
1831
  ...requestId ? { "autter.request.id": requestId } : {}
1820
1832
  });
1821
1833
  markCaptured(error);
1822
- _chunkRV4MJNM2cjs.noteOperationError.call(void 0, error);
1823
- _chunkRV4MJNM2cjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
1834
+ _chunk37W7YYXOcjs.noteOperationError.call(void 0, error);
1835
+ _chunk37W7YYXOcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
1824
1836
  if (isErr && stackText) {
1825
1837
  span.addEvent("exception", {
1826
1838
  "exception.type": error.name,
@@ -1828,28 +1840,29 @@ function initAutterServer(options) {
1828
1840
  "exception.stacktrace": stackText,
1829
1841
  ...redacted["autter.handled"] === true ? { "autter.handled": true, "autter.sampled": redacted["autter.sampled"] === true } : {},
1830
1842
  ...declared,
1831
- ..._chunkRV4MJNM2cjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
1843
+ ..._chunk37W7YYXOcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
1832
1844
  });
1833
1845
  } else {
1834
- const stack = _optionalChain([new Error(), 'access', _58 => _58.stack, 'optionalAccess', _59 => _59.split, 'call', _60 => _60("\n"), 'access', _61 => _61.filter, 'call', _62 => _62((line, i) => i === 0 || !line.includes("captureException")), 'access', _63 => _63.join, 'call', _64 => _64("\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")]);
1835
1847
  span.addEvent("exception", {
1836
1848
  "exception.type": isErr ? error.name : "Error",
1837
1849
  "exception.message": message,
1838
1850
  ...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
1839
1851
  ...redacted["autter.handled"] === true ? { "autter.handled": true, "autter.sampled": redacted["autter.sampled"] === true } : {},
1840
1852
  ...declared,
1841
- ..._chunkRV4MJNM2cjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
1853
+ ..._chunk37W7YYXOcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
1842
1854
  });
1843
1855
  }
1844
1856
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message });
1845
1857
  if (!reuseActive) span.end();
1846
1858
  }
1847
1859
  function captureMessage2(message, severity = "warning", attributes) {
1860
+ if (!errorFilter({ type: "Message", message: String(message), severity })) return;
1848
1861
  if (severity === "error" || severity === "fatal") {
1849
- _optionalChain([errorTraceBuffer, 'optionalAccess', _65 => _65.retainActiveTrace, 'call', _66 => _66()]);
1862
+ _optionalChain([errorTraceBuffer, 'optionalAccess', _67 => _67.retainActiveTrace, 'call', _68 => _68()]);
1850
1863
  }
1851
- _chunkGYTQLITWcjs.telemetryStats.markCaptured();
1852
- const stack = _optionalChain([new Error(), 'access', _67 => _67.stack, 'optionalAccess', _68 => _68.split, 'call', _69 => _69("\n"), 'access', _70 => _70.filter, 'call', _71 => _71((line, i) => i === 0 || !line.includes("captureMessage")), 'access', _72 => _72.join, 'call', _73 => _73("\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")]);
1853
1866
  const safeMessage = redactor.text(message);
1854
1867
  const span = errorTracer.startSpan("Message", {
1855
1868
  attributes: { "autter.severity": severity, ...redactor(attributes) }
@@ -1859,16 +1872,17 @@ function initAutterServer(options) {
1859
1872
  "exception.message": safeMessage,
1860
1873
  ...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
1861
1874
  "autter.severity": severity,
1862
- ..._chunkRV4MJNM2cjs.breadcrumbEventAttributes.call(void 0, redactor.text)
1875
+ ..._chunk37W7YYXOcjs.breadcrumbEventAttributes.call(void 0, redactor.text)
1863
1876
  });
1864
1877
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
1865
1878
  span.end();
1866
1879
  }
1867
1880
  function reportOutcome2(name, message, attributes) {
1868
- _optionalChain([errorTraceBuffer, 'optionalAccess', _74 => _74.retainActiveTrace, 'call', _75 => _75()]);
1869
- _chunkGYTQLITWcjs.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();
1870
1884
  const activeSpan = _api.trace.getActiveSpan();
1871
- const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _76 => _76.isRecording, 'call', _77 => _77()]) === true;
1885
+ const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _78 => _78.isRecording, 'call', _79 => _79()]) === true;
1872
1886
  const span = reuseActive ? activeSpan : errorTracer.startSpan("OutcomeFailure");
1873
1887
  const safeOutcome = redactor({ "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
1874
1888
  const safeName = String(_nullishCoalesce(safeOutcome["autter.outcome.name"], () => ( "operation")));
@@ -1882,7 +1896,7 @@ function initAutterServer(options) {
1882
1896
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
1883
1897
  if (!reuseActive) span.end();
1884
1898
  }
1885
- _chunkRV4MJNM2cjs.configureRuntimeLogger.call(void 0, {
1899
+ _chunk37W7YYXOcjs.configureRuntimeLogger.call(void 0, {
1886
1900
  endpoint,
1887
1901
  apiKey: options.apiKey,
1888
1902
  service: options.service,
@@ -1894,7 +1908,7 @@ function initAutterServer(options) {
1894
1908
  run: (name, fn, attributes, links) => runWithSpan(processTracer, name, fn, redactor(attributes), links),
1895
1909
  reportOutcome: reportOutcome2
1896
1910
  });
1897
- S.hookRequests = _optionalChain([options, 'access', _78 => _78.logging, 'optionalAccess', _79 => _79.requests]) === true;
1911
+ S.hookRequests = _optionalChain([options, 'access', _80 => _80.logging, 'optionalAccess', _81 => _81.requests]) === true;
1898
1912
  let onCrash = null;
1899
1913
  let uninstallRejections = null;
1900
1914
  if (options.captureGlobalErrors !== false) {
@@ -1914,7 +1928,7 @@ function initAutterServer(options) {
1914
1928
  const flushTarget = {
1915
1929
  forceFlush: async () => {
1916
1930
  const results = await Promise.allSettled([
1917
- _chunkRV4MJNM2cjs.flushRuntimeLogs.call(void 0, ),
1931
+ _chunk37W7YYXOcjs.flushRuntimeLogs.call(void 0, ),
1918
1932
  Promise.resolve().then(() => alwaysOnProvider.forceFlush()),
1919
1933
  Promise.resolve().then(() => mainSpanProcessor.forceFlush()),
1920
1934
  ...errorTraceBuffer ? [Promise.resolve().then(() => errorTraceBuffer.forceFlush())] : [],
@@ -1928,10 +1942,10 @@ function initAutterServer(options) {
1928
1942
  }
1929
1943
  }
1930
1944
  };
1931
- _chunkGYTQLITWcjs.registerFlushTarget.call(void 0, "active-server", flushTarget);
1945
+ _chunkMOZOUEMAcjs.registerFlushTarget.call(void 0, "active-server", flushTarget);
1932
1946
  let autoFlushHandle = null;
1933
1947
  if (options.autoFlush !== false) {
1934
- autoFlushHandle = _chunkGYTQLITWcjs.installAutterAutoFlush.call(void 0, );
1948
+ autoFlushHandle = _chunkMOZOUEMAcjs.installAutterAutoFlush.call(void 0, );
1935
1949
  }
1936
1950
  const server = {
1937
1951
  captureException: captureException2,
@@ -1941,22 +1955,22 @@ function initAutterServer(options) {
1941
1955
  withLlmCall: (info, fn) => runLlmSpan(llmTracer, info, fn),
1942
1956
  trackLlmCall: (call) => recordLlmCall(llmTracer, call),
1943
1957
  shutdown: async () => {
1944
- const logShutdown = await Promise.allSettled([_chunkRV4MJNM2cjs.shutdownRuntimeLogger.call(void 0, )]);
1958
+ const logShutdown = await Promise.allSettled([_chunk37W7YYXOcjs.shutdownRuntimeLogger.call(void 0, )]);
1945
1959
  if (onCrash) process.off("uncaughtExceptionMonitor", onCrash);
1946
- _optionalChain([uninstallRejections, 'optionalCall', _80 => _80()]);
1947
- _optionalChain([stopMemoryMetrics, 'optionalCall', _81 => _81()]);
1960
+ _optionalChain([uninstallRejections, 'optionalCall', _82 => _82()]);
1961
+ _optionalChain([stopMemoryMetrics, 'optionalCall', _83 => _83()]);
1948
1962
  if (S.active === server) {
1949
1963
  S.active = null;
1950
1964
  S.alwaysOnProvider = null;
1951
1965
  S.hookRequests = false;
1952
- S.redactor = _chunkRV4MJNM2cjs.makeRedactor.call(void 0, true);
1966
+ S.redactor = _chunk37W7YYXOcjs.makeRedactor.call(void 0, true);
1953
1967
  }
1954
- _optionalChain([autoFlushHandle, 'optionalAccess', _82 => _82.dispose, 'call', _83 => _83()]);
1968
+ _optionalChain([autoFlushHandle, 'optionalAccess', _84 => _84.dispose, 'call', _85 => _85()]);
1955
1969
  autoFlushHandle = null;
1956
- _chunkGYTQLITWcjs.unregisterFlushTargets.call(void 0, );
1957
- _chunkGYTQLITWcjs.telemetryStats.markAllFlushed();
1970
+ _chunkMOZOUEMAcjs.unregisterFlushTargets.call(void 0, );
1971
+ _chunkMOZOUEMAcjs.telemetryStats.markAllFlushed();
1958
1972
  await Promise.allSettled([alwaysOnProvider.shutdown(), sdk.shutdown()]);
1959
- if (_optionalChain([logShutdown, 'access', _84 => _84[0], 'optionalAccess', _85 => _85.status]) === "rejected") throw logShutdown[0].reason;
1973
+ if (_optionalChain([logShutdown, 'access', _86 => _86[0], 'optionalAccess', _87 => _87.status]) === "rejected") throw logShutdown[0].reason;
1960
1974
  }
1961
1975
  };
1962
1976
  S.active = server;
@@ -1973,11 +1987,11 @@ function captureException(error, attributes) {
1973
1987
  return;
1974
1988
  }
1975
1989
  markCaptured(error);
1976
- _chunkRV4MJNM2cjs.noteOperationError.call(void 0, error);
1977
- const split = _chunkRV4MJNM2cjs.splitFingerprint.call(void 0, attributes);
1978
- const fingerprint = _chunkRV4MJNM2cjs.fingerprintEventAttributes.call(void 0, split.fingerprint, S.redactor.text);
1979
- _chunkRV4MJNM2cjs.notifyException.call(void 0, error, { ...split.attributes, ...fingerprint });
1980
- const span = _api.trace.getTracer("autter-errors").startSpan(_chunkRV4MJNM2cjs.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", {
1981
1995
  attributes: { ...S.redactor(split.attributes), ...fingerprint }
1982
1996
  });
1983
1997
  recordError(span, error);
@@ -1992,7 +2006,7 @@ function serverActive() {
1992
2006
  setRequestExceptionCapturer((error, attributes) => captureException(error, attributes));
1993
2007
  setRequestSpanAnnotator((attributes) => {
1994
2008
  const span = _api.trace.getActiveSpan();
1995
- if (_optionalChain([span, 'optionalAccess', _86 => _86.isRecording, 'call', _87 => _87()])) span.setAttributes(S.redactor(_chunkRV4MJNM2cjs.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));
1996
2010
  });
1997
2011
  function withProcessSpan(name, fn, attributes) {
1998
2012
  if (S.active) return S.active.withProcessSpan(name, fn, attributes);
@@ -2027,7 +2041,7 @@ function captureMessage(message, severity = "warning", attributes) {
2027
2041
  "exception.type": "Message",
2028
2042
  "exception.message": safeMessage,
2029
2043
  "autter.severity": severity,
2030
- ..._chunkRV4MJNM2cjs.breadcrumbEventAttributes.call(void 0, S.redactor.text)
2044
+ ..._chunk37W7YYXOcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text)
2031
2045
  });
2032
2046
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
2033
2047
  span.end();
@@ -2035,11 +2049,11 @@ function captureMessage(message, severity = "warning", attributes) {
2035
2049
  function reportOutcome(name, message, attributes) {
2036
2050
  if (S.active) return S.active.reportOutcome(name, message, attributes);
2037
2051
  const span = _api.trace.getTracer("autter-outcomes").startSpan("OutcomeFailure");
2038
- const safeOutcome = _chunkRV4MJNM2cjs.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) });
2039
2053
  const safeName = String(_nullishCoalesce(safeOutcome["autter.outcome.name"], () => ( "operation")));
2040
2054
  const safeMessage = String(_nullishCoalesce(safeOutcome["autter.outcome.message"], () => ( "failed")));
2041
2055
  span.addEvent("autter.outcome", {
2042
- ..._chunkRV4MJNM2cjs.redactAttributes.call(void 0, attributes),
2056
+ ..._chunk37W7YYXOcjs.redactAttributes.call(void 0, attributes),
2043
2057
  "autter.outcome.status": "error",
2044
2058
  "autter.outcome.name": safeName,
2045
2059
  "autter.outcome.message": safeMessage
@@ -2048,7 +2062,7 @@ function reportOutcome(name, message, attributes) {
2048
2062
  span.end();
2049
2063
  }
2050
2064
  function makeSafeCapture(options) {
2051
- const clean = (attributes) => attributes ? { ..._chunkRV4MJNM2cjs.redactAttributes.call(void 0, attributes, options) } : void 0;
2065
+ const clean = (attributes) => attributes ? { ..._chunk37W7YYXOcjs.redactAttributes.call(void 0, attributes, options) } : void 0;
2052
2066
  return {
2053
2067
  captureException: (error, attributes) => captureException(error, clean(attributes)),
2054
2068
  captureMessage: (message, severity, attributes) => captureMessage(message, _nullishCoalesce(severity, () => ( "warning")), clean(attributes))
@@ -2075,7 +2089,7 @@ async function emitLlmSelftestTrace() {
2075
2089
  attributes: { "autter.selftest": true }
2076
2090
  },
2077
2091
  (llm) => {
2078
- traceId = _nullishCoalesce(_optionalChain([_api.trace, 'access', _88 => _88.getActiveSpan, 'call', _89 => _89(), 'optionalAccess', _90 => _90.spanContext, 'call', _91 => _91(), 'access', _92 => _92.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]), () => ( ""));
2079
2093
  llm.setUsage({ inputTokens: 1, outputTokens: 1 });
2080
2094
  llm.setCost(0);
2081
2095
  }
@@ -2103,7 +2117,7 @@ var CALL_METHODS = /* @__PURE__ */ new Set([
2103
2117
  // openai beta structured outputs
2104
2118
  ]);
2105
2119
  function detectProvider(client) {
2106
- const name = _nullishCoalesce(_optionalChain([client, 'access', _93 => _93.constructor, 'optionalAccess', _94 => _94.name, 'optionalAccess', _95 => _95.toLowerCase, 'call', _96 => _96()]), () => ( ""));
2120
+ const name = _nullishCoalesce(_optionalChain([client, 'access', _95 => _95.constructor, 'optionalAccess', _96 => _96.name, 'optionalAccess', _97 => _97.toLowerCase, 'call', _98 => _98()]), () => ( ""));
2107
2121
  for (const known of ["openai", "anthropic", "mistral", "groq", "cohere"]) {
2108
2122
  if (name.includes(known)) return known;
2109
2123
  }
@@ -2111,7 +2125,7 @@ function detectProvider(client) {
2111
2125
  const baseUrl = String(
2112
2126
  _nullishCoalesce(_nullishCoalesce(client.baseURL, () => ( client.baseUrl)), () => ( ""))
2113
2127
  );
2114
- const host = _nullishCoalesce(_optionalChain([baseUrl, 'access', _97 => _97.match, 'call', _98 => _98(/https?:\/\/([^/]+)/), 'optionalAccess', _99 => _99[1]]), () => ( ""));
2128
+ const host = _nullishCoalesce(_optionalChain([baseUrl, 'access', _99 => _99.match, 'call', _100 => _100(/https?:\/\/([^/]+)/), 'optionalAccess', _101 => _101[1]]), () => ( ""));
2115
2129
  if (host.includes("openai")) return "openai";
2116
2130
  if (host.includes("anthropic")) return "anthropic";
2117
2131
  if (host.includes("googleapis")) return "google";
@@ -2121,13 +2135,13 @@ function detectProvider(client) {
2121
2135
  }
2122
2136
  function extractUsage(result) {
2123
2137
  const r = result;
2124
- const usage = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _100 => _100.usage]), () => ( _optionalChain([r, 'optionalAccess', _101 => _101.message, 'optionalAccess', _102 => _102.usage])));
2125
- const meta = _optionalChain([r, 'optionalAccess', _103 => _103.usageMetadata]);
2126
- const details = _optionalChain([usage, 'optionalAccess', _104 => _104.prompt_tokens_details]);
2127
- const cached = _nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _105 => _105.cache_read_input_tokens]), () => ( (typeof _optionalChain([details, 'optionalAccess', _106 => _106.cached_tokens]) === "number" ? details.cached_tokens : void 0))), () => ( _optionalChain([meta, 'optionalAccess', _107 => _107.cachedContentTokenCount])));
2128
- const input = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _108 => _108.prompt_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _109 => _109.input_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _110 => _110.promptTokenCount]))), () => ( void 0));
2129
- const output = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _111 => _111.completion_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _112 => _112.output_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _113 => _113.candidatesTokenCount]))), () => ( void 0));
2130
- const responseModel = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _114 => _114.model]), () => ( _optionalChain([r, 'optionalAccess', _115 => _115.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])));
2131
2145
  return {
2132
2146
  inputTokens: typeof input === "number" ? input : void 0,
2133
2147
  outputTokens: typeof output === "number" ? output : void 0,
@@ -2136,7 +2150,7 @@ function extractUsage(result) {
2136
2150
  };
2137
2151
  }
2138
2152
  function rollUp(model, usage) {
2139
- _chunkRV4MJNM2cjs.recordOperationAiUsage.call(void 0, {
2153
+ _chunk37W7YYXOcjs.recordOperationAiUsage.call(void 0, {
2140
2154
  model: _nullishCoalesce(usage.responseModel, () => ( model)),
2141
2155
  ...usage.inputTokens !== void 0 ? { inputTokens: usage.inputTokens } : {},
2142
2156
  ...usage.outputTokens !== void 0 ? { outputTokens: usage.outputTokens } : {},
@@ -2220,10 +2234,10 @@ function wrapStream(stream, span, model) {
2220
2234
  });
2221
2235
  }
2222
2236
  function instrumentLlmClient(client, options) {
2223
- const provider = (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _116 => _116.provider]), () => ( detectProvider(client)))).toLowerCase();
2237
+ const provider = (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _118 => _118.provider]), () => ( detectProvider(client)))).toLowerCase();
2224
2238
  const proxied = /* @__PURE__ */ new WeakMap();
2225
2239
  function resolveUserId() {
2226
- return typeof _optionalChain([options, 'optionalAccess', _117 => _117.userId]) === "function" ? options.userId() : _optionalChain([options, 'optionalAccess', _118 => _118.userId]);
2240
+ return typeof _optionalChain([options, 'optionalAccess', _119 => _119.userId]) === "function" ? options.userId() : _optionalChain([options, 'optionalAccess', _120 => _120.userId]);
2227
2241
  }
2228
2242
  function traceCall(fn, self, callPath, args) {
2229
2243
  const request = args[0];
@@ -2237,7 +2251,7 @@ function instrumentLlmClient(client, options) {
2237
2251
  "gen_ai.system": provider,
2238
2252
  "gen_ai.request.model": request.model,
2239
2253
  ...userId ? { "autter.user_id": userId } : {},
2240
- ...redactWithActive(_optionalChain([options, 'optionalAccess', _119 => _119.attributes]))
2254
+ ...redactWithActive(_optionalChain([options, 'optionalAccess', _121 => _121.attributes]))
2241
2255
  }
2242
2256
  });
2243
2257
  let result;
@@ -2361,7 +2375,7 @@ ${frames.join("\n")}`;
2361
2375
  function recordBoundaryError(error, req, rule) {
2362
2376
  try {
2363
2377
  const state = requestStateOf(req);
2364
- if (state) _chunkRV4MJNM2cjs.noteOperationError.call(void 0, error, false, state);
2378
+ if (state) _chunk37W7YYXOcjs.noteOperationError.call(void 0, error, false, state);
2365
2379
  captureAtBoundary(error, state, rule);
2366
2380
  } catch (e32) {
2367
2381
  }
@@ -2373,12 +2387,12 @@ function autterErrorHandler(options = {}) {
2373
2387
  };
2374
2388
  }
2375
2389
  function autterFastifyErrors(fastify, options, done) {
2376
- const rule = _optionalChain([options, 'optionalAccess', _120 => _120.capture]);
2390
+ const rule = _optionalChain([options, 'optionalAccess', _122 => _122.capture]);
2377
2391
  fastify.addHook("onError", ((request, _reply, error, next) => {
2378
- recordBoundaryError(error, _optionalChain([request, 'optionalAccess', _121 => _121.raw]), rule);
2392
+ recordBoundaryError(error, _optionalChain([request, 'optionalAccess', _123 => _123.raw]), rule);
2379
2393
  next();
2380
2394
  }));
2381
- _optionalChain([done, 'optionalCall', _122 => _122()]);
2395
+ _optionalChain([done, 'optionalCall', _124 => _124()]);
2382
2396
  }
2383
2397
  autterFastifyErrors[/* @__PURE__ */ Symbol.for("skip-override")] = true;
2384
2398
  autterFastifyErrors[/* @__PURE__ */ Symbol.for("fastify.display-name")] = "autter-runtime-errors";
@@ -2387,7 +2401,7 @@ function autterKoa(options = {}) {
2387
2401
  try {
2388
2402
  await next();
2389
2403
  } catch (error) {
2390
- recordBoundaryError(error, _optionalChain([ctx, 'optionalAccess', _123 => _123.req]), options.capture);
2404
+ recordBoundaryError(error, _optionalChain([ctx, 'optionalAccess', _125 => _125.req]), options.capture);
2391
2405
  throw error;
2392
2406
  }
2393
2407
  };
@@ -2398,7 +2412,7 @@ function autterKoa(options = {}) {
2398
2412
 
2399
2413
 
2400
2414
 
2401
- var L = _chunkGYTQLITWcjs.sharedSlot.call(void 0, "logging", () => ({ active: null }));
2415
+ var L = _chunkMOZOUEMAcjs.sharedSlot.call(void 0, "logging", () => ({ active: null }));
2402
2416
  function initAutterLogging(options) {
2403
2417
  if (L.active) return L.active;
2404
2418
  if (serverActive()) {
@@ -2407,29 +2421,37 @@ function initAutterLogging(options) {
2407
2421
  );
2408
2422
  return {
2409
2423
  captureException,
2410
- flush: _chunkRV4MJNM2cjs.flushRuntimeLogs,
2424
+ flush: _chunk37W7YYXOcjs.flushRuntimeLogs,
2411
2425
  shutdown: async () => {
2412
2426
  }
2413
2427
  };
2414
2428
  }
2415
- if (_chunkGYTQLITWcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunkGYTQLITWcjs.setDebugMode.call(void 0, true);
2429
+ if (_chunkMOZOUEMAcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunkMOZOUEMAcjs.setDebugMode.call(void 0, true);
2416
2430
  const endpoint = (_nullishCoalesce(options.endpoint, () => ( "https://otlp.autter.dev"))).replace(/\/$/, "");
2417
2431
  const environment = _nullishCoalesce(_nullishCoalesce(options.environment, () => ( process.env.NODE_ENV)), () => ( "production"));
2418
- const redact = _chunkRV4MJNM2cjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
2432
+ const redact = _chunk37W7YYXOcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
2419
2433
  const mode = _nullishCoalesce(options.exceptions, () => ( "auto"));
2420
- _chunkGYTQLITWcjs.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 });
2421
2436
  function captureException2(error, attributes) {
2422
2437
  markCaptured(error);
2423
- const split = _chunkRV4MJNM2cjs.splitFingerprint.call(void 0, attributes);
2424
- const fingerprint = _chunkRV4MJNM2cjs.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);
2425
2447
  const redacted = redact(split.attributes);
2426
2448
  const span = _api.trace.getActiveSpan();
2427
- if (mode === "auto" && _optionalChain([span, 'optionalAccess', _124 => _124.isRecording, 'call', _125 => _125()])) {
2428
- _chunkRV4MJNM2cjs.noteOperationError.call(void 0, error);
2429
- _chunkRV4MJNM2cjs.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 });
2430
2452
  span.setAttributes({ "autter.severity": "error", ...redacted, ...structuredErrorAttributes(error) });
2431
- const declared = { ..._chunkRV4MJNM2cjs.errorAttributes.call(void 0, error), ...fingerprint };
2432
- if (_chunkRV4MJNM2cjs.isError.call(void 0, error)) {
2453
+ const declared = { ..._chunk37W7YYXOcjs.errorAttributes.call(void 0, error), ...fingerprint };
2454
+ if (_chunk37W7YYXOcjs.isError.call(void 0, error)) {
2433
2455
  span.addEvent("exception", {
2434
2456
  "exception.type": error.name,
2435
2457
  "exception.message": error.message,
@@ -2445,15 +2467,15 @@ function initAutterLogging(options) {
2445
2467
  }
2446
2468
  span.setStatus({
2447
2469
  code: _api.SpanStatusCode.ERROR,
2448
- message: _chunkRV4MJNM2cjs.isError.call(void 0, error) ? error.message : String(error)
2470
+ message: _chunk37W7YYXOcjs.isError.call(void 0, error) ? error.message : String(error)
2449
2471
  });
2450
2472
  return;
2451
2473
  }
2452
- _chunkRV4MJNM2cjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
2453
- _chunkRV4MJNM2cjs.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 });
2454
2476
  }
2455
2477
  const captured = /* @__PURE__ */ new WeakSet();
2456
- _chunkRV4MJNM2cjs.configureRuntimeLogger.call(void 0, {
2478
+ _chunk37W7YYXOcjs.configureRuntimeLogger.call(void 0, {
2457
2479
  endpoint,
2458
2480
  apiKey: _nullishCoalesce(options.apiKey, () => ( "")),
2459
2481
  service: options.service,
@@ -2462,7 +2484,7 @@ function initAutterLogging(options) {
2462
2484
  ...options.logging ? { options: options.logging } : {},
2463
2485
  redact,
2464
2486
  reportOutcome: (name, message, attributes) => {
2465
- _chunkRV4MJNM2cjs.runtimeLogger.error(message, {
2487
+ _chunk37W7YYXOcjs.runtimeLogger.error(message, {
2466
2488
  ...attributes,
2467
2489
  "autter.outcome.name": name.slice(0, 200),
2468
2490
  "autter.outcome.message": message.slice(0, 1e3)
@@ -2489,21 +2511,21 @@ function initAutterLogging(options) {
2489
2511
  (reason) => captureException2(reason, { "autter.unhandled_rejection": true })
2490
2512
  );
2491
2513
  }
2492
- _chunkGYTQLITWcjs.registerFlushTarget.call(void 0, "logging", { forceFlush: () => _chunkRV4MJNM2cjs.flushRuntimeLogs.call(void 0, ) });
2493
- let autoFlushHandle = options.autoFlush === false ? null : _chunkGYTQLITWcjs.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, );
2494
2516
  const handle = {
2495
2517
  captureException: captureException2,
2496
- flush: _chunkRV4MJNM2cjs.flushRuntimeLogs,
2518
+ flush: _chunk37W7YYXOcjs.flushRuntimeLogs,
2497
2519
  shutdown: async () => {
2498
2520
  process.off("uncaughtExceptionMonitor", onCrash);
2499
- _optionalChain([uninstallRejections, 'optionalCall', _126 => _126()]);
2521
+ _optionalChain([uninstallRejections, 'optionalCall', _130 => _130()]);
2500
2522
  uninstallRejections = null;
2501
2523
  setLoggerOnlyCapture(null);
2502
- _optionalChain([autoFlushHandle, 'optionalAccess', _127 => _127.dispose, 'call', _128 => _128()]);
2524
+ _optionalChain([autoFlushHandle, 'optionalAccess', _131 => _131.dispose, 'call', _132 => _132()]);
2503
2525
  autoFlushHandle = null;
2504
- _chunkGYTQLITWcjs.unregisterFlushTargets.call(void 0, );
2526
+ _chunkMOZOUEMAcjs.unregisterFlushTargets.call(void 0, );
2505
2527
  if (L.active === handle) L.active = null;
2506
- await _chunkRV4MJNM2cjs.shutdownRuntimeLogger.call(void 0, );
2528
+ await _chunk37W7YYXOcjs.shutdownRuntimeLogger.call(void 0, );
2507
2529
  }
2508
2530
  };
2509
2531
  L.active = handle;
@@ -2512,7 +2534,7 @@ function initAutterLogging(options) {
2512
2534
 
2513
2535
  // src/enrichers.ts
2514
2536
  function headerOf(req, name) {
2515
- const headers = _optionalChain([req, 'optionalAccess', _129 => _129.headers]);
2537
+ const headers = _optionalChain([req, 'optionalAccess', _133 => _133.headers]);
2516
2538
  if (!headers) return void 0;
2517
2539
  if (typeof headers.get === "function") {
2518
2540
  return _nullishCoalesce(headers.get(name), () => ( void 0));
@@ -2525,7 +2547,7 @@ function enrichUserAgent() {
2525
2547
  return (event, { req }) => {
2526
2548
  const ua = headerOf(req, "user-agent");
2527
2549
  if (!ua) return;
2528
- const info = _chunkRV4MJNM2cjs.parseUserAgent.call(void 0, ua);
2550
+ const info = _chunk37W7YYXOcjs.parseUserAgent.call(void 0, ua);
2529
2551
  if (info.browser) event.attributes["user_agent.browser"] = info.browser;
2530
2552
  if (info.os) event.attributes["user_agent.os"] = info.os;
2531
2553
  event.attributes["user_agent.device"] = info.device;
@@ -2537,7 +2559,7 @@ function enrichRequestSize() {
2537
2559
  const request = Number(headerOf(req, "content-length"));
2538
2560
  if (Number.isFinite(request) && request >= 0)
2539
2561
  event.attributes["http.request.body.size"] = request;
2540
- const raw = _optionalChain([res, 'optionalAccess', _130 => _130.getHeader, 'optionalCall', _131 => _131(
2562
+ const raw = _optionalChain([res, 'optionalAccess', _134 => _134.getHeader, 'optionalCall', _135 => _135(
2541
2563
  "content-length"
2542
2564
  )]);
2543
2565
  const response = Number(raw);
@@ -2555,7 +2577,7 @@ var COUNTRY_HEADERS = [
2555
2577
  function enrichEdgeGeo() {
2556
2578
  return (event, { req }) => {
2557
2579
  for (const name of COUNTRY_HEADERS) {
2558
- const value = _optionalChain([headerOf, 'call', _132 => _132(req, name), 'optionalAccess', _133 => _133.trim, 'call', _134 => _134(), 'access', _135 => _135.toUpperCase, 'call', _136 => _136()]);
2580
+ const value = _optionalChain([headerOf, 'call', _136 => _136(req, name), 'optionalAccess', _137 => _137.trim, 'call', _138 => _138(), 'access', _139 => _139.toUpperCase, 'call', _140 => _140()]);
2559
2581
  if (value && /^[A-Z]{2}$/.test(value) && value !== "XX" && value !== "T1") {
2560
2582
  event.attributes["geo.country.iso_code"] = value;
2561
2583
  return;
@@ -2589,9 +2611,9 @@ var COMMIT_VARS = [
2589
2611
  "SOURCE_VERSION"
2590
2612
  ];
2591
2613
  function enrichDeployment(env = process.env) {
2592
- const pick = (names) => names.map((name) => _optionalChain([env, 'access', _137 => _137[name], 'optionalAccess', _138 => _138.trim, 'call', _139 => _139()])).find((value) => value);
2593
- const region = _optionalChain([pick, 'call', _140 => _140(REGION_VARS), 'optionalAccess', _141 => _141.slice, 'call', _142 => _142(0, 64)]);
2594
- const commit = _optionalChain([pick, 'call', _143 => _143(COMMIT_VARS), 'optionalAccess', _144 => _144.slice, 'call', _145 => _145(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)]);
2595
2617
  return (event) => {
2596
2618
  if (region) event.attributes["deployment.region"] = region;
2597
2619
  if (commit) event.attributes["deployment.commit"] = commit;
@@ -2652,4 +2674,4 @@ function enrichDeployment(env = process.env) {
2652
2674
 
2653
2675
 
2654
2676
 
2655
- exports.CODE_PATTERN = _chunkRV4MJNM2cjs.CODE_PATTERN; exports.COMPAT_MANIFEST = _chunkGYTQLITWcjs.COMPAT_MANIFEST; exports.INGESTER_VERSION_HEADER = _chunkGYTQLITWcjs.INGESTER_VERSION_HEADER; exports.RuntimeError = _chunkRV4MJNM2cjs.RuntimeError; exports.SDK_IDENTITY = _chunkGYTQLITWcjs.SDK_IDENTITY; exports.addBreadcrumb = _chunkRV4MJNM2cjs.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 = _chunkRV4MJNM2cjs.consoleSink; exports.createBrowserRelayFetchHandler = createBrowserRelayFetchHandler; exports.createBrowserRelayHandler = createBrowserRelayHandler; exports.createRuntimeLogger = _chunkRV4MJNM2cjs.createRuntimeLogger; exports.defineRuntimeErrors = _chunkRV4MJNM2cjs.defineRuntimeErrors; exports.emitLlmSelftestTrace = emitLlmSelftestTrace; exports.enrichDeployment = enrichDeployment; exports.enrichEdgeGeo = enrichEdgeGeo; exports.enrichRequestSize = enrichRequestSize; exports.enrichUserAgent = enrichUserAgent; exports.errorAttributes = _chunkRV4MJNM2cjs.errorAttributes; exports.evaluateCompat = _chunkGYTQLITWcjs.evaluateCompat; exports.fetchIngesterCompat = _chunkGYTQLITWcjs.fetchIngesterCompat; exports.fileSink = _chunkRV4MJNM2cjs.fileSink; exports.flushRuntimeLogs = _chunkRV4MJNM2cjs.flushRuntimeLogs; exports.initAutterLogging = initAutterLogging; exports.initAutterServer = initAutterServer; exports.installAutterAutoFlush = _chunkGYTQLITWcjs.installAutterAutoFlush; exports.instrumentLlmClient = instrumentLlmClient; exports.isRuntimeErrorLike = _chunkRV4MJNM2cjs.isRuntimeErrorLike; exports.makeSafeCapture = makeSafeCapture; exports.otlpSink = _chunkRV4MJNM2cjs.otlpSink; exports.redactAttributes = _chunkRV4MJNM2cjs.redactAttributes; exports.redactText = _chunkRV4MJNM2cjs.redactText; exports.reportOutcome = reportOutcome; exports.runDoctor = _chunkHKVFURYTcjs.runDoctor; exports.runInBackground = _chunkRV4MJNM2cjs.runInBackground; exports.runtimeContext = _chunkRV4MJNM2cjs.runtimeContext; exports.runtimeLogStats = _chunkRV4MJNM2cjs.runtimeLogStats; exports.runtimeLogger = _chunkRV4MJNM2cjs.runtimeLogger; exports.sanitizeBrowserPayload = sanitizeBrowserPayload; exports.startCaughtExceptionSampler = startCaughtExceptionSampler; exports.toClientError = _chunkRV4MJNM2cjs.toClientError; exports.trackLlmCall = trackLlmCall; exports.unhandledRejectionsMode = unhandledRejectionsMode; exports.withLlmCall = withLlmCall; exports.withProcessSpan = withProcessSpan; exports.withRuntimeOperation = _chunkRV4MJNM2cjs.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;