Skip to content

Commit

Permalink
Add truncate method to the search_spans and search_traces (#1124)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkuzmik authored Jan 23, 2025
1 parent 8c3dc6a commit 89b74c1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sdks/python/src/opik/api_objects/opik_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ def search_traces(
project_name: Optional[str] = None,
filter_string: Optional[str] = None,
max_results: int = 1000,
truncate: bool = True,
) -> List[trace_public.TracePublic]:
"""
Search for traces in the given project.
Expand All @@ -624,6 +625,7 @@ def search_traces(
project_name: The name of the project to search traces in. If not provided, will search across the project name configured when the Client was created which defaults to the `Default Project`.
filter_string: A filter string to narrow down the search. If not provided, all traces in the project will be returned up to the limit.
max_results: The maximum number of traces to return.
truncate: Whether to truncate image data stored in input, output or metadata
"""

page_size = 200
Expand All @@ -638,6 +640,7 @@ def search_traces(
filters=filters,
page=page,
size=page_size,
truncate=truncate,
)

if len(page_traces.content) == 0:
Expand All @@ -654,6 +657,7 @@ def search_spans(
trace_id: Optional[str] = None,
filter_string: Optional[str] = None,
max_results: int = 1000,
truncate: bool = True,
) -> List[span_public.SpanPublic]:
"""
Search for spans in the given trace. This allows you to search spans based on the span input, output,
Expand All @@ -664,6 +668,7 @@ def search_spans(
trace_id: The ID of the trace to search spans in. If provided, the search will be limited to the spans in the given trace.
filter_string: A filter string to narrow down the search.
max_results: The maximum number of spans to return.
truncate: Whether to truncate image data stored in input, output or metadata
"""
page_size = 200
spans: List[span_public.SpanPublic] = []
Expand All @@ -678,6 +683,7 @@ def search_spans(
filters=filters,
page=page,
size=page_size,
truncate=truncate,
)

if len(page_spans.content) == 0:
Expand Down

0 comments on commit 89b74c1

Please sign in to comment.