Skip to content

Commit 5e81f3c

Browse files
committed
re-add tool_name attr to tool.Call + toolCount attr in fetchTools trace
1 parent a863d67 commit 5e81f3c

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

aibtrace/aibtrace.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const (
3232
MCPToolName = "mcp_tool_name"
3333
MCPServerName = "mcp_server_name"
3434
MCPServerURL = "mcp_server_url"
35+
MCPToolCount = "mcp_tool_count"
3536

3637
APIKeyID = "api_key_id"
3738
)

mcp/proxy_streamable_http.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ func (p *StreamableHTTPServerProxy) fetchTools(ctx context.Context) (_ map[strin
154154
Logger: p.logger,
155155
}
156156
}
157+
span.SetAttributes(append(p.traceAttributes(), attribute.Int(aibtrace.MCPToolCount, len(out)))...)
157158
return out, nil
158159
}
159160

mcp/tool.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func (t *Tool) Call(ctx context.Context, tracer trace.Tracer, input any) (_ *mcp
5050

5151
spanAttrs := append(
5252
aibtrace.InterceptionAttributesFromContext(ctx),
53+
attribute.String(aibtrace.MCPToolName, t.Name),
5354
attribute.String(aibtrace.MCPServerName, t.ServerName),
5455
attribute.String(aibtrace.MCPServerURL, t.ServerURL),
5556
)

trace_integration_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@ func TestNewServerProxyManagerTraces(t *testing.T) {
543543
attribute.String(aibtrace.MCPServerName, serverName),
544544
}
545545
verifyTraces(t, sr, []expectTrace{{"StreamableHTTPServerProxy.Init", 1, codes.Unset}}, attrs)
546+
547+
attrs = append(attrs, attribute.Int(aibtrace.MCPToolCount, len(proxy.ListTools())))
546548
verifyTraces(t, sr, []expectTrace{{"StreamableHTTPServerProxy.Init.fetchTools", 1, codes.Unset}}, attrs)
547549
}
548550

0 commit comments

Comments
 (0)