aiodogstatsd is an asyncio-based client for sending metrics to StatsD with support for the DogStatsD extension. It supports gauge, counter, histogram, distribution, and timing metric types. The library is actively maintained, currently at version 0.16.0.post0, and features a consistent release cadence with updates for Python version compatibility and framework integrations.
pip install aiodogstatsdVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the aiodogstatsd client using an async context manager and send basic increment, gauge, and timing metrics. The context manager ensures proper connection handling. Environment variables are used for host and port configuration, defaulting to 'localhost' and '9125' respectively.
Upgrade your Python environment to 3.7 or newer. Update your `requires_python` specification if applicable.
If migrating from an older version, remove Sanic-specific integration code. Consider using a Sanic-native StatsD client if Sanic integration is critical, or integrate aiodogstatsd manually if possible for your use case.
Initialize the client with `Client(port=8125, ...)` if targeting a standard StatsD or Datadog Agent setup.
Adopt the `async with` context manager pattern for client initialization and usage to prevent resource leaks and ensure robustness.
Monitor for dropped metrics. Consider optimizing network settings, increasing UDP buffer sizes on the host, or exploring client-side aggregation features (if available in a StatsD client, though not a primary feature of `aiodogstatsd`) to reduce packet volume. Ensure your StatsD server (e.g., Datadog Agent) is adequately resourced.
Install the package using pip: 'pip install aiodogstatsd'.
Ensure that 'aiodogstatsd.Client' is instantiated correctly and not called as a function.
Import the 'Client' class correctly: 'from aiodogstatsd import Client'.
Verify that the StatsD server is running and that the host and port settings in 'aiodogstatsd.Client' match the server's configuration.
Ensure that all asyncio operations are completed before closing the event loop, and avoid running new operations after it has been closed.