Skip to content

Conversation

@pawbana
Copy link
Contributor

@pawbana pawbana commented Nov 25, 2025

Adds tracing for interceptions, tool calls and recording.

Example interception trace:

image

@pawbana pawbana requested a review from dannykopping November 25, 2025 04:14
@pawbana pawbana force-pushed the pb/add-otel branch 2 times, most recently from 3fb2522 to af4a1fd Compare November 25, 2025 08:51
@mtojek
Copy link
Member

mtojek commented Nov 26, 2025

Hey @pawbana, have you tested it with Jaeger tracing involved as we chatted on the weekly call? If so, perhaps update the PR description with any findings or graphs.

resp, err := http.DefaultClient.Do(req)
t.Cleanup(func() { _ = resp.Body.Close() })
require.NoError(t, err)
bridgeSrv.Close()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

Did a quick skim review, spotted a few things which need attention.
I think there a few too many drive-by changes in this PR which I want to understand better.

Copy link
Collaborator

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

Almost there! 🎉 A few minor questions & nits

return attrs
}

func EndSpanErr(span trace.Span, err *error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might want to explain the *error in a comment for the confused reader later 😆


// Setup MCP tools.
tools := setupMCPServerProxiesForTest(t)
tools := setupMCPServerProxiesForTest(t, testTracer)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: it's confusing to name this tools, since it's not actually a list of tools.

_ = json.NewDecoder(&buf).Decode(&args)
res, err := tool.Call(ctx, args)

args := i.unmarshalArgs(tc.Function.Arguments)
Copy link
Collaborator

Choose a reason for hiding this comment

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

unmarshalArgs returns a ToolArgs struct, which is a type alias for any.

You're subtly changing behaviour now. Previously this was being decoded to a map[string]string.
Why was this change necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without the change TestOpenAIInjectedToolsTrace test was failing due to ToolCall span input attribute being empty.
I tested current code manually and tool.Call gets empty input in openAI blocking case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So are you saying blocking openai requests fail to invoke tools correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

github.com/openai/openai-go/v2 v2.7.0
)

require (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
require (
// Tracing-related libs.
require (

Also, thanks for getting rid of go-cmp 👍

@pawbana pawbana merged commit b202549 into main Dec 5, 2025
1 check passed
pawbana added a commit to coder/coder that referenced this pull request Dec 5, 2025
Adds tracing for AIBridge.
Updates github.com/coder/aibridge version from `v0.2.2` to `v0.3.0`

Depends on: coder/aibridge#63
Fixes: coder/aibridge#26

---------

Co-authored-by: Danny Kopping <danny@coder.com>
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