File: statsd.py

package info (click to toggle)
python-urllib3 2.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,340 kB
  • sloc: python: 26,167; makefile: 122; javascript: 92; sh: 11
file content (16 lines) | stat: -rw-r--r-- 493 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from __future__ import annotations

import trio

from ..config import Config
from ..statsd import StatsdLogger as Base


class StatsdLogger(Base):
    def __init__(self, config: Config) -> None:
        super().__init__(config)
        self.address = tuple(config.statsd_host.rsplit(":", 1))
        self.socket = trio.socket.socket(trio.socket.AF_INET, trio.socket.SOCK_DGRAM)

    async def _socket_send(self, message: bytes) -> None:
        await self.socket.sendto(message, self.address)