StatsD client in Python with support for Telegraf and SRV records in DNS
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
telestatsd
.gitignore
LICENSE
README.md
release.sh
setup.py

README.md

telestatsd

StatsD client in Python with support for Telegraf and SRV records in DNS.

Features

  • SRV records in DNS
  • Support for StatsD input plugin in Telgraf and its additional features like tags
  • Pluggable system of address providers with SRV or static providers supported off-the-shelf

Examples

UDP client with default address provider pointing to localhost:8215

from telestatsd.clients.udp import Client

client = Client(tags={'foo': 1})
client.incr('success', 1)

INET (static) address provider

INET provider returns (host, port) tuple for AF_INET address family where host and port are passed while creating provider object.

from telestatsd.address_providers.inet import Provider
from telestatsd.clients.udp import Client

address_provider = Provider(host='localhost', port=8125)
client = Client(tags={'foo': 1}, address_provider=address_provider)
client.incr('success', 1)

inet.Provider has default host (localhost) and port (8125) so its initialization can be shortened:

client = Client(tags={'foo': 1}, address_provider=Provider())

SRVINET address provider

SRVINET provider returns (host, port) tuple for AF_INET address family where host and port are retrieved from first SRV record returned by DNS server.

from telestatsd.address_providers.srvinet import Provider
from telestatsd.clients.udp import Client

address_provider = Provider(service='telegraf-in-docker',
                            domain='marathon.mesos',
                            protocol=Provider.PROTO_UDP)

lient = Client(tags={'foo': 1}, address_provider=address_provider)
client.incr('success', 1)

Logger client

import logging
import sys

from telestatsd.clients.logger import Client

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
client = Client(tags={'foo': 1})
client.incr('success')
> INFO:telestatsd.clients.logger:success,foo=1:1|c