Describe your environment
OS: Ubuntu 22.04
Python version: Python 3.12
Package version: opentelemetry-instrumentation-genai-langchain 1.1b1, opentelemetry-util-genai 1.1b0 (also reproduces on main)
GenAI library (e.g. anthropic, openai) and version: langchain 1.3.16, langchain-openai 1.4.3
What happened?
The LangChain instrumentation reads a conversation identifier from the
thread_id, session_id, or conversation_id metadata keys, but only applies
it to invoke_agent spans. The chat and invoke_workflow spans in the same
trace have no gen_ai.conversation.id, even though semconv defines the
attribute as conditionally required on all three.
WorkflowInvocation in opentelemetry-util-genai has no conversation_id
field at all, so an invoke_workflow span cannot carry one even when the
application supplies it.
Separately, AgentInvocation applies the attribute from
_get_request_attributes, which runs when the span finishes. The attribute is
absent for the whole life of the span, so a SpanProcessor.on_start cannot see
it and a child span cannot read it from its parent.
Steps to Reproduce
examples/agent/main.py in the langchain package already reproduces this — it
sets session_id in the agent's metadata:
agent = create_react_agent(llm, tools=[multiply, add]).with_config(
{
"metadata": {
"agent_name": "coordinator",
"session_id": session_id,
},
}
)
Run it against any exporter and inspect the resulting spans, or swap the OTLP
exporters for an InMemorySpanExporter and print gen_ai.conversation.id for
each span.
Expected Result
Every span in the trace that semconv defines the attribute for carries it — the
invoke_agent span, the chat spans for the model calls it makes, and the
invoke_workflow span if the run is classified as a workflow.
Actual Result
Only the invoke_agent span carries gen_ai.conversation.id. The chat spans
and any invoke_workflow span have no such attribute.
Additional context
No response
Would you like to implement a fix?
Yes
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
Describe your environment
OS: Ubuntu 22.04
Python version: Python 3.12
Package version: opentelemetry-instrumentation-genai-langchain 1.1b1, opentelemetry-util-genai 1.1b0 (also reproduces on main)
GenAI library (e.g. anthropic, openai) and version: langchain 1.3.16, langchain-openai 1.4.3
What happened?
The LangChain instrumentation reads a conversation identifier from the
thread_id,session_id, orconversation_idmetadata keys, but only appliesit to
invoke_agentspans. Thechatandinvoke_workflowspans in the sametrace have no
gen_ai.conversation.id, even though semconv defines theattribute as conditionally required on all three.
WorkflowInvocationinopentelemetry-util-genaihas noconversation_idfield at all, so an
invoke_workflowspan cannot carry one even when theapplication supplies it.
Separately,
AgentInvocationapplies the attribute from_get_request_attributes, which runs when the span finishes. The attribute isabsent for the whole life of the span, so a
SpanProcessor.on_startcannot seeit and a child span cannot read it from its parent.
Steps to Reproduce
examples/agent/main.pyin the langchain package already reproduces this — itsets
session_idin the agent's metadata:Run it against any exporter and inspect the resulting spans, or swap the OTLP
exporters for an
InMemorySpanExporterand printgen_ai.conversation.idforeach span.
Expected Result
Every span in the trace that semconv defines the attribute for carries it — the
invoke_agentspan, thechatspans for the model calls it makes, and theinvoke_workflowspan if the run is classified as a workflow.Actual Result
Only the
invoke_agentspan carriesgen_ai.conversation.id. Thechatspansand any
invoke_workflowspan have no such attribute.Additional context
No response
Would you like to implement a fix?
Yes
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding
+1orme too, to help us triage it. Learn more here.