diff --git a/src/harness_sdk/instrumentation/anthropic/__init__.py b/src/harness_sdk/instrumentation/anthropic/__init__.py index 9f9e274..b4adabc 100644 --- a/src/harness_sdk/instrumentation/anthropic/__init__.py +++ b/src/harness_sdk/instrumentation/anthropic/__init__.py @@ -273,6 +273,7 @@ def _wrapper( merged_kwargs["stream"] = True params = extract_params(**merged_kwargs) invocation = _build_invocation(handler, params, instance, capture_content) + invocation.attributes["gen_ai.request.streaming"] = True try: _evaluate_invocation(invocation) except ControlEvaluationBlocked: @@ -306,6 +307,7 @@ def _wrapper( merged_kwargs["stream"] = True params = extract_params(**merged_kwargs) invocation = _build_invocation(handler, params, instance, capture_content) + invocation.attributes["gen_ai.request.streaming"] = True try: _evaluate_invocation(invocation) except ControlEvaluationBlocked: diff --git a/test/instrumentation/anthropic/test_anthropic.py b/test/instrumentation/anthropic/test_anthropic.py index cc604b8..2a992cf 100644 --- a/test/instrumentation/anthropic/test_anthropic.py +++ b/test/instrumentation/anthropic/test_anthropic.py @@ -368,6 +368,7 @@ def test_messages_stream_sync_span_after_consume(agent, exporter, anthropic_inst assert len(spans) == 1 attrs = spans[0].attributes assert attrs.get("gen_ai.system") == "anthropic" + assert attrs.get("gen_ai.request.streaming") is True assert attrs.get("gen_ai.usage.output_tokens") == 5 @@ -428,6 +429,7 @@ async def test_messages_stream_async_span_after_consume(agent, exporter, anthrop spans = exporter.get_finished_spans() exporter.clear() assert len(spans) == 1 + assert spans[0].attributes.get("gen_ai.request.streaming") is True assert spans[0].attributes.get("gen_ai.usage.output_tokens") == 5