vona-core 5.1.32 → 5.1.34

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.js CHANGED
@@ -1564,19 +1564,19 @@ class BeanContainer {
1564
1564
  fn = function ([receiver, _], next) {
1565
1565
  const beanInstance = self.app.bean._getBean(aopMethod.beanFullName);
1566
1566
  if (!beanInstance.get) throw new Error(`get property accessor not exists: ${aopMethod.onionName}`);
1567
- return beanInstance.get(aopMethod.options, _patchAopNext([receiver, _], next), receiver, prop);
1567
+ return beanInstance.get(aopMethod.options, _patchAopMethodNext([receiver, _], next), receiver, prop);
1568
1568
  };
1569
1569
  } else if (methodType === 'set') {
1570
1570
  fn = function ([receiver, value], next) {
1571
1571
  const beanInstance = self.app.bean._getBean(aopMethod.beanFullName);
1572
1572
  if (!beanInstance.set) throw new Error(`set property accessor not exists: ${aopMethod.onionName}`);
1573
- return beanInstance.set(aopMethod.options, value, _patchAopNext([receiver, value], next), receiver, prop);
1573
+ return beanInstance.set(aopMethod.options, value, _patchAopMethodNext([receiver, value], next), receiver, prop);
1574
1574
  };
1575
1575
  } else if (methodType === 'method') {
1576
1576
  fn = function ([receiver, args], next) {
1577
1577
  const beanInstance = self.app.bean._getBean(aopMethod.beanFullName);
1578
1578
  if (!beanInstance.execute) throw new Error(`execute method not exists: ${aopMethod.onionName}`);
1579
- return beanInstance.execute(aopMethod.options, args, _patchAopNext([receiver, args], next), receiver, prop);
1579
+ return beanInstance.execute(aopMethod.options, args, _patchAopMethodNext([receiver, args], next), receiver, prop);
1580
1580
  };
1581
1581
  }
1582
1582
  chains.push([aopKey, fn]);
@@ -1602,6 +1602,17 @@ function _patchAopNext([receiver, context], next) {
1602
1602
  return next([receiver, context]);
1603
1603
  };
1604
1604
  }
1605
+ function _patchAopMethodNext([receiver, context], next) {
1606
+ const nextPatched = (...args) => {
1607
+ context = args.length === 0 ? context : args[0];
1608
+ return next([receiver, context]);
1609
+ };
1610
+ nextPatched.replay = (...args) => {
1611
+ const nextContext = args.length === 0 ? context : args[0];
1612
+ return next.replay([receiver, nextContext]);
1613
+ };
1614
+ return nextPatched;
1615
+ }
1605
1616
  function __checkAopOfDescriptorInfo(descriptorInfo) {
1606
1617
  if (!descriptorInfo) return true;
1607
1618
  return !descriptorInfo.dynamic && !descriptorInfo.ofBeanBase;
@@ -2789,9 +2800,18 @@ const formatLoggerErrors = opts => {
2789
2800
  };
2790
2801
  const formatLoggerCtx = Winston.format((info, _opts) => {
2791
2802
  const app = useApp();
2792
- if (!app.ctx || !app.ctx.method || !app.ctx.path) return info;
2793
- info.method = app.ctx.method;
2794
- info.path = app.ctx.path;
2803
+ if (!app.ctx) return info;
2804
+ if (app.ctx.method) info.method = app.ctx.method;
2805
+ if (app.ctx.path) info.path = app.ctx.path;
2806
+ const telemetry = app.ctx.state.telemetry;
2807
+ if (telemetry?.requestId) info.request_id = telemetry.requestId;
2808
+ const span = telemetry?.span ?? telemetry?.serverSpan;
2809
+ const spanContext = span?.spanContext();
2810
+ if (spanContext?.traceId && spanContext?.spanId) {
2811
+ info.trace_id = spanContext.traceId;
2812
+ info.span_id = spanContext.spanId;
2813
+ info.trace_flags = spanContext.traceFlags;
2814
+ }
2795
2815
  return info;
2796
2816
  });
2797
2817
  const formatLoggerDummy = Winston.format(info => {