Repository navigation
Make automatic tool tracing backend-neutral - #1342
Conversation
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>
There was a problem hiding this comment.
🟢 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
otelproviderand the shared error-type helper intointernal/telemetry, removinginternal/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
API consistency review
Changed Go contract
Upstream evidence reviewedNo 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. AssessmentI could not complete the comparison, so I am not approving parity and have no confirmed findings. The new
|
Summary
toolautocall.Config.Tracerandtoolautocall.WithTracer, with explicit configuration taking precedence.otelprovider, preserving automatic middleware injection and addingNewToolTracerfor explicit use.internal/telemetryand removeinternal/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