Skip to content

[Repo Assist] feat(tracing): add GenAIOperationName and GenAIAgentName to mcp.tool_call spans#7981

Merged
lpcox merged 1 commit into
mainfrom
repo-assist/eng-otel-genai-attrs-20260623-805265753ca7605d
Jun 23, 2026
Merged

[Repo Assist] feat(tracing): add GenAIOperationName and GenAIAgentName to mcp.tool_call spans#7981
lpcox merged 1 commit into
mainfrom
repo-assist/eng-otel-genai-attrs-20260623-805265753ca7605d

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Adds two missing [OTel GenAI semantic convention]((opentelemetry.io/redacted) attributes to StartToolCallSpan:

Attribute Value Why
gen_ai.operation.name "execute_tool" Primary grouping key in Honeycomb/Grafana Tempo for GenAI tool-call spans
gen_ai.agent.name "mcp-gateway" Identifies the gateway component in traces

Both constants (GenAIOperationName, GenAIAgentName) were already defined in internal/tracing/genai_attrs.go but never referenced — a gap flagged in the Go Fan module review (#7972, items 1 and 2).

Changes

internal/tracing/span_helpers.goStartToolCallSpan:

// Before
GenAISystem.String("mcp"),
GenAIAgentID.String(serverID),
MCPMethod.String("tools/call"),
GenAIToolName.String(toolName),

// After
GenAISystem.String("mcp"),
GenAIOperationName.String("execute_tool"),  // ← new
GenAIAgentName.String("mcp-gateway"),       // ← new
GenAIAgentID.String(serverID),
MCPMethod.String("tools/call"),
GenAIToolName.String(toolName),

internal/tracing/span_helpers_test.goTestStartToolCallSpan: two new hasAttr assertions for the added attributes.

Rationale

  • gen_ai.operation.name is the standard grouping dimension for GenAI spans. Observability dashboards that follow OTel semconv use it as the primary filter/grouping field.
  • gen_ai.agent.name completes the standard GenAI identity attributes (alongside the already-set gen_ai.agent.id) so traces are self-describing.
  • No new dependencies, no behaviour change — purely additive attribute enrichment.

Test Status

Format check: gofmt ✅ — no formatting issues.

⚠️ Build/test: make agent-finished could not run locally — proxy.golang.org is blocked in the sandbox environment (infrastructure constraint). The CI pipeline will validate the build and tests. The change is a trivially correct attribute addition with no API changes.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

Generated by Repo Assist · 188.5 AIC · ⊞ 12.2K ·
Comment /repo-assist to run again

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

…CallSpan

Add the two missing GenAI semantic convention attributes to the
mcp.tool_call span:

  - gen_ai.operation.name = "execute_tool"  (OTel GenAI semconv primary
    grouping key for tool-call operations in Honeycomb/Grafana Tempo)
  - gen_ai.agent.name = "mcp-gateway"  (identifies the gateway component)

Both attribute keys (GenAIOperationName, GenAIAgentName) were already
defined in genai_attrs.go but never used. This fixes a gap flagged by
the Go Fan module review (#7972 items 1 and 2).

Update TestStartToolCallSpan to assert the two new attributes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox marked this pull request as ready for review June 23, 2026 18:23
Copilot AI review requested due to automatic review settings June 23, 2026 18:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR enriches mcp.tool_call OpenTelemetry spans with two missing GenAI semantic convention attributes so tool-call traces are easier to group and identify in downstream observability tools.

Changes:

  • Add gen_ai.operation.name = "execute_tool" to StartToolCallSpan.
  • Add gen_ai.agent.name = "mcp-gateway" to StartToolCallSpan.
  • Extend TestStartToolCallSpan to assert both new attributes are present.
Show a summary per file
File Description
internal/tracing/span_helpers.go Adds GenAI operation + agent name attributes to the tool-call span attributes set.
internal/tracing/span_helpers_test.go Adds assertions verifying the new span attributes are emitted.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@lpcox lpcox merged commit a15128b into main Jun 23, 2026
24 checks passed
@lpcox lpcox deleted the repo-assist/eng-otel-genai-attrs-20260623-805265753ca7605d branch June 23, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants