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
16 changes: 9 additions & 7 deletions src/rius/_semconv_generated.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vendored from rius-semconv v1.13.0 out/python/_semconv_generated.py by
# Vendored from rius-semconv v1.13.1 out/python/_semconv_generated.py by
# scripts/sync-semconv.sh. Do not edit: change the registry in rius-semconv.
"""Rius semantic conventions: the constants and tables, generated.

Expand Down Expand Up @@ -1604,11 +1604,13 @@ class SpanKind(str, Enum):

# SpanKind (our taxonomy ATTRIBUTE) -> the OpenTelemetry SpanKind FIELD, set
# centrally at span creation. The GenAI conventions decide the field per
# operation: inference, embeddings and retrieval call out of the process
# (CLIENT); execute_tool is INTERNAL; invoke_agent is CLIENT only for a hosted
# agent. Hence:
# - LLM / EMBEDDING / RETRIEVER / RERANKER -> CLIENT: a remote model or
# index is called.
# operation: inference and embeddings call out of the process (CLIENT);
# retrieval and execute_tool are INTERNAL; invoke_agent is CLIENT only for a
# hosted agent. Hence:
# - LLM / EMBEDDING / RERANKER -> CLIENT: a remote model is called.
# - RETRIEVER -> INTERNAL: the conventions deprecated their client retrieval
# span for an internal one, since a retriever wraps embedding, database,
# HTTP or rerank calls that have CLIENT spans of their own.
# - TOOL -> INTERNAL: a bare TOOL span is an in-process function, and the
# execute-tool convention says INTERNAL. The MCP wrapper overrides this to
# CLIENT at its own call site because a tools/call crosses a process
Expand All @@ -1625,7 +1627,7 @@ class SpanKind(str, Enum):
_OTEL_KIND_BY_KIND: dict[SpanKind, str] = {
SpanKind.LLM: "CLIENT",
SpanKind.EMBEDDING: "CLIENT",
SpanKind.RETRIEVER: "CLIENT",
SpanKind.RETRIEVER: "INTERNAL",
SpanKind.RERANKER: "CLIENT",
SpanKind.TOOL: "INTERNAL",
SpanKind.AGENT: "INTERNAL",
Expand Down
10 changes: 6 additions & 4 deletions tests/test_observe.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def test_non_tool_kind_has_no_gen_ai_tool_name(exported_spans: InMemorySpanExpor
[
(SpanKind.LLM, OtelSpanKind.CLIENT),
(SpanKind.EMBEDDING, OtelSpanKind.CLIENT),
(SpanKind.RETRIEVER, OtelSpanKind.CLIENT),
(SpanKind.RETRIEVER, OtelSpanKind.INTERNAL),
(SpanKind.TOOL, OtelSpanKind.INTERNAL),
(SpanKind.AGENT, OtelSpanKind.INTERNAL),
(SpanKind.CHAIN, OtelSpanKind.INTERNAL),
Expand All @@ -461,11 +461,13 @@ def step() -> None:
def test_otel_kind_field_follows_taxonomy_on_async_path(
exported_spans: InMemorySpanExporter,
) -> None:
@observe(kind=SpanKind.RETRIEVER)
async def search() -> None:
# A CLIENT kind, because INTERNAL is OTel's default and would pass even if
# the async path ignored the taxonomy.
@observe(kind=SpanKind.EMBEDDING)
async def embed() -> None:
pass

asyncio.run(search())
asyncio.run(embed())
assert exported_spans.get_finished_spans()[0].kind is OtelSpanKind.CLIENT


Expand Down
7 changes: 4 additions & 3 deletions tests/test_semconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_set_span_kind_without_operation(exported_spans: InMemorySpanExporter) -
[
(SpanKind.LLM, OtelSpanKind.CLIENT),
(SpanKind.EMBEDDING, OtelSpanKind.CLIENT),
(SpanKind.RETRIEVER, OtelSpanKind.CLIENT),
(SpanKind.RETRIEVER, OtelSpanKind.INTERNAL),
(SpanKind.RERANKER, OtelSpanKind.CLIENT),
(SpanKind.TOOL, OtelSpanKind.INTERNAL),
(SpanKind.AGENT, OtelSpanKind.INTERNAL),
Expand All @@ -54,8 +54,9 @@ def test_set_span_kind_without_operation(exported_spans: InMemorySpanExporter) -
def test_otel_span_kind_follows_the_genai_conventions(
kind: SpanKind, expected: OtelSpanKind
) -> None:
"""Inference, embeddings and retrieval cross a process boundary (CLIENT);
an in-process tool, agent or step does not (INTERNAL)."""
"""Inference and embeddings cross a process boundary (CLIENT); retrieval
and an in-process tool, agent or step do not (INTERNAL). A retriever wraps
the embedding, database or HTTP calls that carry CLIENT spans of their own."""
assert otel_span_kind(kind) is expected


Expand Down
2 changes: 1 addition & 1 deletion tests/test_spans.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def test_retrieved_documents_are_recorded_as_json(exported_spans: InMemorySpanEx
[
(SpanKind.LLM, OtelSpanKind.CLIENT),
(SpanKind.EMBEDDING, OtelSpanKind.CLIENT),
(SpanKind.RETRIEVER, OtelSpanKind.CLIENT),
(SpanKind.RETRIEVER, OtelSpanKind.INTERNAL),
(SpanKind.TOOL, OtelSpanKind.INTERNAL),
(SpanKind.AGENT, OtelSpanKind.INTERNAL),
(SpanKind.CHAIN, OtelSpanKind.INTERNAL),
Expand Down
Loading