GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `sentry_sdk.init()` slowed by module-level `package_version("mcp")` scanning all installed distributions (2.64.0) · Issue #6769 · getsentry/sentry-python

sentry_sdk.init() slowed by module-level package_version("mcp") scanning all installed distributions (2.64.0) #6769

New issue
Copy link
New issue
Copy link
Closed
Closed
sentry_sdk.init() slowed by module-level package_version("mcp") scanning all installed distributions (2.64.0)#6769
Copy link
Assignees
alexander-alderman-webb
Labels
BugPythonSDKSDK

Description

@tejas7777
tejas7777
opened on Jul 7, 2026
Issue body actions

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.64.0

Steps to Reproduce

In any environment with a few hundred installed packages and mcp not installed:

import time
from sentry_sdk.integrations import DidNotEnable

t = time.perf_counter()
try:
    import sentry_sdk.integrations.mcp
except DidNotEnable:
    pass
print(f'{time.perf_counter() - t:.3f}s')

With ~200 installed distributions: 0.202s on 2.64.0 vs 0.052s on 2.63.0. The cost scales with the number of installed distributions.

sentry_sdk.init() imports this module through auto-enabling integrations, so every init() pays this even when mcp is not installed. In a process where all other imports are already warm (e.g. a forked worker), init() goes from ~0.04s to ~0.28s.

Expected Result

When mcp is not installed, the MCP integration raises DidNotEnable without doing any expensive work, as in 2.63.0.

Actual Result

#6583 added a module-level call at the top of sentry_sdk/integrations/mcp.py, above the try/except ImportError guard:

MCP_PACKAGE_VERSION = package_version("mcp")

package_version() -> _get_installed_modules() parses the metadata of every installed distribution. Profiling init() attributes nearly all of the added time to this line.

This mainly hurts short-lived processes that call init() per process (test suites forking workers, CLIs, cron jobs) - our CI worker-boot timing assertions started failing on the 2.63.0 -> 2.64.0 bump.

Suggested fix: move the package_version("mcp") call below the import mcp guard (or compute it lazily in setup_once()), so environments without mcp skip the scan.

Activity

  1. getsantry
    added
    Waiting for: Product Owner
    on Jul 7, 2026
  2. linear-code commented on Jul 7, 2026

    @linear-code
    linear-codeBot
    on Jul 7, 2026 – with Linear Code
    More actions

    PY-2599

  3. getsantry
    moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 7, 2026
  4. getsantry
    added this to GitHub Issues with 👀 3on Jul 7, 2026
  5. linear-code
    added
    Bug
    PythonSDKSDK
    on Jul 7, 2026
  6. alexander-alderman-webb
    self-assigned this
    on Jul 7, 2026
  7. alexander-alderman-webb commented on Jul 7, 2026

    @alexander-alderman-webb
    alexander-alderman-webb
    on Jul 7, 2026
    Collaborator
    More actions

    Thanks @tejas7777 I'll address

    Reacted by Tejas Chendekar
  8. getsantry
    removed
    Waiting for: Product Owner
    on Jul 7, 2026
  9. getsantry
    moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 7, 2026
  10. mangodxd
    added a commit that references this issue on Jul 23, 2026

    perf: Avoid scanning installed packages when MCP SDK is not installed (…

    07564c8
  11. alexander-alderman-webb commented on Sep 7, 2026

    @alexander-alderman-webb
    alexander-alderman-webb
    on Sep 7, 2026
    Collaborator
    More actions

    This was resolved in 5bd85b4, released in 2.67.0 of the SDK.

  12. alexander-alderman-webb
    closed this as completedon Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @alexander-alderman-webb
    alexander-alderman-webb

Labels

BugPythonSDKSDK

Projects

  • GitHub Issues with 👀 3
    Status
    No status
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.