From c03d9e0634bb22db4b76ca14595995273657c4d8 Mon Sep 17 00:00:00 2001 From: A-Vamshi Date: Mon, 29 Jun 2026 16:53:42 +0530 Subject: [PATCH 1/2] add test_run_id support --- deepeval/tracing/api.py | 1 + deepeval/tracing/context.py | 3 +++ deepeval/tracing/otel/exporter.py | 7 +++++++ deepeval/tracing/tracing.py | 1 + deepeval/tracing/types.py | 1 + 5 files changed, 13 insertions(+) diff --git a/deepeval/tracing/api.py b/deepeval/tracing/api.py index 27c6b5f3c1..92616692a8 100644 --- a/deepeval/tracing/api.py +++ b/deepeval/tracing/api.py @@ -148,6 +148,7 @@ class TraceApi(BaseModel): output: Optional[Any] = Field(None) status: Optional[TraceSpanApiStatus] = Field(TraceSpanApiStatus.SUCCESS) test_case_id: Optional[str] = Field(None, alias="testCaseId") + test_run_id: Optional[str] = Field(None, alias="testRunId") turn_id: Optional[str] = Field(None, alias="turnId") # additional test case parameters diff --git a/deepeval/tracing/context.py b/deepeval/tracing/context.py index 811c601b34..ae5a9a594d 100644 --- a/deepeval/tracing/context.py +++ b/deepeval/tracing/context.py @@ -133,6 +133,7 @@ def update_current_trace( test_case: Optional[LLMTestCase] = None, confident_api_key: Optional[str] = None, test_case_id: Optional[str] = None, + test_run_id: Optional[str] = None, turn_id: Optional[str] = None, metric_collection: Optional[str] = None, metrics: Optional[List[BaseMetric]] = None, @@ -176,6 +177,8 @@ def update_current_trace( current_trace.confident_api_key = confident_api_key if test_case_id: current_trace.test_case_id = test_case_id + if test_run_id: + current_trace.test_run_id = test_run_id if turn_id: current_trace.turn_id = turn_id if metric_collection: diff --git a/deepeval/tracing/otel/exporter.py b/deepeval/tracing/otel/exporter.py index 1e732cafd2..121d71324f 100644 --- a/deepeval/tracing/otel/exporter.py +++ b/deepeval/tracing/otel/exporter.py @@ -89,6 +89,7 @@ class BaseSpanWrapper: trace_tools_called: Optional[List[ToolCall]] = None trace_expected_tools: Optional[List[ToolCall]] = None trace_test_case_id: Optional[str] = None + trace_test_run_id: Optional[str] = None trace_turn_id: Optional[str] = None trace_metric_collection: Optional[str] = None trace_environment: Optional[str] = None @@ -325,6 +326,10 @@ def _set_current_trace_attributes_from_base_span_wrapper( base_span_wrapper.trace_test_case_id, str ): current_trace.test_case_id = base_span_wrapper.trace_test_case_id + if base_span_wrapper.trace_test_run_id and isinstance( + base_span_wrapper.trace_test_run_id, str + ): + current_trace.test_run_id = base_span_wrapper.trace_test_run_id if base_span_wrapper.trace_turn_id and isinstance( base_span_wrapper.trace_turn_id, str ): @@ -427,6 +432,7 @@ def __set_trace_attributes( raw_trace_expected_tools = list(raw_trace_expected_tools) trace_test_case_id = span.attributes.get("confident.trace.test_case_id") + trace_test_run_id = span.attributes.get("confident.trace.test_run_id") trace_turn_id = span.attributes.get("confident.trace.turn_id") raw_trace_metric_collection = span.attributes.get( @@ -460,6 +466,7 @@ def __set_trace_attributes( base_span_wrapper.trace_tools_called = trace_tools_called base_span_wrapper.trace_expected_tools = trace_expected_tools base_span_wrapper.trace_test_case_id = trace_test_case_id + base_span_wrapper.trace_test_run_id = trace_test_run_id base_span_wrapper.trace_turn_id = trace_turn_id base_span_wrapper.trace_metric_collection = trace_metric_collection base_span_wrapper.trace_environment = trace_environment diff --git a/deepeval/tracing/tracing.py b/deepeval/tracing/tracing.py index ddf6c0627c..2cc5c7690e 100644 --- a/deepeval/tracing/tracing.py +++ b/deepeval/tracing/tracing.py @@ -877,6 +877,7 @@ def create_trace_api(self, trace: Trace) -> TraceApi: toolsCalled=trace.tools_called, expectedTools=trace.expected_tools, testCaseId=trace.test_case_id, + testRunId=trace.test_run_id, turnId=trace.turn_id, confident_api_key=trace.confident_api_key, environment=( diff --git a/deepeval/tracing/types.py b/deepeval/tracing/types.py index 6980b16586..6ae5d4ebef 100644 --- a/deepeval/tracing/types.py +++ b/deepeval/tracing/types.py @@ -197,6 +197,7 @@ class Trace(BaseModel): metrics: Optional[List[BaseMetric]] = None metric_collection: Optional[str] = None test_case_id: Optional[str] = Field(None, serialization_alias="testCaseId") + test_run_id: Optional[str] = Field(None, serialization_alias="testRunId") turn_id: Optional[str] = Field(None, serialization_alias="turnId") # Don't serialize these From 3898ea53f1fe1ea609ea4a3588b025cbd5ba0836 Mon Sep 17 00:00:00 2001 From: A-Vamshi Date: Mon, 29 Jun 2026 16:55:45 +0530 Subject: [PATCH 2/2] . --- typescript/src/tracing/api.ts | 1 + typescript/src/tracing/tracing.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/typescript/src/tracing/api.ts b/typescript/src/tracing/api.ts index 25552e60e5..fa09946022 100644 --- a/typescript/src/tracing/api.ts +++ b/typescript/src/tracing/api.ts @@ -101,6 +101,7 @@ export interface TraceApi { threadId?: string; userId?: string; testCaseId?: string; + testRunId?: string; turnId?: string; input?: any; output?: any; diff --git a/typescript/src/tracing/tracing.ts b/typescript/src/tracing/tracing.ts index cf7ac78356..2d9263af62 100644 --- a/typescript/src/tracing/tracing.ts +++ b/typescript/src/tracing/tracing.ts @@ -270,6 +270,7 @@ export interface Trace { threadId?: string; userId?: string; testCaseId?: string; + testRunId?: string; turnId?: string; input?: any; output?: any; @@ -797,6 +798,7 @@ export class TraceManager { threadId: trace.threadId, userId: trace.userId, testCaseId: trace.testCaseId, + testRunId: trace.testRunId, turnId: trace.turnId, input: trace.input, output: trace.output, @@ -1447,6 +1449,7 @@ export interface UpdateCurrentTraceParams { threadId?: string; userId?: string; testCaseId?: string; + testRunId?: string; turnId?: string; input?: any; output?: any; @@ -1469,6 +1472,7 @@ export const updateCurrentTrace = ({ threadId, userId, testCaseId, + testRunId, turnId, input, output, @@ -1516,6 +1520,9 @@ export const updateCurrentTrace = ({ if (testCaseId !== undefined) { currentTrace.testCaseId = testCaseId; } + if (testRunId !== undefined) { + currentTrace.testRunId = testRunId; + } if (turnId !== undefined) { currentTrace.turnId = turnId; }