add trace chunk count as span attr for async

This commit is contained in:
Dinesh Yeduguru 2024-11-30 18:30:56 -08:00
parent e5c85b9dba
commit 4dd08e5595

View file

@ -102,10 +102,12 @@ def trace_protocol(cls: Type[T]) -> Type[T]:
with tracing.span(f"{class_name}.{method_name}", span_attributes) as span:
try:
count = 0
async for item in method(self, *args, **kwargs):
yield item
count += 1
finally:
span.set_attribute("output", "streaming output")
span.set_attribute("chunk_count", count)
@wraps(method)
async def async_wrapper(self: Any, *args: Any, **kwargs: Any) -> Any: