File: base.py

package info (click to toggle)
python-snitun 0.45.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 640 kB
  • sloc: python: 6,681; sh: 5; makefile: 3
file content (71 lines) | stat: -rw-r--r-- 1,689 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""Base metrics collector interface."""

from abc import ABC, abstractmethod


class MetricsCollector(ABC):
    """Abstract base class for metrics collection."""

    @abstractmethod
    def gauge(
        self,
        name: str,
        value: float,
        tags: dict[str, str] | None = None,
    ) -> None:
        """
        Set a gauge metric to a specific value.

        Args:
            name: Metric name (e.g., 'snitun.peer.connections')
            value: Current value
            tags: Optional tags for the metric
        """

    @abstractmethod
    def increment(
        self,
        name: str,
        value: float = 1,
        tags: dict[str, str] | None = None,
    ) -> None:
        """
        Increment a counter metric.

        Args:
            name: Metric name (e.g., 'snitun.connections.new')
            value: Amount to increment (default: 1)
            tags: Optional tags for the metric
        """

    @abstractmethod
    def histogram(
        self,
        name: str,
        value: float,
        tags: dict[str, str] | None = None,
    ) -> None:
        """
        Record a value in a histogram.

        Args:
            name: Metric name (e.g., 'snitun.connection.duration')
            value: Value to record
            tags: Optional tags for the metric
        """

    @abstractmethod
    def timing(
        self,
        name: str,
        value: float,
        tags: dict[str, str] | None = None,
    ) -> None:
        """
        Record a timing value.

        Args:
            name: Metric name (e.g., 'snitun.handshake.time')
            value: Time in milliseconds
            tags: Optional tags for the metric
        """