skrawcz commented on code in PR #590:
URL: https://github.com/apache/burr/pull/590#discussion_r2464482387


##########
tests/integrations/test_burr_opentelemetry.py:
##########
@@ -43,3 +48,137 @@ class SampleModel(pydantic.BaseModel):
 )
 def test_convert_to_otel_attribute(value, expected):
     assert convert_to_otel_attribute(value) == expected
+
+
+def test_burr_tracking_span_processor_on_start_with_none_tracker():
+    """Test that on_start handles None tracker gracefully without raising an 
error."""
+    processor = BurrTrackingSpanProcessor()
+
+    # Mock a span with a parent
+    mock_span = Mock()
+    mock_span.parent = Mock()
+    mock_span.parent.span_id = 12345
+    mock_span.name = "test_span"
+
+    # Mock the get_cached_span to return a parent span context
+    with patch("burr.integrations.opentelemetry.get_cached_span") as 
mock_get_cached:
+        mock_parent_context = Mock()
+        mock_parent_context.action_span = Mock()
+        mock_parent_context.action_span.spawn = Mock(return_value=Mock())
+        mock_parent_context.partition_key = "test_partition"
+        mock_parent_context.app_id = "test_app"
+        mock_get_cached.return_value = mock_parent_context
+
+        # Mock cache_span
+        with patch("burr.integrations.opentelemetry.cache_span"):
+            # Set tracker_context to None (simulating no tracker in context)
+            token = tracker_context.set(None)
+            try:
+                # This should not raise an error even though tracker is None
+                processor.on_start(mock_span, parent_context=None)
+            finally:
+                tracker_context.reset(token)
+
+
+def test_burr_tracking_span_processor_on_end_with_none_tracker():
+    """Test that on_end handles None tracker gracefully without raising an 
error."""
+    processor = BurrTrackingSpanProcessor()

Review Comment:
   pointer?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to