@anyway-sh/node-server-sdk 0.22.8 → 0.22.9

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
@@ -90,7 +90,7 @@ class PromptNotFoundError extends TraceloopError {
90
90
  }
91
91
  }
92
92
 
93
- var version = "0.22.8";
93
+ var version = "0.22.9";
94
94
 
95
95
  /**
96
96
  * Base class for handling annotation operations with the Traceloop API.
@@ -3411,9 +3411,13 @@ const ensureSpanCompatibility = (span) => {
3411
3411
  const onSpanEnd = (originalOnEnd, instrumentationLibraries) => {
3412
3412
  return (span) => {
3413
3413
  var _a, _b, _c;
3414
+ const libName = ((_a = span.instrumentationScope) === null || _a === void 0 ? void 0 : _a.name) ||
3415
+ ((_b = span.instrumentationLibrary) === null || _b === void 0 ? void 0 : _b.name) ||
3416
+ "unknown";
3417
+ console.log(`[Anyway Debug] onSpanEnd: span="${span.name}" lib="${libName}"`);
3414
3418
  if (instrumentationLibraries &&
3415
- !instrumentationLibraries.includes(((_a = span.instrumentationScope) === null || _a === void 0 ? void 0 : _a.name) ||
3416
- ((_b = span.instrumentationLibrary) === null || _b === void 0 ? void 0 : _b.name))) {
3419
+ !instrumentationLibraries.includes(libName)) {
3420
+ console.log(`[Anyway Debug] Dropping span="${span.name}" - lib="${libName}" not in allowed list`);
3417
3421
  return;
3418
3422
  }
3419
3423
  transformAiSdkSpanAttributes(span);
@@ -3440,6 +3444,7 @@ const onSpanEnd = (originalOnEnd, instrumentationLibraries) => {
3440
3444
  cleanupExpiredSpanAgentNames();
3441
3445
  }
3442
3446
  const compatibleSpan = ensureSpanCompatibility(span);
3447
+ console.log(`[Anyway Debug] Span queued for export: "${span.name}" lib="${libName}"`);
3443
3448
  originalOnEnd(compatibleSpan);
3444
3449
  };
3445
3450
  };
@@ -3725,6 +3730,19 @@ const startTracing = (options) => {
3725
3730
  url: `${baseUrl}/v1/traces`,
3726
3731
  headers,
3727
3732
  }));
3733
+ // [Anyway Debug] Wrap exporter to log outgoing calls
3734
+ const origExport = traceExporter.export.bind(traceExporter);
3735
+ traceExporter.export = (spans, resultCallback) => {
3736
+ var _a, _b;
3737
+ console.log(`[Anyway Debug] Exporting ${spans.length} span(s) to ${baseUrl}/v1/traces`);
3738
+ for (const s of spans) {
3739
+ console.log(`[Anyway Debug] - ${s.name} (${((_a = s.instrumentationLibrary) === null || _a === void 0 ? void 0 : _a.name) || ((_b = s.instrumentationScope) === null || _b === void 0 ? void 0 : _b.name) || "unknown"})`);
3740
+ }
3741
+ return origExport(spans, (result) => {
3742
+ console.log(`[Anyway Debug] Export result: code=${result.code}${result.error ? ` error=${result.error.message}` : ""}`);
3743
+ resultCallback(result);
3744
+ });
3745
+ };
3728
3746
  _spanProcessor = createSpanProcessor({
3729
3747
  apiKey: options.apiKey,
3730
3748
  baseUrl: options.baseUrl,
@@ -3924,6 +3942,9 @@ const initialize = (options = {}) => {
3924
3942
  if (!options.silenceInitializationMessage) {
3925
3943
  console.log(`Traceloop exporting traces to ${_configuration.exporter ? "a custom exporter" : _configuration.baseUrl}`);
3926
3944
  }
3945
+ console.log(`[Anyway Debug] Trace endpoint: ${_configuration.baseUrl}/v1/traces`);
3946
+ console.log(`[Anyway Debug] API key present: ${!!_configuration.apiKey}`);
3947
+ console.log(`[Anyway Debug] Using custom exporter: ${!!_configuration.exporter}`);
3927
3948
  if (options.tracingEnabled === undefined || options.tracingEnabled) {
3928
3949
  if (options.logLevel) {
3929
3950
  api.diag.setLogger(new api.DiagConsoleLogger(), logLevelToOtelLogLevel(options.logLevel));