netra-sdk 1.8.0 → 1.9.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.d.cts CHANGED
@@ -11,7 +11,6 @@ interface NetraConfig {
11
11
  disableBatch?: boolean;
12
12
  traceContent?: boolean;
13
13
  debugMode?: boolean;
14
- enableRootSpan?: boolean;
15
14
  resourceAttributes?: Record<string, any>;
16
15
  environment?: string;
17
16
  enableScrubbing?: boolean;
@@ -33,10 +32,8 @@ interface NetraConfig {
33
32
  * link is remote (cross-process) is kept as a root so an upstream distributed
34
33
  * trace is not severed.
35
34
  *
36
- * Note: when `enableRootSpan` is true, Netra attaches its own root span and
37
- * every auto-instrumentation span becomes its child, so no reparenting
38
- * occurs. Pass a set containing `NetraInstruments.ALL` to allow all
39
- * instrumentations to produce root spans (legacy behaviour).
35
+ * Pass a set containing `NetraInstruments.ALL` to allow all instrumentations
36
+ * to produce root spans (legacy behaviour).
40
37
  */
41
38
  rootInstruments?: Set<NetraInstruments>;
42
39
  }
@@ -82,6 +79,8 @@ declare class Config {
82
79
  static readonly LIBRARY_NAME = "netra";
83
80
  static readonly LIBRARY_VERSION = "1.8.0";
84
81
  static readonly TRIAL_BLOCK_DURATION_SECONDS = 900;
82
+ static readonly TRACE_ORIGIN_KEY = "netra.trace.origin";
83
+ static readonly TRACE_ORIGIN_EVALUATION = "evaluation";
85
84
  private static _spanAttributeMaxSize;
86
85
  /**
87
86
  * Lazily reads NETRA_SPAN_ATTRIBUTE_MAX_SIZE from process.env on first
@@ -96,7 +95,6 @@ declare class Config {
96
95
  disableBatch: boolean;
97
96
  traceContent: boolean;
98
97
  debugMode: boolean;
99
- enableRootSpan: boolean;
100
98
  enableScrubbing: boolean;
101
99
  environment: string;
102
100
  resourceAttributes: Record<string, any>;
@@ -821,6 +819,39 @@ interface SessionStatsData {
821
819
  session_duration: string;
822
820
  cursor: string;
823
821
  }
822
+ interface SessionDetailsToolCall {
823
+ toolName: string;
824
+ toolCallCount: number;
825
+ }
826
+ interface SessionDetailsTrace {
827
+ traceId: string;
828
+ traceName: string;
829
+ startTime: string;
830
+ endTime: string;
831
+ latencyMs: number;
832
+ input: string | null;
833
+ output: string | null;
834
+ tokens: {
835
+ promptTokens: number;
836
+ completionTokens: number;
837
+ cachedTokens: number;
838
+ cacheCreationTokens: number;
839
+ totalTokens: number;
840
+ };
841
+ cost: {
842
+ promptTokensCost: number;
843
+ completionTokensCost: number;
844
+ cachedTokensCost: number;
845
+ cacheCreationTokensCost: number;
846
+ totalCost: number;
847
+ };
848
+ models: string[];
849
+ toolCalls: SessionDetailsToolCall[];
850
+ }
851
+ interface SessionDetailsResponse {
852
+ sessionId: string;
853
+ traces: SessionDetailsTrace[];
854
+ }
824
855
 
825
856
  /**
826
857
  * Public Dashboard API
@@ -840,6 +871,7 @@ declare class Dashboard {
840
871
  getSessionStats(startTime: string, endTime: string, limit?: number, filters?: SessionFilter[], cursor?: string, sortField?: SortField, sortOrder?: SortOrder): Promise<SessionStatsResult | null>;
841
872
  iterSessionStats(startTime: string, endTime: string, filters?: SessionFilter[], sortField?: SortField, sortOrder?: SortOrder): AsyncGenerator<SessionStatsData, void, unknown>;
842
873
  getSessionSummary(filter: SessionFilterConfig): Promise<any | null>;
874
+ getSessionDetails(sessionId: string): Promise<SessionDetailsResponse | null>;
843
875
  private isValidScope;
844
876
  private isValidChartType;
845
877
  private isValidMetrics;
@@ -1752,7 +1784,6 @@ declare class Netra {
1752
1784
  private static _initialized;
1753
1785
  private static _config;
1754
1786
  private static _tracer;
1755
- private static _rootSpan;
1756
1787
  private static _metricsEnabled;
1757
1788
  static usage: Usage;
1758
1789
  static evaluation: Evaluation;
@@ -1768,12 +1799,6 @@ declare class Netra {
1768
1799
  static setOutput(value: any): void;
1769
1800
  static setRootInput(value: any): void;
1770
1801
  static setRootOutput(value: any): void;
1771
- /**
1772
- * Run a function with the root span as the active parent context.
1773
- * All spans created within this function will be children of the root span.
1774
- * Note: required in JS because OTel JS has no persistent context.attach()
1775
- */
1776
- static runWithRootSpan<T>(fn: () => T): T;
1777
1802
  static setSessionId(sessionId: string): void;
1778
1803
  /**
1779
1804
  * Set user_id context attributes for all spans.
@@ -1804,4 +1829,4 @@ declare class Netra {
1804
1829
  static withBlockedSpansLocal: typeof withBlockedSpansLocal;
1805
1830
  }
1806
1831
 
1807
- export { type ActionModel, type AfterAllFn, type AfterFn, Aggregation, BaseTask, type BeforeAllFn, type BeforeFn, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, DEFAULT_INSTRUMENTS, DEFAULT_INSTRUMENTS_FOR_ROOT, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetPromptParams, GroupBy, type InitializeRunResult, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, type ProcessedFile, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, type SafeStringifyOptions, Scope, ScrubbingSpanProcessor, SerializationSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationHooks, type SimulationItem, type SimulationOptions, type SimulationResult, SpanIOProcessor, type SpanOptions, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, TruncatingSerializer, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, safeStringify, span, task, workflow };
1832
+ export { type ActionModel, type AfterAllFn, type AfterFn, Aggregation, BaseTask, type BeforeAllFn, type BeforeFn, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, DEFAULT_INSTRUMENTS, DEFAULT_INSTRUMENTS_FOR_ROOT, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetPromptParams, GroupBy, type InitializeRunResult, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, type ProcessedFile, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, type SafeStringifyOptions, Scope, ScrubbingSpanProcessor, SerializationSpanProcessor, type SessionDetailsResponse, type SessionDetailsToolCall, type SessionDetailsTrace, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationHooks, type SimulationItem, type SimulationOptions, type SimulationResult, SpanIOProcessor, type SpanOptions, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, TruncatingSerializer, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, safeStringify, span, task, workflow };
package/dist/index.d.ts CHANGED
@@ -11,7 +11,6 @@ interface NetraConfig {
11
11
  disableBatch?: boolean;
12
12
  traceContent?: boolean;
13
13
  debugMode?: boolean;
14
- enableRootSpan?: boolean;
15
14
  resourceAttributes?: Record<string, any>;
16
15
  environment?: string;
17
16
  enableScrubbing?: boolean;
@@ -33,10 +32,8 @@ interface NetraConfig {
33
32
  * link is remote (cross-process) is kept as a root so an upstream distributed
34
33
  * trace is not severed.
35
34
  *
36
- * Note: when `enableRootSpan` is true, Netra attaches its own root span and
37
- * every auto-instrumentation span becomes its child, so no reparenting
38
- * occurs. Pass a set containing `NetraInstruments.ALL` to allow all
39
- * instrumentations to produce root spans (legacy behaviour).
35
+ * Pass a set containing `NetraInstruments.ALL` to allow all instrumentations
36
+ * to produce root spans (legacy behaviour).
40
37
  */
41
38
  rootInstruments?: Set<NetraInstruments>;
42
39
  }
@@ -82,6 +79,8 @@ declare class Config {
82
79
  static readonly LIBRARY_NAME = "netra";
83
80
  static readonly LIBRARY_VERSION = "1.8.0";
84
81
  static readonly TRIAL_BLOCK_DURATION_SECONDS = 900;
82
+ static readonly TRACE_ORIGIN_KEY = "netra.trace.origin";
83
+ static readonly TRACE_ORIGIN_EVALUATION = "evaluation";
85
84
  private static _spanAttributeMaxSize;
86
85
  /**
87
86
  * Lazily reads NETRA_SPAN_ATTRIBUTE_MAX_SIZE from process.env on first
@@ -96,7 +95,6 @@ declare class Config {
96
95
  disableBatch: boolean;
97
96
  traceContent: boolean;
98
97
  debugMode: boolean;
99
- enableRootSpan: boolean;
100
98
  enableScrubbing: boolean;
101
99
  environment: string;
102
100
  resourceAttributes: Record<string, any>;
@@ -821,6 +819,39 @@ interface SessionStatsData {
821
819
  session_duration: string;
822
820
  cursor: string;
823
821
  }
822
+ interface SessionDetailsToolCall {
823
+ toolName: string;
824
+ toolCallCount: number;
825
+ }
826
+ interface SessionDetailsTrace {
827
+ traceId: string;
828
+ traceName: string;
829
+ startTime: string;
830
+ endTime: string;
831
+ latencyMs: number;
832
+ input: string | null;
833
+ output: string | null;
834
+ tokens: {
835
+ promptTokens: number;
836
+ completionTokens: number;
837
+ cachedTokens: number;
838
+ cacheCreationTokens: number;
839
+ totalTokens: number;
840
+ };
841
+ cost: {
842
+ promptTokensCost: number;
843
+ completionTokensCost: number;
844
+ cachedTokensCost: number;
845
+ cacheCreationTokensCost: number;
846
+ totalCost: number;
847
+ };
848
+ models: string[];
849
+ toolCalls: SessionDetailsToolCall[];
850
+ }
851
+ interface SessionDetailsResponse {
852
+ sessionId: string;
853
+ traces: SessionDetailsTrace[];
854
+ }
824
855
 
825
856
  /**
826
857
  * Public Dashboard API
@@ -840,6 +871,7 @@ declare class Dashboard {
840
871
  getSessionStats(startTime: string, endTime: string, limit?: number, filters?: SessionFilter[], cursor?: string, sortField?: SortField, sortOrder?: SortOrder): Promise<SessionStatsResult | null>;
841
872
  iterSessionStats(startTime: string, endTime: string, filters?: SessionFilter[], sortField?: SortField, sortOrder?: SortOrder): AsyncGenerator<SessionStatsData, void, unknown>;
842
873
  getSessionSummary(filter: SessionFilterConfig): Promise<any | null>;
874
+ getSessionDetails(sessionId: string): Promise<SessionDetailsResponse | null>;
843
875
  private isValidScope;
844
876
  private isValidChartType;
845
877
  private isValidMetrics;
@@ -1752,7 +1784,6 @@ declare class Netra {
1752
1784
  private static _initialized;
1753
1785
  private static _config;
1754
1786
  private static _tracer;
1755
- private static _rootSpan;
1756
1787
  private static _metricsEnabled;
1757
1788
  static usage: Usage;
1758
1789
  static evaluation: Evaluation;
@@ -1768,12 +1799,6 @@ declare class Netra {
1768
1799
  static setOutput(value: any): void;
1769
1800
  static setRootInput(value: any): void;
1770
1801
  static setRootOutput(value: any): void;
1771
- /**
1772
- * Run a function with the root span as the active parent context.
1773
- * All spans created within this function will be children of the root span.
1774
- * Note: required in JS because OTel JS has no persistent context.attach()
1775
- */
1776
- static runWithRootSpan<T>(fn: () => T): T;
1777
1802
  static setSessionId(sessionId: string): void;
1778
1803
  /**
1779
1804
  * Set user_id context attributes for all spans.
@@ -1804,4 +1829,4 @@ declare class Netra {
1804
1829
  static withBlockedSpansLocal: typeof withBlockedSpansLocal;
1805
1830
  }
1806
1831
 
1807
- export { type ActionModel, type AfterAllFn, type AfterFn, Aggregation, BaseTask, type BeforeAllFn, type BeforeFn, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, DEFAULT_INSTRUMENTS, DEFAULT_INSTRUMENTS_FOR_ROOT, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetPromptParams, GroupBy, type InitializeRunResult, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, type ProcessedFile, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, type SafeStringifyOptions, Scope, ScrubbingSpanProcessor, SerializationSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationHooks, type SimulationItem, type SimulationOptions, type SimulationResult, SpanIOProcessor, type SpanOptions, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, TruncatingSerializer, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, safeStringify, span, task, workflow };
1832
+ export { type ActionModel, type AfterAllFn, type AfterFn, Aggregation, BaseTask, type BeforeAllFn, type BeforeFn, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, DEFAULT_INSTRUMENTS, DEFAULT_INSTRUMENTS_FOR_ROOT, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetPromptParams, GroupBy, type InitializeRunResult, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, type ProcessedFile, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, type SafeStringifyOptions, Scope, ScrubbingSpanProcessor, SerializationSpanProcessor, type SessionDetailsResponse, type SessionDetailsToolCall, type SessionDetailsTrace, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationHooks, type SimulationItem, type SimulationOptions, type SimulationResult, SpanIOProcessor, type SpanOptions, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, TruncatingSerializer, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, safeStringify, span, task, workflow };
package/dist/index.js CHANGED
@@ -669,11 +669,6 @@ var _Config = class _Config {
669
669
  "NETRA_DEBUG",
670
670
  false
671
671
  );
672
- this.enableRootSpan = this._getBoolConfig(
673
- config.enableRootSpan,
674
- "NETRA_ENABLE_ROOT_SPAN",
675
- false
676
- );
677
672
  this.enableScrubbing = this._getBoolConfig(
678
673
  config.enableScrubbing,
679
674
  "NETRA_ENABLE_SCRUBBING",
@@ -823,6 +818,11 @@ _Config.SDK_NAME = "netra";
823
818
  _Config.LIBRARY_NAME = "netra";
824
819
  _Config.LIBRARY_VERSION = SDK_VERSION;
825
820
  _Config.TRIAL_BLOCK_DURATION_SECONDS = 900;
821
+ // 15 minutes
822
+ // Root-span attribute marking traces produced by evaluation/simulation runs
823
+ // so the FE/BE can distinguish them from normal workflow invocations.
824
+ _Config.TRACE_ORIGIN_KEY = "netra.trace.origin";
825
+ _Config.TRACE_ORIGIN_EVALUATION = "evaluation";
826
826
  var Config = _Config;
827
827
 
828
828
  // src/utils/pattern-matching.ts
@@ -1943,13 +1943,13 @@ async function runSingleEvaluator(params) {
1943
1943
  if (config) {
1944
1944
  expectedName = config.name;
1945
1945
  }
1946
- const context17 = {
1946
+ const context16 = {
1947
1947
  input: itemInput,
1948
1948
  taskOutput,
1949
1949
  expectedOutput,
1950
1950
  metadata
1951
1951
  };
1952
- let result = evaluator.evaluate(context17);
1952
+ let result = evaluator.evaluate(context16);
1953
1953
  if (result instanceof Promise) {
1954
1954
  result = await result;
1955
1955
  }
@@ -2293,7 +2293,11 @@ var Evaluation = class {
2293
2293
  */
2294
2294
  async executeItemPipeline(runId, runName, ctx, task2, evaluators, results, bgEvalTasks) {
2295
2295
  const spanName = `TestRun.${runName}`;
2296
- const span2 = new SpanWrapper(spanName, {}, "netra.evaluation");
2296
+ const span2 = new SpanWrapper(
2297
+ spanName,
2298
+ { [Config.TRACE_ORIGIN_KEY]: Config.TRACE_ORIGIN_EVALUATION },
2299
+ "netra.evaluation"
2300
+ );
2297
2301
  span2.start();
2298
2302
  try {
2299
2303
  const otelSpan = span2.getCurrentSpan();
@@ -2696,6 +2700,42 @@ var DashboardHttpClient = class extends NetraHttpClient {
2696
2700
  return null;
2697
2701
  }
2698
2702
  }
2703
+ /**
2704
+ * Get detailed information for a specific session including all its traces.
2705
+ *
2706
+ * Args:
2707
+ * sessionId: The session ID to retrieve details for.
2708
+ *
2709
+ * Returns:
2710
+ * The session details response data or null on error.
2711
+ */
2712
+ async getSessionDetails(sessionId) {
2713
+ if (!this.isInitialized()) {
2714
+ Logger.error(
2715
+ "netra.dashboard: Dashboard client is not initialized; cannot get session details"
2716
+ );
2717
+ return null;
2718
+ }
2719
+ try {
2720
+ const url = `/public/dashboard/session/${encodeURIComponent(sessionId)}`;
2721
+ const response = await this.get(url);
2722
+ if (!response.ok) {
2723
+ const errorMessage = response.data?.error?.message ?? "Unknown error";
2724
+ Logger.error(
2725
+ `netra.dashboard: Failed to fetch session details: ${errorMessage}`
2726
+ );
2727
+ return null;
2728
+ }
2729
+ return response.data;
2730
+ } catch (err) {
2731
+ const message = err?.response?.data?.error?.message ?? "";
2732
+ Logger.error(
2733
+ "netra.dashboard: Failed to fetch session details:",
2734
+ message
2735
+ );
2736
+ return null;
2737
+ }
2738
+ }
2699
2739
  };
2700
2740
 
2701
2741
  // src/api/dashboard/models.ts
@@ -2919,6 +2959,19 @@ var Dashboard = class {
2919
2959
  }
2920
2960
  return result.data ?? {};
2921
2961
  }
2962
+ async getSessionDetails(sessionId) {
2963
+ if (!sessionId) {
2964
+ Logger.error(
2965
+ "netra.dashboard: session_id is required to fetch session details"
2966
+ );
2967
+ return null;
2968
+ }
2969
+ const result = await this.client.getSessionDetails(sessionId);
2970
+ if (!result) {
2971
+ return null;
2972
+ }
2973
+ return result.data ?? result;
2974
+ }
2922
2975
  isValidScope(scope) {
2923
2976
  return Object.values(Scope).includes(scope);
2924
2977
  }
@@ -3834,6 +3887,13 @@ var SpanIOProcessor = class {
3834
3887
  if (key === _USAGE_OUTPUT_TOKENS) {
3835
3888
  return original(_USAGE_COMPLETION_TOKENS, value);
3836
3889
  }
3890
+ if (key === "db.statement") {
3891
+ original(key, value);
3892
+ if (!inputLocked() && inputIsEmpty() && !isEmpty(value)) {
3893
+ original("input", typeof value === "string" ? value : String(value));
3894
+ }
3895
+ return span2;
3896
+ }
3837
3897
  return original(key, value);
3838
3898
  } catch (e) {
3839
3899
  Logger.debug(`SpanIOProcessor: error processing key=${key}`, e);
@@ -4414,7 +4474,7 @@ function setUsageAttributes(span2, response) {
4414
4474
  Number(cacheReadTokens)
4415
4475
  );
4416
4476
  }
4417
- const cacheCreationTokens = usage.cache_creation_input_tokens;
4477
+ const cacheCreationTokens = usage.cache_creation_input_tokens ?? (usage.prompt_tokens_details ?? usage.input_tokens_details)?.cache_write_tokens;
4418
4478
  if (cacheCreationTokens !== void 0) {
4419
4479
  span2.setAttribute(
4420
4480
  SpanAttributes2.LLM_USAGE_CACHE_CREATION_INPUT_TOKENS,
@@ -12359,7 +12419,7 @@ var SimulationHttpClient = class {
12359
12419
  * Used in the two-phase flow so that beforeAll/before hooks can run
12360
12420
  * before any LLM spend.
12361
12421
  */
12362
- async initializeRun(name, datasetId, context17, hooksMeta) {
12422
+ async initializeRun(name, datasetId, context16, hooksMeta) {
12363
12423
  if (!this.client) {
12364
12424
  Logger.error(`${LOG_PREFIX5}: Client not initialized`);
12365
12425
  return null;
@@ -12369,7 +12429,7 @@ var SimulationHttpClient = class {
12369
12429
  const payload = {
12370
12430
  name,
12371
12431
  datasetId,
12372
- context: context17 || {}
12432
+ context: context16 || {}
12373
12433
  };
12374
12434
  if (hooksMeta) {
12375
12435
  payload.lifecycleHooks = hooksMeta;
@@ -12687,7 +12747,7 @@ var Simulation = class {
12687
12747
  name,
12688
12748
  datasetId,
12689
12749
  task: task2,
12690
- context: context17,
12750
+ context: context16,
12691
12751
  maxConcurrency = 5,
12692
12752
  hooks
12693
12753
  } = options;
@@ -12699,7 +12759,7 @@ var Simulation = class {
12699
12759
  const initResult = await this._client.initializeRun(
12700
12760
  name,
12701
12761
  datasetId,
12702
- context17,
12762
+ context16,
12703
12763
  hooksMeta && Object.keys(hooksMeta).length > 0 ? hooksMeta : null
12704
12764
  );
12705
12765
  if (!initResult) {
@@ -13000,7 +13060,11 @@ var Simulation = class {
13000
13060
  let sessionId = null;
13001
13061
  let rawFiles = initialFiles ?? [];
13002
13062
  while (true) {
13003
- const span2 = new SpanWrapper(SPAN_NAME, {}, LOG_PREFIX7);
13063
+ const span2 = new SpanWrapper(
13064
+ SPAN_NAME,
13065
+ { [Config.TRACE_ORIGIN_KEY]: Config.TRACE_ORIGIN_EVALUATION },
13066
+ LOG_PREFIX7
13067
+ );
13004
13068
  span2.start();
13005
13069
  try {
13006
13070
  const traceId = span2.getCurrentSpan()?.spanContext().traceId ?? "";
@@ -13340,26 +13404,6 @@ Received ${signal}. Shutting down Netra SDK...`);
13340
13404
  process.once("SIGINT", () => handleSignal("SIGINT"));
13341
13405
  process.once("SIGTERM", () => handleSignal("SIGTERM"));
13342
13406
  process.once("uncaughtException", handleUncaughtException);
13343
- if (cfg.enableRootSpan) {
13344
- const tracer2 = this._tracer || trace.getTracer("netra.root.span");
13345
- const rootName = `${Config.LIBRARY_NAME}.root.span`;
13346
- this._rootSpan = tracer2.startSpan(rootName, {
13347
- kind: SpanKind.INTERNAL
13348
- });
13349
- if (this._rootSpan) {
13350
- if (cfg.appName) {
13351
- this._rootSpan.setAttribute("service.name", cfg.appName);
13352
- }
13353
- this._rootSpan.setAttribute("netra.environment", cfg.environment);
13354
- this._rootSpan.setAttribute(
13355
- "netra.library.version",
13356
- Config.LIBRARY_VERSION
13357
- );
13358
- Logger.info(
13359
- "Netra root span created. Use Netra.runWithRootSpan() to parent spans under it."
13360
- );
13361
- }
13362
- }
13363
13407
  await instrumentationsReady;
13364
13408
  }
13365
13409
  static async shutdown() {
@@ -13371,14 +13415,6 @@ Received ${signal}. Shutting down Netra SDK...`);
13371
13415
  } catch (e) {
13372
13416
  Logger.error("Error during uninstrumentAll:", e);
13373
13417
  }
13374
- if (this._rootSpan) {
13375
- try {
13376
- this._rootSpan.end();
13377
- } catch (e) {
13378
- } finally {
13379
- this._rootSpan = void 0;
13380
- }
13381
- }
13382
13418
  const FLUSH_TIMEOUT_MS = 5e3;
13383
13419
  try {
13384
13420
  const traceProvider = trace.getTracerProvider();
@@ -13415,20 +13451,6 @@ Received ${signal}. Shutting down Netra SDK...`);
13415
13451
  static setRootOutput(value) {
13416
13452
  SessionManager.setRootOutput(value);
13417
13453
  }
13418
- /**
13419
- * Run a function with the root span as the active parent context.
13420
- * All spans created within this function will be children of the root span.
13421
- * Note: required in JS because OTel JS has no persistent context.attach()
13422
- */
13423
- static runWithRootSpan(fn) {
13424
- if (!this._rootSpan) {
13425
- Logger.warn(
13426
- "runWithRootSpan: No root span available. Running function without parent context."
13427
- );
13428
- return fn();
13429
- }
13430
- return context.with(trace.setSpan(context.active(), this._rootSpan), fn);
13431
- }
13432
13454
  static setSessionId(sessionId) {
13433
13455
  if (typeof sessionId !== "string") {
13434
13456
  Logger.error(`setSessionId: sessionId must be a string, got ${typeof sessionId}`);