Skip to content

Make automatic tool tracing backend-neutral - #1342

Merged
Quim Muntal (qmuntal) merged 1 commit into
mainfrom
backend-neutral-tool-tracing
Nov 2, 2026
Merged

Quim Muntal (qmuntal) merged 1 commit into
mainfrom
backend-neutral-tool-tracing

Conversation

@qmuntal

Copy link
Copy Markdown
Member

Summary

  • Add backend-neutral tool tracing through toolautocall.Config.Tracer and toolautocall.WithTracer, with explicit configuration taking precedence.
  • Move tool spans into otelprovider, preserving automatic middleware injection and adding NewToolTracer for explicit use.
  • Move the shared error-type helper into internal/telemetry and remove internal/otelx.

This removes OpenTelemetry from the core, OpenAI provider, and workflow build dependencies. Provider SDKs may still depend on OpenTelemetry; module requirements are unchanged.

Validation

  • Focused Go tests pass for automatic tool calling, harness integration, the OTel provider, telemetry, and workflow observability.
  • Changed-file lint: 0 issues.
  • Verified the OpenTelemetry-free core dependency graph.

Allow tool tracers to be configured directly or injected through the run context. Keep OpenTelemetry instrumentation in otelprovider and consolidate the shared error-type helper in internal telemetry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 08:31
@qmuntal
Quim Muntal (qmuntal) requested a review from a team as a code owner October 30, 2026 08:31
@github-actions github-actions Bot added area:agent Changes files in the agent area area:internal Changes files in the internal area area:provider Changes files in the provider area area:provider/otel Changes files in the provider / otel area area:workflow Changes files in the workflow area labels Oct 30, 2026

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.

🟢 Approval recommended

The backend-neutral tool-tracing refactor has no active review issues.

No open issues 🎉

What changed in this PR

Decouples automatic tool tracing from OpenTelemetry, keeping backend-specific span handling in otelprovider while preserving automatic middleware injection.

Changes:

  • Adds a backend-neutral tracer interface and context injection, with explicit configuration taking precedence.
  • Moves tool spans into otelprovider and the shared error-type helper into internal/telemetry, removing internal/otelx.
  • Expands tests for tracer selection, streaming, concurrency, errors, panics, and cancellation.
File Description
workflow/​internal/​observability/​observability.go Uses the relocated error-type helper.
provider/​otelprovider/​tool.go Implements OpenTelemetry tool tracing and NewToolTracer.
provider/​otelprovider/​otel.go Injects the backend-neutral tool tracer.
provider/​otelprovider/​otel_test.go Expands tool-span configuration and failure tests.
provider/​otelprovider/​model.go Uses the relocated error-type helper.
provider/​otelprovider/​embedding.go Uses the relocated error-type helper.
provider/​otelprovider/​doc.go Documents explicit tool tracing.
internal/​telemetry/​telemetry.go Adds the shared error-type helper.
internal/​telemetry/​telemetry_test.go Tests error-type naming behavior.
internal/​otelx/​error.go Removes the relocated helper.
internal/​otelx/​context.go Removes OpenTelemetry-specific tracer context storage.
agent/​harness/​toolautocall/​doc.go Documents backend-neutral tracing and precedence.
agent/​harness/​toolautocall/​autocall.go Replaces direct OpenTelemetry usage with tracer callbacks.
agent/​harness/​toolautocall/​autocall_test.go Tests tracer lifecycle, precedence, and concurrent calls.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

API consistency review

Result Scope
unable to determine public API, user-visible behavior

Changed Go contract

  • New exported toolautocall.Config.Tracer and toolautocall.WithTracer. An explicit tracer takes precedence over the context tracer.
  • New otelprovider.NewToolTracer. Tool spans are now created in otelprovider instead of the core.
  • Automatic middleware injection of tool spans is preserved.
  • internal/otelx is removed.

Upstream evidence reviewed

No upstream evidence was gathered in this run. I did not compare against the .NET or Python tool-invocation telemetry. The PR's validation covers Go tests only.

Assessment

I could not complete the comparison, so I am not approving parity and have no confirmed findings. The new Tracer hook looks like Go-specific plumbing. It exists to remove OpenTelemetry from the core dependency graph. The .NET OpenTelemetryAgent and FunctionInvokingChatClient path and the Python observability.py do not obviously expose an equivalent option. Maintainers should check that the span names, attributes and default-on behavior of tool tracing match .NET and Python. Those are the observable parts of the change.

Generated by Go API Consistency Review Agent for #1342 · copilot · auto · 18.2 AIC · ⌖ 0.616 AIC · ⊞ 4.9K · ◷

@github-actions github-actions Bot added the public-api-change Pull Request changes public APIs label Oct 30, 2026
@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 025f582 Nov 2, 2026
32 of 34 checks passed
@qmuntal
Quim Muntal (qmuntal) deleted the backend-neutral-tool-tracing branch November 2, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Changes files in the agent area area:internal Changes files in the internal area area:provider/otel Changes files in the provider / otel area area:provider Changes files in the provider area area:workflow Changes files in the workflow area public-api-change Pull Request changes public APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants