Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NA] Add truncate arg to the search_spans and search_traces #1124

Merged
merged 2 commits into from
Jan 23, 2025
Merged
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
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
Loading