Skip to main content

cliffracer-metrics

Dispatch timing and counting for cliffracer services, plus batching and connection-pooling helpers.

from cliffracer import CliffracerService, ServiceConfig
from cliffracer_metrics import MetricsExtension

class OrderService(CliffracerService):
    metrics = MetricsExtension()

MetricsExtension records a count, an error count and a latency window per dispatch kind, and contributes them to /health under the attribute name you declared it as. Declared as metrics above, its numbers appear under "metrics".

A refusal is counted separately from a handler error, so a service refusing unauthenticated callers reports that as policy rather than as a thousand crashes.

A pool of connections

from cliffracer import CliffracerService, rpc
from cliffracer_metrics import PoolExtension

class Ingest(CliffracerService):
    pool = PoolExtension(max_connections=8)

    @rpc
    async def bulk(self, subject: str) -> dict[str, bool]:
        reply = await self.pool.request(subject, b"{}")
        return {"ok": True}

PoolExtension builds an OptimizedNATSConnection from the service's own config, credentials included, connects it when the service starts, closes it when the service stops, and reports its connection count under /health.

The pool is a second set of connections the handler reaches for. The service's own connection carries call_rpc, publish_event and every subscription, so what goes through the pool is what a handler sends through it.

You construct BatchProcessor and PerformanceMetrics yourself. Each has a package test that builds and exercises it, which is the working example of how to use it.

Installed from PyPI, versioned in lockstep with cliffracer.

Metadata

Release files for cliffracer-metrics 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cliffracer-metrics 1.0.0
File Size Uploaded
cliffracer_metrics-1.0.0.tar.gz 15.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cliffracer-metrics 1.0.0
File Interpreter ABI Platform
cliffracer_metrics-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.6 kB

Release files / cliffracer_metrics-1.0.0.tar.gz

Download URL cliffracer_metrics-1.0.0.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9c62881eb0f2d62713301d9a9256323e2aab8e663dd5d6cda8a9b37cd8503468
BLAKE2b-256 checksum
How to use checksums
065f85ef4ee8c835ca0907ca4a829d43a555f3f3edec555a49295a10f14dc3bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / cliffracer_metrics-1.0.0-py3-none-any.whl

Download URL cliffracer_metrics-1.0.0-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c80f20c1889973644d85acc7c44f114ac166e0068c8f504318dc650babddcdc7
BLAKE2b-256 checksum
How to use checksums
12b028d1a4830b94e363f88ffe2c8becd7ed4ad95c3bf3ebb92426406ea1ed37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page