agent-inspect 6.31.2 → 6.31.3

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.
@@ -955,6 +955,11 @@ function exportOpenInference(tree, options) {
955
955
  function hexFrom2(seed, byteLen) {
956
956
  return crypto__default.default.createHash("sha256").update(seed, "utf8").digest("hex").slice(0, byteLen * 2);
957
957
  }
958
+ function unixNano2(ms) {
959
+ const whole = Math.trunc(ms);
960
+ const fractionNs = Math.round((ms - whole) * 1e6);
961
+ return BigInt(whole) * 1000000n + BigInt(fractionNs);
962
+ }
958
963
  function stringAttr(key, value) {
959
964
  return { key, value: { stringValue: value } };
960
965
  }
@@ -988,10 +993,10 @@ function exportOtlpJson(tree, options) {
988
993
  const ev = n.event;
989
994
  const spanId = hexFrom2(`${tree.runId}:${ev.eventId}`, 8);
990
995
  const parentSpanId = ev.parentId ? hexFrom2(`${tree.runId}:${ev.parentId}`, 8) : void 0;
991
- const startNs = String(Math.round(ev.timestamp * 1e6));
996
+ const startNs = String(unixNano2(ev.timestamp));
992
997
  let endNs;
993
998
  if (ev.durationMs !== void 0 && Number.isFinite(ev.durationMs)) {
994
- endNs = String(Math.round(ev.timestamp * 1e6 + ev.durationMs * 1e6));
999
+ endNs = String(unixNano2(ev.timestamp) + unixNano2(ev.durationMs));
995
1000
  }
996
1001
  const attrs = [
997
1002
  stringAttr("agent_inspect.kind", ev.kind),