Skip to content

Align tracing semconv usage and enrich OTel span attributes#6847

Merged
lpcox merged 3 commits into
mainfrom
copilot/go-fan-review-opentelemetry
Jun 1, 2026
Merged

Align tracing semconv usage and enrich OTel span attributes#6847
lpcox merged 3 commits into
mainfrom
copilot/go-fan-review-opentelemetry

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 1, 2026

This updates the OpenTelemetry tracing integration to remove mixed semantic convention versions in internal/tracing and pick up the current OTel Go release. It also fills two observability gaps called out in the review: structured error.type on error spans and gen_ai.system on MCP tool-call spans.

  • Tracing semconv alignment

    • Standardizes internal/tracing/span_helpers.go and its tests on semconv/v1.34.0
    • Removes the remaining v1.27.0 usage so tracing code emits a consistent schema version
  • Span enrichment

    • RecordSpanError now sets error.type in addition to recording the exception and span status
    • StartToolCallSpan now includes gen_ai.system="mcp" on tool-call spans
    • Re-exports GenAISystem alongside the existing gen_ai.* helpers for consistent use across tracing code
  • Dependency update

    • Bumps the direct OTel modules to v1.44.0
    • Refreshes module metadata to match the updated dependency graph
  • Focused test updates

    • Extends existing tracing helper tests to assert the new error.type and gen_ai.system attributes
func RecordSpanError(span trace.Span, err error, msg string) {
    span.RecordError(err, trace.WithStackTrace(true))
    if err != nil {
        span.SetAttributes(semconv.ErrorType(err))
    }
    span.SetStatus(codes.Error, msg)
}

func StartToolCallSpan(ctx context.Context, tracer trace.Tracer, serverID, toolName string) (context.Context, trace.Span) {
    return tracer.Start(ctx, "mcp.tool_call",
        trace.WithAttributes(
            GenAISystem.String("mcp"),
            GenAIAgentID.String(serverID),
            MCPMethod.String("tools/call"),
            GenAIToolName.String(toolName),
        ),
    )
}

Copilot AI linked an issue Jun 1, 2026 that may be closed by this pull request
5 tasks
Copilot AI changed the title [WIP] Review OpenTelemetry Go Module integration Align tracing semconv usage and enrich OTel span attributes Jun 1, 2026
Copilot finished work on behalf of lpcox June 1, 2026 14:52
Copilot AI requested a review from lpcox June 1, 2026 14:52
@lpcox lpcox marked this pull request as ready for review June 1, 2026 14:59
Copilot AI review requested due to automatic review settings June 1, 2026 14:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 updates the gateway’s OpenTelemetry tracing helpers to consistently use a single semantic conventions package version and enriches spans with additional standardized attributes to improve observability.

Changes:

  • Standardize tracing helpers and tests on go.opentelemetry.io/otel/semconv/v1.34.0 (removing mixed semconv usage).
  • Enrich error spans with error.type and MCP tool-call spans with gen_ai.system="mcp".
  • Bump OpenTelemetry Go modules to v1.44.0 and refresh module metadata (go.mod/go.sum).
Show a summary per file
File Description
internal/tracing/span_helpers.go Align semconv import; add error.type on errors and gen_ai.system on tool-call spans.
internal/tracing/span_helpers_test.go Extend tests to assert the new error.type and gen_ai.system attributes.
internal/tracing/genai_attrs.go Re-export GenAISystem key alongside existing gen_ai.* helpers for consistent usage.
go.mod Bump OpenTelemetry modules to v1.44.0 and update related dependencies.
go.sum Update checksums to reflect the refreshed dependency graph after version bumps.

Copilot's findings

Tip

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

  • Files reviewed: 4/5 changed files
  • Comments generated: 0

@lpcox lpcox merged commit 2260f38 into main Jun 1, 2026
29 checks passed
@lpcox lpcox deleted the copilot/go-fan-review-opentelemetry branch June 1, 2026 15:31
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.

[go-fan] Go Module Review: go.opentelemetry.io/otel

3 participants