Skip to content

fix(names): Add gen_ai.function_id and gen_ai.pipeline.name to agent span name templates - #593

Merged
RulaKhaled merged 2 commits into
mainfrom
fix/agent-span-name-templates
Aug 28, 2026
Merged

RulaKhaled merged 2 commits into
mainfrom
fix/agent-span-name-templates

Conversation

@RulaKhaled

@RulaKhaled RulaKhaled commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

The agent category currently only offers {{gen_ai.operation.name}} {{gen_ai.agent.name}} before falling through to the bare operation, so agent span names the SDKs already emit have no template backing them:

  • invoke_agent weather_agent — Vercel AI, value on gen_ai.function_id
  • invoke_agent format_prompt — LangChain, value on gen_ai.pipeline.name (after the getsentry/sentry-javascript follow-up; JS currently uses langchain.chain.name)
  • invoke_agent {run_name}sentry-python already emits this for LangChain agent executors, with run_name on gen_ai.function_id

Both attributes are already registered and both carry bounded, low-cardinality values.

🤖 Generated with Claude Code

…ent span names

The agent category only offered `{{gen_ai.operation.name}} {{gen_ai.agent.name}}`
before falling through to the bare operation, so agent spans the SDKs already
emit had no template backing them: Vercel AI puts the value on
`gen_ai.function_id`, LangChain on `gen_ai.pipeline.name`, and sentry-python
already emits `invoke_agent {run_name}` with `run_name` on `gen_ai.function_id`.

Add both templates after the `agent.name` one so it stays the most specific
match, and before the bare operation fallback.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@RulaKhaled
RulaKhaled requested review from a team, Lms24, cleptric, mjq and nsdeschenes as code owners August 27, 2026 13:35
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Attributes

  • Add HTTP body size and status text attributes by msonnb in #574
  • Add graphql.processing.type by andreiborza in #572

Other

  • (span-names) Add url.domainrule for http.client spans by Lms24 in #575

Bug Fixes 🐛

Names

  • Add gen_ai.function_id and gen_ai.pipeline.name to agent span name templates by RulaKhaled in #593
  • Add missing gen_ai ops to span name rules by Lms24 in #579
  • Include tool name in gen_ai.execute_tool span names by Lms24 in #580
  • Correct graphql span name examples by andreiborza in #573

Internal Changes 🔧

  • (attributes) Add search alias for segment name by nsdeschenes in #577
  • (search-metadata) Add visibility field by nsdeschenes in #597

🤖 This preview updates automatically when you update the PR.

RulaKhaled added a commit to getsentry/sentry-javascript that referenced this pull request Aug 28, 2026
… streaming (#23582)

With span streaming enabled (the default), `gen_ai.invoke_agent` names
follow the [agent span name
conventions](https://getsentry.github.io/sentry-conventions/names/#gen_ai-agent):
`{operation} {name}` from `gen_ai.agent.name`, `gen_ai.pipeline.name` or
`gen_ai.function_id`, otherwise `{operation}`.

In practice this only changes LangChain chain spans, and only their
prefix. They were named `chain format_prompt`, which does not lead with
the operation like every other agent span; they are now `invoke_agent
format_prompt`. The chain name itself is bounded, so it stays in the
name. A chain the SDK cannot name falls back to `invoke_agent` rather
than carrying the `unknown_chain` sentinel, the same way a missing model
is dropped in #23573.

LangGraph agent names and Vercel AI `functionId`s are unchanged in both
lifecycles — both are bounded, low-cardinality values.

The `pipeline.name` and `function_id` templates are added in
getsentry/sentry-conventions#593. LangChain still emits its chain name
on `langchain.chain.name`; moving it to `gen_ai.pipeline.name` is
tracked in
[JS-3452](https://linear.app/getsentry/issue/JS-3452/move-langchainchainname-to-gen-aipipelinename)
and should land before v11 ships, so the emitted name matches a
published template. Span names are unaffected by that move — they are
built from the local chain name, not read back off the attribute.

The other two ops in the agent rule need nothing: the SDK emits no
`gen_ai.handoff` spans, and `gen_ai.create_agent` was dropped in v11.
Neither is listed in the migration table.

The migration entry lives in `MIGRATION.md` rather than
`docs/migration/v11-end-state.md`, which was removed by #23623.

Fixes #23524

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@Lms24
Lms24 requested a review from vgrozdanic August 28, 2026 10:28

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from my end! Let's keep this open a bit longer for product/agent monitoring folks to weigh in

@vgrozdanic vgrozdanic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you 🙌

@RulaKhaled
RulaKhaled enabled auto-merge (squash) August 28, 2026 12:06
@RulaKhaled
RulaKhaled merged commit 529aadd into main Aug 28, 2026
17 checks passed
@RulaKhaled
RulaKhaled deleted the fix/agent-span-name-templates branch August 28, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants