@narumitw/pi-otel 0.54.3 → 0.55.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.ts CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  getLangfuseRuntimeInternal,
7
7
  normalizeOtlpConnection,
8
8
  otlpSecrets
9
- } from "./chunks/chunk-DSQBXICE.ts";
9
+ } from "./chunks/chunk-IXR5MVGN.ts";
10
10
 
11
11
  // src/otel.ts
12
12
  import { stripVTControlCharacters } from "node:util";
@@ -631,7 +631,7 @@ var TraceRecorder = class {
631
631
  ...mismatched && outcome === "success" ? {
632
632
  level: "WARNING",
633
633
  statusMessage: `Turn ${turnIndex} ended while turn ${this.turnIndex} was active.`
634
- } : severityForOutcome(outcome, result.message.errorMessage)
634
+ } : severityForOutcome(outcome, this.captureErrorMessage(result.message.errorMessage))
635
635
  });
636
636
  this.turn.end();
637
637
  this.turn = void 0;
@@ -729,7 +729,7 @@ var TraceRecorder = class {
729
729
  ...finiteNumber(message.usage?.reasoning) ? { "pi.usage.reasoning_tokens": message.usage.reasoning } : {},
730
730
  ...finiteNumber(message.usage?.cacheWrite1h) ? { "pi.usage.cache_write_1h_tokens": message.usage.cacheWrite1h } : {}
731
731
  },
732
- ...severityForOutcome(outcome, message.errorMessage)
732
+ ...severityForOutcome(outcome, this.captureErrorMessage(message.errorMessage))
733
733
  });
734
734
  state.observation.end(state.endTime);
735
735
  this.generation = void 0;
@@ -885,7 +885,7 @@ var TraceRecorder = class {
885
885
  const finalAttributes = {
886
886
  ...this.lastOutput !== void 0 ? { output: this.lastOutput } : {},
887
887
  metadata: finalMetadata,
888
- ...severityForOutcome(baseOutcome, statusMessage ?? this.lastAssistant?.errorMessage)
888
+ ...severityForOutcome(baseOutcome, statusMessage ?? this.captureErrorMessage(this.lastAssistant?.errorMessage))
889
889
  };
890
890
  this.root.update(finalAttributes);
891
891
  this.root.updateTrace?.({
@@ -915,7 +915,7 @@ var TraceRecorder = class {
915
915
  "pi.attempt.outcome": outcome,
916
916
  ...message?.stopReason ? { "pi.attempt.stop_reason": message.stopReason } : {}
917
917
  },
918
- ...severityForOutcome(outcome, statusMessage ?? message?.errorMessage)
918
+ ...severityForOutcome(outcome, statusMessage ?? this.captureErrorMessage(message?.errorMessage))
919
919
  });
920
920
  this.attempt.end();
921
921
  this.attempt = void 0;
@@ -977,6 +977,10 @@ var TraceRecorder = class {
977
977
  this.compaction.observation.end();
978
978
  this.compaction = void 0;
979
979
  }
980
+ captureErrorMessage(message) {
981
+ if (!this.context.captureContent || typeof message !== "string") return void 0;
982
+ return String(sanitizeTraceValue(message));
983
+ }
980
984
  capture(value) {
981
985
  return this.context.captureContent ? sanitizeTraceValue(value) : CONTENT_DISABLED;
982
986
  }
@@ -1594,7 +1598,7 @@ function createOtelExtension(dependencies = {}) {
1594
1598
  if (createBackend) {
1595
1599
  runtime = createLangfuseRuntimeFromBackend(await createBackend(config));
1596
1600
  } else {
1597
- const { createLangfuseRuntime: createLangfuseRuntime2, createOtelRuntime: createOtelRuntime2 } = await import("./chunks/runtime-X3YFJUNH.ts");
1601
+ const { createLangfuseRuntime: createLangfuseRuntime2, createOtelRuntime: createOtelRuntime2 } = await import("./chunks/runtime-KWIFBNQ2.ts");
1598
1602
  if (!isCurrent()) return void 0;
1599
1603
  runtime = await (config.backend === "otlp" ? createOtelRuntime2(config) : createLangfuseRuntime2({ config, env: false }));
1600
1604
  }
@@ -1858,11 +1862,11 @@ var otel_default = createOtelExtension();
1858
1862
 
1859
1863
  // src/runtime-api.ts
1860
1864
  async function createLangfuseRuntime(options = {}) {
1861
- const runtime = await import("./chunks/runtime-X3YFJUNH.ts");
1865
+ const runtime = await import("./chunks/runtime-KWIFBNQ2.ts");
1862
1866
  return runtime.createLangfuseRuntime(options);
1863
1867
  }
1864
1868
  async function createOtelRuntime(config) {
1865
- const runtime = await import("./chunks/runtime-X3YFJUNH.ts");
1869
+ const runtime = await import("./chunks/runtime-KWIFBNQ2.ts");
1866
1870
  return runtime.createOtelRuntime(config);
1867
1871
  }
1868
1872
  export {