Skip to content

Commit

Permalink
fix: Overload __exit__ method for NoOpTracer
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianNiehusAA authored and NiklasKoehneckeAA committed Aug 12, 2024
1 parent 73db2da commit 55f8344
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/intelligence_layer/core/tracer/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,14 @@ def end(self, timestamp: Optional[datetime] = None) -> None:
def export_for_viewing(self) -> Sequence[ExportedSpan]:
return []

def __exit__(
self,
exc_type: Optional[type[BaseException]],
exc_value: Optional[BaseException],
_traceback: Optional[TracebackType],
) -> None:
pass


class JsonSerializer(RootModel[PydanticSerializable]):
root: SerializeAsAny[PydanticSerializable]
2 changes: 1 addition & 1 deletion tests/connectors/document_index/test_document_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def test_document_list_all_documents(
) -> None:
filter_result = document_index.documents(collection_path)

assert len(filter_result) == 3
assert len(filter_result) == 6


def test_document_list_max_n_documents(
Expand Down
7 changes: 5 additions & 2 deletions tests/core/tracer/test_in_memory_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ def test_task_span_records_error_value() -> None:
raise ValueError("my bad, sorry")

assert isinstance(tracer.entries[0], InMemoryTaskSpan)
error = tracer.entries[0].output
assert isinstance(error, ErrorValue)
error_log = tracer.entries[0].entries[0]
assert isinstance(error_log, LogEntry)

error = error_log.value
assert isinstance(error_log.value, ErrorValue)
assert error.message == "my bad, sorry"
assert error.error_type == "ValueError"
assert error.stack_trace.startswith("Traceback")
Expand Down

0 comments on commit 55f8344

Please sign in to comment.