diff --git a/python/instrumentation/openinference-instrumentation-guardrails/src/openinference/instrumentation/guardrails/__init__.py b/python/instrumentation/openinference-instrumentation-guardrails/src/openinference/instrumentation/guardrails/__init__.py index 316ef2d5d..6d0120fce 100644 --- a/python/instrumentation/openinference-instrumentation-guardrails/src/openinference/instrumentation/guardrails/__init__.py +++ b/python/instrumentation/openinference-instrumentation-guardrails/src/openinference/instrumentation/guardrails/__init__.py @@ -50,8 +50,6 @@ def instrumentation_dependencies(self) -> Collection[str]: return _instruments def _instrument(self, **kwargs: Any) -> None: - import guardrails as gd - version = Version(metadata.version("guardrails-ai")) global GUARDRAILS_VERSION GUARDRAILS_VERSION = (version.major, version.minor, version.micro) @@ -60,6 +58,8 @@ def _instrument(self, **kwargs: Any) -> None: logger.info("Guardrails version >= 0.5.2 detected, skipping instrumentation") return + import guardrails as gd + if not (tracer_provider := kwargs.get("tracer_provider")): tracer_provider = trace_api.get_tracer_provider() if not (config := kwargs.get("config")):