Skip to content

Update OpenTelemetry span and attribute names #2964

@alexmojaki

Description

@alexmojaki

Some changes we need to be more in line with the OTel specs:

Agent runs:

  • Span name should be invoke_agent {gen_ai.agent.name} instead of agent run
  • Attribute agent_name should be gen_ai.agent.name. For this one, let's just duplicate the attribute immediately, i.e. set both names to the same value.

Tool execution:

  • Span name should be execute_tool {gen_ai.tool.name} instead of running tool
  • gen_ai.tool.call.arguments where we’ve been using tool_arguments
  • gen_ai.tool.call.result where we’ve been using tool_response

All these names are already being actively used in queries, changing them would cause breakages, although just copying agent_name is fine. Most users probably don't actually care about these right now. So I think InstrumentationSettings(version=3) should be introduced to allow enabling some or all of these changes, while the default version=2 remains. If making all these changes in a single PR is a pain, then version=3 can apply some subset while the rest is for version=4 or beyond.

The span names are the most important for the sake of improving the display in #2925.

The gen_ai.tool.call.* attributes are not even part of the released spec yet, so not very important.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions