Skip to content

Commit 1fa0323

Browse files
Resolve greptile deadcode catch
1 parent 8a84798 commit 1fa0323

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/agentex/lib/core/tracing/span_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def _record_drop(self, count: int, reason: str) -> None:
163163
if count <= 0:
164164
return
165165
self._dropped_spans += count
166-
if "shutdown" in reason:
166+
if "shutting down" in reason:
167167
for _ in range(count):
168168
_metrics.record_span_dropped("shutdown")
169169
elif "queue full" in reason:

tests/lib/core/tracing/test_span_queue.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,28 @@ async def test_enqueue_records_enqueued_metric(self, monkeypatch):
790790

791791
mock_metrics.span_events_enqueued.add.assert_any_call(1, {"event_type": "start"})
792792

793+
async def test_enqueue_during_shutdown_records_dropped_metric(self, monkeypatch):
794+
monkeypatch.setenv("AGENTEX_TRACING_METRICS", "1")
795+
import agentex.lib.core.observability.tracing_metrics_recording as recording
796+
797+
recording._metrics_enabled = None
798+
recording._tracing = None
799+
mock_metrics = MagicMock()
800+
proc = _make_processor()
801+
queue = AsyncSpanQueue(linger_ms=0)
802+
803+
with patch(
804+
"agentex.lib.core.observability.tracing_metrics.get_tracing_metrics",
805+
return_value=mock_metrics,
806+
):
807+
queue.enqueue(SpanEventType.START, _make_span(), [proc])
808+
await asyncio.sleep(0.05)
809+
queue._stopping = True
810+
queue.enqueue(SpanEventType.END, _make_span(), [proc])
811+
await queue.shutdown()
812+
813+
mock_metrics.span_events_dropped.add.assert_any_call(1, {"reason": "shutdown"})
814+
793815
async def test_processor_failure_records_export_failure(self, monkeypatch):
794816
monkeypatch.setenv("AGENTEX_TRACING_METRICS", "1")
795817
import agentex.lib.core.observability.tracing_metrics_recording as recording

0 commit comments

Comments
 (0)