[BUG] pull_request.count metric not emitted when MR/PR created via MCP tools (e.g. gitlab create_merge_request)

Resolved 💬 1 comment Opened Apr 9, 2026 by bangau1 Closed May 4, 2026

Summary

The claude_code.pull_request.count telemetry metric is not incremented when a merge request or pull request is created via an MCP tool (e.g., mcp__gitlab__create_merge_request). The metric is only emitted when the PR/MR is created via a CLI command through the Bash tool (e.g., glab mr create, gh pr create).

Environment

  • Claude Code Version: 2.1.97
  • OS: macOS Darwin 25.3.0
  • Terminal: VS Code / tmux
  • Telemetry Backend: OpenTelemetry → OTLP Collector → ClickHouse
  • MCP Server: Official GitLab MCP server (installed as Claude Code plugin via marketplace)
  • MCP Server Type: HTTP (https://gitlab.com/api/v4/mcp)
  • MCP Plugin Source: claude-plugins-official/external_plugins/gitlab

Steps to Reproduce

  1. Enable telemetry with CLAUDE_CODE_ENABLE_TELEMETRY=1 and OTEL_LOG_TOOL_DETAILS=1
  2. Start a Claude Code session
  3. Create a merge request using the GitLab MCP tool (mcp__gitlab__create_merge_request)
  4. Check the claude_code.pull_request.count metric in your telemetry backend — it is missing
  5. In a separate session, create a merge request using glab mr create via the Bash tool
  6. Check the metric again — it IS emitted

Evidence

MR created via MCP tool — metric NOT emitted

A session created a GitLab MR at 2026-04-09 05:29:18 UTC via mcp__gitlab__create_merge_request.

otel_logs confirms the MCP tool call:

Timestamp: 2026-04-09 05:29:18.071
tool_name: mcp_tool
tool_parameters: {"mcp_server_name":"gitlab","mcp_tool_name":"create_merge_request"}
tool_input: {"project_id":"<redacted>","title":"<redacted>","source_branch":"<redacted>","target_branch":"main",...}

otel_metrics_sum for this session shows these metrics were emitted:

  • claude_code.session.count
  • claude_code.commit.count
  • claude_code.cost.usage
  • claude_code.token.usage
  • claude_code.active_time.total
  • claude_code.pull_request.count — MISSING

MR created via Bash tool — metric IS emitted

A different session created an MR at 2026-04-09 14:29:05 UTC via glab mr create --draft through the Bash tool.

otel_metrics_sum for this session:

  • claude_code.pull_request.count = 1 — emitted at 2026-04-09 14:29:22 UTC

Expected Behavior

claude_code.pull_request.count should increment regardless of whether the PR/MR was created via:

  • Bash tool (gh pr create, glab mr create)
  • MCP tool (mcp__gitlab__create_merge_request, mcp__github__create_pull_request, etc.)

Both methods create a PR/MR "via Claude Code" and should be tracked equivalently.

Actual Behavior

The metric only fires for Bash-based PR/MR creation. MCP tool invocations that create PRs/MRs are silently ignored by the telemetry instrumentation.

Root Cause Hypothesis

The pull_request.count instrumentation likely detects PR creation by pattern-matching Bash command output (e.g., matching gh pr create or glab mr create commands). There is no equivalent detection for MCP tool calls like create_merge_request or create_pull_request.

Impact

Organizations tracking developer productivity via the pull_request.count metric get undercounted PR numbers when users create PRs through MCP tools. This is increasingly common as MCP adoption grows and users rely on GitLab/GitHub MCP servers for workflow automation.

Related Issues

  • #20918 — Telemetry counters (commit.count, pull_request.count) don't increment for multiple events within a session (closed/stale, different but related)

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗