{"id":"312d7b06c6fc274c","repo":"redis/redis-py","slug":"opentelemetry-api-is-not-installed-install-it-wit","errorCode":null,"errorMessage":"OpenTelemetry API is not installed. Install it with: pip install opentelemetry-api","messagePattern":"OpenTelemetry API is not installed\\. Install it with: pip install opentelemetry-api","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"redis/observability/metrics.py","lineNumber":84,"sourceCode":"class RedisMetricsCollector:\n    \"\"\"\n    Collects and records OpenTelemetry metrics for Redis operations.\n\n    This class manages all metric instruments and provides methods to record\n    various Redis operations including connection pool events, command execution,\n    and cluster-specific operations.\n\n    Args:\n        meter: OpenTelemetry Meter instance\n        config: OTel configuration object\n    \"\"\"\n\n    METER_NAME = \"redis-py\"\n    METER_VERSION = \"1.0.0\"\n\n    def __init__(self, meter: Meter, config: OTelConfig):\n        if not OTEL_AVAILABLE:\n            raise ImportError(\n                \"OpenTelemetry API is not installed. \"\n                \"Install it with: pip install opentelemetry-api\"\n            )\n\n        self.meter = meter\n        self.config = config\n        self.attr_builder = AttributeBuilder()\n\n        # Initialize enabled metric instruments\n\n        if MetricGroup.RESILIENCY in self.config.metric_groups:\n            self._init_resiliency_metrics()\n\n        if MetricGroup.COMMAND in self.config.metric_groups:\n            self._init_command_metrics()\n\n        if MetricGroup.CONNECTION_BASIC in self.config.metric_groups:\n            self._init_connection_basic_metrics()","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/observability/metrics.py#L66-L102","documentation":"Error \"OpenTelemetry API is not installed. Install it with: pip install opentelemetry-api\" thrown in redis/redis-py.","triggerScenarios":"Thrown at redis/observability/metrics.py:84 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}