redis/redis-py · error · NotImplementedError

LATENCY HISTOGRAM is intentionally not implemented in the…

Error message

LATENCY HISTOGRAM is intentionally not implemented in the client.

What it means

Raised by latency_histogram() (redis/commands/core.py:1964) which is a stub that unconditionally raises NotImplementedError. Note the actual server command for per-command latency histograms is INFO LATENCYSTATS, not LATENCY HISTOGRAM; this stub exists to reserve the name and document that the old LATENCY HISTOGRAM shape is unsupported. Related supported commands: latency_history, latency_latest, latency_reset. Any call raises immediately.

Solutions

  1. For per-command latency histograms use: r.execute_command("INFO", "LATENCYSTATS") (server-side)
  2. For event latency time-series use r.latency_history(event) or r.latency_latest()
  3. Render percentiles client-side from latency_history samples

Example fix

# before
r.latency_histogram("GET")
# after
hist = r.execute_command("INFO", "LATENCYSTATS")
Defensive patterns

Strategy: fallback

Validate before calling

# latency_histogram() is intentionally unimplemented; use INFO LATENCYSTATS
def latency_histograms(r):
    return r.execute_command("INFO", "LATENCYSTATS")

Try / catch

try:
    r.latency_histogram()
except NotImplementedError:
    hist = r.execute_command("INFO", "LATENCYSTATS")

Prevention

When it happens

Trigger: Calling r.latency_histogram() or r.latency_histogram("GET"). Any call raises immediately.

Common situations: Wanting command latency percentile data and guessing the method name; migrating from a tool that exposed a 'latency histogram'.

Related errors


AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10). Data as JSON: /api/errors/ee8aae5533d9ed9e. Report an issue: GitHub.

Appendix: source

Thrown at redis/commands/core.py:1964

    def memory_purge(self: SyncClientProtocol, **kwargs) -> bool: ...

    @overload
    def memory_purge(self: AsyncClientProtocol, **kwargs) -> Awaitable[bool]: ...

    def memory_purge(self, **kwargs) -> bool | Awaitable[bool]:
        """
        Attempts to purge dirty pages for reclamation by allocator

        For more information, see https://redis.io/commands/memory-purge
        """
        return self.execute_command("MEMORY PURGE", **kwargs)

    def latency_histogram(self, *args):
        """
        This function throws a NotImplementedError since it is intentionally
        not supported.
        """
        raise NotImplementedError(
            "LATENCY HISTOGRAM is intentionally not implemented in the client."
        )

    @overload
    def latency_history(self: SyncClientProtocol, event: str) -> list[list[int]]: ...

    @overload
    def latency_history(
        self: AsyncClientProtocol, event: str
    ) -> Awaitable[list[list[int]]]: ...

    def latency_history(
        self, event: str
    ) -> list[list[int]] | Awaitable[list[list[int]]]:
        """
        Returns the raw data of the ``event``'s latency spikes time series.

        For more information, see https://redis.io/commands/latency-history

View on GitHub (pinned to 6a6b581b48)