Skip to content

Add MCP telemetry tracking events

What does this MR do and why?

Creates two new events to track MCP related calls for tracking finish and start of mcp tool calls. The following adds these two events as internal tool calls and AI related event calls to track how often our mcp services is being used.

Relates to issue #574629

This MR was created by Duo in Session 1164223

Changes

  • Add event definitions for start_mcp_tool_call and finish_mcp_tool_call
  • Implement telemetry tracking in MCP tool execution flow
  • Capture contextual data including tool name, success/failure status, and error details
  • Enable visibility into MCP server usage patterns and adoption blockers

References

Screenshots or screen recordings

Tools Events Internal AI tracking event
Make multiple tool request Screenshot_2025-10-27_at_7.44.50_PM gitlabhq_development=# select * from ai_usage_events order by id desc limit 1; <br> id | timestamp | user_id | organization_id | created_at | event | extras | namespace_id <br>----+---------------------------+---------+-----------------+-------------------------------+-------+-----------------------------------------------------------------------------------------------------------------------------+--------------<br> 35 | 2025-10-27 21:40:54.83+00 | 1 | 1 | 2025-10-27 21:45:06.232095+00 | 22 | {"tool_name": "create_issue", "session_id": 3, "error_status": null, "failure_reason": null, "has_tool_call_success": null} | <br>(1 row)<br>

How to set up and validate locally

Verify Internal Events are being called

  • Run rails runner scripts/internal_events/monitor.rb start_mcp_tool_call finish_mcp_tool_call in your terminal
  • Make a MCP related tool call by setting up your MCP Server

Verify AI Internal Events are added

  • Go to postgres gdk psql
  • Execute select * from ai_usage_events order by id desc limit 1
  • You should see an event record with filled user_id, namespace_id, and extras including project_id, session_id, environment

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Nathan Weinshenker

Merge request reports

Loading