Skip to content

MetricsManager

faststream.prometheus.manager.MetricsManager #

MetricsManager(
    container: MetricsContainer,
    *,
    app_name: str = "faststream",
)
Source code in faststream/prometheus/manager.py
 8
 9
10
11
12
def __init__(
    self, container: MetricsContainer, *, app_name: str = "faststream"
) -> None:
    self._container = container
    self._app_name = app_name

add_received_message #

add_received_message(
    broker: str,
    handler: str,
    amount: int = 1,
    **custom_labels: str,
) -> None
Source code in faststream/prometheus/manager.py
14
15
16
17
18
19
20
21
22
23
24
25
26
def add_received_message(
    self,
    broker: str,
    handler: str,
    amount: int = 1,
    **custom_labels: str,
) -> None:
    self._container.received_messages_total.labels(
        app_name=self._app_name,
        broker=broker,
        handler=handler,
        **custom_labels,
    ).inc(amount)

observe_received_messages_size #

observe_received_messages_size(
    broker: str,
    handler: str,
    size: int,
    **custom_labels: str,
) -> None
Source code in faststream/prometheus/manager.py
28
29
30
31
32
33
34
35
36
37
38
39
40
def observe_received_messages_size(
    self,
    broker: str,
    handler: str,
    size: int,
    **custom_labels: str,
) -> None:
    self._container.received_messages_size_bytes.labels(
        app_name=self._app_name,
        broker=broker,
        handler=handler,
        **custom_labels,
    ).observe(size)

add_received_message_in_process #

add_received_message_in_process(
    broker: str,
    handler: str,
    amount: int = 1,
    **custom_labels: str,
) -> None
Source code in faststream/prometheus/manager.py
42
43
44
45
46
47
48
49
50
51
52
53
54
def add_received_message_in_process(
    self,
    broker: str,
    handler: str,
    amount: int = 1,
    **custom_labels: str,
) -> None:
    self._container.received_messages_in_process.labels(
        app_name=self._app_name,
        broker=broker,
        handler=handler,
        **custom_labels,
    ).inc(amount)

remove_received_message_in_process #

remove_received_message_in_process(
    broker: str,
    handler: str,
    amount: int = 1,
    **custom_labels: str,
) -> None
Source code in faststream/prometheus/manager.py
56
57
58
59
60
61
62
63
64
65
66
67
68
def remove_received_message_in_process(
    self,
    broker: str,
    handler: str,
    amount: int = 1,
    **custom_labels: str,
) -> None:
    self._container.received_messages_in_process.labels(
        app_name=self._app_name,
        broker=broker,
        handler=handler,
        **custom_labels,
    ).dec(amount)

add_received_processed_message #

add_received_processed_message(
    broker: str,
    handler: str,
    status: ProcessingStatus,
    amount: int = 1,
    **custom_labels: str,
) -> None
Source code in faststream/prometheus/manager.py
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
def add_received_processed_message(
    self,
    broker: str,
    handler: str,
    status: ProcessingStatus,
    amount: int = 1,
    **custom_labels: str,
) -> None:
    self._container.received_processed_messages_total.labels(
        app_name=self._app_name,
        broker=broker,
        handler=handler,
        status=status.value,
        **custom_labels,
    ).inc(amount)

observe_received_processed_message_duration #

observe_received_processed_message_duration(
    duration: float,
    broker: str,
    handler: str,
    **custom_labels: str,
) -> None
Source code in faststream/prometheus/manager.py
86
87
88
89
90
91
92
93
94
95
96
97
98
def observe_received_processed_message_duration(
    self,
    duration: float,
    broker: str,
    handler: str,
    **custom_labels: str,
) -> None:
    self._container.received_processed_messages_duration_seconds.labels(
        app_name=self._app_name,
        broker=broker,
        handler=handler,
        **custom_labels,
    ).observe(duration)

add_received_processed_message_exception #

add_received_processed_message_exception(
    broker: str,
    handler: str,
    exception_type: str,
    **custom_labels: str,
) -> None
Source code in faststream/prometheus/manager.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
def add_received_processed_message_exception(
    self,
    broker: str,
    handler: str,
    exception_type: str,
    **custom_labels: str,
) -> None:
    self._container.received_processed_messages_exceptions_total.labels(
        app_name=self._app_name,
        broker=broker,
        handler=handler,
        exception_type=exception_type,
        **custom_labels,
    ).inc()

add_published_message #

add_published_message(
    broker: str,
    destination: str,
    status: PublishingStatus,
    amount: int = 1,
    **custom_labels: str,
) -> None
Source code in faststream/prometheus/manager.py
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
def add_published_message(
    self,
    broker: str,
    destination: str,
    status: PublishingStatus,
    amount: int = 1,
    **custom_labels: str,
) -> None:
    self._container.published_messages_total.labels(
        app_name=self._app_name,
        broker=broker,
        destination=destination,
        status=status.value,
        **custom_labels,
    ).inc(amount)

observe_published_message_duration #

observe_published_message_duration(
    duration: float,
    broker: str,
    destination: str,
    **custom_labels: str,
) -> None
Source code in faststream/prometheus/manager.py
131
132
133
134
135
136
137
138
139
140
141
142
143
def observe_published_message_duration(
    self,
    duration: float,
    broker: str,
    destination: str,
    **custom_labels: str,
) -> None:
    self._container.published_messages_duration_seconds.labels(
        app_name=self._app_name,
        broker=broker,
        destination=destination,
        **custom_labels,
    ).observe(duration)

add_published_message_exception #

add_published_message_exception(
    broker: str,
    destination: str,
    exception_type: str,
    **custom_labels: str,
) -> None
Source code in faststream/prometheus/manager.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
def add_published_message_exception(
    self,
    broker: str,
    destination: str,
    exception_type: str,
    **custom_labels: str,
) -> None:
    self._container.published_messages_exceptions_total.labels(
        app_name=self._app_name,
        broker=broker,
        destination=destination,
        exception_type=exception_type,
        **custom_labels,
    ).inc()