Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Emit gen_ai.provider.name instead of deprecated gen_ai.system for Anthropic spans
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ def get_llm_request_attributes(
) -> dict[str, AttributeValue]:
attributes: dict[str, AttributeValue | None] = {
GenAIAttributes.GEN_AI_OPERATION_NAME: GenAIAttributes.GenAiOperationNameValues.CHAT.value,
GenAIAttributes.GEN_AI_SYSTEM: GenAIAttributes.GenAiSystemValues.ANTHROPIC.value, # pyright: ignore[reportDeprecated]
GenAIAttributes.GEN_AI_PROVIDER_NAME: (
GenAIAttributes.GenAiProviderNameValues.ANTHROPIC.value
),
Comment thread
AgentGymLeader marked this conversation as resolved.
GenAIAttributes.GEN_AI_REQUEST_MODEL: params.model,
GenAIAttributes.GEN_AI_REQUEST_MAX_TOKENS: params.max_tokens,
GenAIAttributes.GEN_AI_REQUEST_TEMPERATURE: params.temperature,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async def test_async_messages_create_basic(
span = spans[0]
assert span.name == f"chat {model}"
assert span.attributes[GenAIAttributes.GEN_AI_OPERATION_NAME] == "chat"
assert span.attributes[GenAIAttributes.GEN_AI_SYSTEM] == "anthropic"
assert span.attributes[GenAIAttributes.GEN_AI_PROVIDER_NAME] == "anthropic"
assert span.attributes[GenAIAttributes.GEN_AI_REQUEST_MODEL] == model
assert span.attributes[GenAIAttributes.GEN_AI_RESPONSE_ID] == response.id
assert (
Expand Down Expand Up @@ -785,4 +785,7 @@ async def test_async_messages_create_event_only_no_content_in_span(
assert len(logs) == 1
log_record = logs[0].log_record
assert log_record.event_name == "gen_ai.client.inference.operation.details"
assert log_record.attributes[GenAIAttributes.GEN_AI_SYSTEM] == "anthropic"
assert (
log_record.attributes[GenAIAttributes.GEN_AI_PROVIDER_NAME]
== "anthropic"
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,12 @@
from .conformance.inference import InferenceScenario
from .conformance.tool_calling import ToolCallingScenario

_LEGACY_SYSTEM_SKIP = pytest.mark.skip(
reason="anthropic emits legacy gen_ai.system in experimental mode"
)


@pytest.mark.parametrize(
"scenario",
[
pytest.param(InferenceScenario(), marks=_LEGACY_SYSTEM_SKIP),
pytest.param(ToolCallingScenario(), marks=_LEGACY_SYSTEM_SKIP),
InferenceScenario(),
ToolCallingScenario(),
],
ids=lambda s: type(s).__name__,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def assert_span_attributes( # pylint: disable=too-many-arguments
== span.attributes[GenAIAttributes.GEN_AI_OPERATION_NAME]
)
assert (
GenAIAttributes.GenAiSystemValues.ANTHROPIC.value
== span.attributes[GenAIAttributes.GEN_AI_SYSTEM]
GenAIAttributes.GenAiProviderNameValues.ANTHROPIC.value
== span.attributes[GenAIAttributes.GEN_AI_PROVIDER_NAME]
)
Comment thread
lmolkova marked this conversation as resolved.
assert (
request_model == span.attributes[GenAIAttributes.GEN_AI_REQUEST_MODEL]
Expand Down