Skip to content

Commit 33ead3a

Browse files
committed
refactor: support chat span without request model
1 parent c1c74ff commit 33ead3a

File tree

1 file changed

+8
-2
lines changed
  • instrumentation-genai/opentelemetry-instrumentation-langchain/src/opentelemetry/instrumentation/langchain

1 file changed

+8
-2
lines changed

instrumentation-genai/opentelemetry-instrumentation-langchain/src/opentelemetry/instrumentation/langchain/span_manager.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,18 @@ def create_chat_span(
7474
self,
7575
run_id: UUID,
7676
parent_run_id: Optional[UUID],
77-
request_model: str,
77+
request_model: Optional[str],
7878
) -> Span:
79+
operation_name = GenAI.GenAiOperationNameValues.CHAT.value
80+
span_name = (
81+
f"{operation_name} {request_model}"
82+
if request_model
83+
else operation_name
84+
)
7985
span = self._create_span(
8086
run_id=run_id,
8187
parent_run_id=parent_run_id,
82-
span_name=f"{GenAI.GenAiOperationNameValues.CHAT.value} {request_model}",
88+
span_name=span_name,
8389
kind=SpanKind.CLIENT,
8490
)
8591
span.set_attribute(

0 commit comments

Comments
 (0)