Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/harness_sdk/instrumentation/anthropic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions test/instrumentation/anthropic/test_anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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


Expand Down
Loading