Source code for taimoe.platform.instrumentation

"""Auto-instrumentation modules."""

from __future__ import annotations

import sys

from .adk import patch as patch_adk
from .adk import unpatch as unpatch_adk


[docs] def patch_all() -> dict[str, bool]: """Apply every supported auto-instrumentation. Returns a ``{library: succeeded}`` map so callers can log or surface which integrations took effect. ``True`` means at least one of that library's monkey-patches landed; ``False`` means the library wasn't importable or every patch refused. """ return {"google-adk": patch_adk()}
[docs] def unpatch_all() -> None: """Reverse whatever ``patch_all()`` managed to apply.""" unpatch_adk()
[docs] def is_adk_available() -> bool: """Return True if ``google.adk`` has already been imported by the host. Used by ``init()`` so L4 / L5 callers don't pay the ADK patch cost when they're not using ADK. We check ``sys.modules`` rather than ``import google.adk`` because importing would itself pull ADK into the host's import graph. """ return "google.adk" in sys.modules
__all__ = ["patch_adk", "unpatch_adk", "patch_all", "unpatch_all", "is_adk_available"]