Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.
TypeScript agent-harnessagent-harness-engineeringai-engineeringai-observabilityamd-gpuclaude-codeclickhousecodexcoding-agentcoding-agentscursorgenaigpu-monitoringllm-observabilityllmopsnvidia-smiobservabilityopen-sourceopenaiopentelemetry
fix(python-sdk): end the original streaming span instead of orphaning it (#1464)
Tai An7bc745992899
diff --git a/sdk/python/src/openlit/instrumentation/ai21/ai21.py b/sdk/python/src/openlit/instrumentation/ai21/ai21.pyindex e10fbb48..14cbfc7e 100644--- a/sdk/python/src/openlit/instrumentation/ai21/ai21.py+++ b/sdk/python/src/openlit/instrumentation/ai21/ai21.py@@ -91,9 +91,7 @@ def chat(return chunkexcept StopIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/ai21/async_ai21.py b/sdk/python/src/openlit/instrumentation/ai21/async_ai21.pyindex 62319bd8..b493908a 100644--- a/sdk/python/src/openlit/instrumentation/ai21/async_ai21.py+++ b/sdk/python/src/openlit/instrumentation/ai21/async_ai21.py@@ -91,9 +91,7 @@ def async_chat(return chunkexcept StopAsyncIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/bedrock/bedrock.py b/sdk/python/src/openlit/instrumentation/bedrock/bedrock.pyindex 5bfb5339..de51064d 100644--- a/sdk/python/src/openlit/instrumentation/bedrock/bedrock.py+++ b/sdk/python/src/openlit/instrumentation/bedrock/bedrock.py@@ -214,9 +214,7 @@ def converse_stream(return chunkexcept StopIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/cohere/async_cohere.py b/sdk/python/src/openlit/instrumentation/cohere/async_cohere.pyindex c3aae0f4..448d302c 100644--- a/sdk/python/src/openlit/instrumentation/cohere/async_cohere.py+++ b/sdk/python/src/openlit/instrumentation/cohere/async_cohere.py@@ -174,9 +174,7 @@ def async_chat_stream(return chunkexcept StopAsyncIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/cohere/cohere.py b/sdk/python/src/openlit/instrumentation/cohere/cohere.pyindex d05b5bba..7ce5f4fa 100644--- a/sdk/python/src/openlit/instrumentation/cohere/cohere.py+++ b/sdk/python/src/openlit/instrumentation/cohere/cohere.py@@ -174,9 +174,7 @@ def chat_stream(return chunkexcept StopIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py b/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.pyindex 88513a1b..3d0b365e 100644--- a/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py+++ b/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py@@ -176,9 +176,7 @@ def async_generate_stream(return chunkexcept StopAsyncIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py b/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.pyindex a4907055..ce28d0f4 100644--- a/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py+++ b/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py@@ -176,9 +176,7 @@ def generate_stream(return chunkexcept StopIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/gpt4all/gpt4all.py b/sdk/python/src/openlit/instrumentation/gpt4all/gpt4all.pyindex d79c1d67..dda1e2f5 100644--- a/sdk/python/src/openlit/instrumentation/gpt4all/gpt4all.py+++ b/sdk/python/src/openlit/instrumentation/gpt4all/gpt4all.py@@ -92,9 +92,7 @@ def generate(return chunkexcept StopIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_generate_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/groq/async_groq.py b/sdk/python/src/openlit/instrumentation/groq/async_groq.pyindex c741a9b1..686f4353 100644--- a/sdk/python/src/openlit/instrumentation/groq/async_groq.py+++ b/sdk/python/src/openlit/instrumentation/groq/async_groq.py@@ -94,9 +94,7 @@ def async_chat(return chunkexcept StopAsyncIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/groq/groq.py b/sdk/python/src/openlit/instrumentation/groq/groq.pyindex 380e2e24..e9492937 100644--- a/sdk/python/src/openlit/instrumentation/groq/groq.py+++ b/sdk/python/src/openlit/instrumentation/groq/groq.py@@ -94,9 +94,7 @@ def chat(return chunkexcept StopIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/mistral/async_mistral.py b/sdk/python/src/openlit/instrumentation/mistral/async_mistral.pyindex 7c65f4ad..38592f29 100644--- a/sdk/python/src/openlit/instrumentation/mistral/async_mistral.py+++ b/sdk/python/src/openlit/instrumentation/mistral/async_mistral.py@@ -171,9 +171,7 @@ def async_stream(return chunkexcept StopAsyncIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/mistral/mistral.py b/sdk/python/src/openlit/instrumentation/mistral/mistral.pyindex eada7487..dbbbe9bb 100644--- a/sdk/python/src/openlit/instrumentation/mistral/mistral.py+++ b/sdk/python/src/openlit/instrumentation/mistral/mistral.py@@ -171,9 +171,7 @@ def stream(return chunkexcept StopIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/ollama/async_ollama.py b/sdk/python/src/openlit/instrumentation/ollama/async_ollama.pyindex 14c4bfde..cb0badb6 100644--- a/sdk/python/src/openlit/instrumentation/ollama/async_ollama.py+++ b/sdk/python/src/openlit/instrumentation/ollama/async_ollama.py@@ -97,9 +97,7 @@ def async_chat(return chunkexcept StopAsyncIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,@@ -281,9 +279,7 @@ def async_generate(return chunkexcept StopAsyncIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_generate_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/ollama/ollama.py b/sdk/python/src/openlit/instrumentation/ollama/ollama.pyindex cd5894f4..8ea4e3d5 100644--- a/sdk/python/src/openlit/instrumentation/ollama/ollama.py+++ b/sdk/python/src/openlit/instrumentation/ollama/ollama.py@@ -97,9 +97,7 @@ def chat(return chunkexcept StopIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,@@ -281,9 +279,7 @@ def generate(return chunkexcept StopIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_generate_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/premai/premai.py b/sdk/python/src/openlit/instrumentation/premai/premai.pyindex be145e65..0b4ed49e 100644--- a/sdk/python/src/openlit/instrumentation/premai/premai.py+++ b/sdk/python/src/openlit/instrumentation/premai/premai.py@@ -90,9 +90,7 @@ def chat(finally:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/together/async_together.py b/sdk/python/src/openlit/instrumentation/together/async_together.pyindex cdaaea32..9a4d7148 100644--- a/sdk/python/src/openlit/instrumentation/together/async_together.py+++ b/sdk/python/src/openlit/instrumentation/together/async_together.py@@ -89,9 +89,7 @@ def async_completion(return chunkexcept StopIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,diff --git a/sdk/python/src/openlit/instrumentation/together/together.py b/sdk/python/src/openlit/instrumentation/together/together.pyindex 7ba1a6ba..12d59112 100644--- a/sdk/python/src/openlit/instrumentation/together/together.py+++ b/sdk/python/src/openlit/instrumentation/together/together.py@@ -89,9 +89,7 @@ def completion(return chunkexcept StopIteration:try:- with tracer.start_as_current_span(- self._span_name, kind=SpanKind.CLIENT- ) as self._span:+ with self._span:process_streaming_chat_response(self,pricing_info=pricing_info,