Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deepeval/tracing/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions deepeval/tracing/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions deepeval/tracing/otel/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
):
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions deepeval/tracing/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=(
Expand Down
1 change: 1 addition & 0 deletions deepeval/tracing/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions typescript/src/tracing/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export interface TraceApi {
threadId?: string;
userId?: string;
testCaseId?: string;
testRunId?: string;
turnId?: string;
input?: any;
output?: any;
Expand Down
7 changes: 7 additions & 0 deletions typescript/src/tracing/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ export interface Trace {
threadId?: string;
userId?: string;
testCaseId?: string;
testRunId?: string;
turnId?: string;
input?: any;
output?: any;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1447,6 +1449,7 @@ export interface UpdateCurrentTraceParams {
threadId?: string;
userId?: string;
testCaseId?: string;
testRunId?: string;
turnId?: string;
input?: any;
output?: any;
Expand All @@ -1469,6 +1472,7 @@ export const updateCurrentTrace = ({
threadId,
userId,
testCaseId,
testRunId,
turnId,
input,
output,
Expand Down Expand Up @@ -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;
}
Expand Down
Loading