Skip to content

Commit cbd468e

Browse files
create mock for Gauge class
1 parent 9c8fc7e commit cbd468e

File tree

13 files changed

+322
-94
lines changed

13 files changed

+322
-94
lines changed

synapse/app/phone_stats_home.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
import sys
2525
from typing import TYPE_CHECKING, Mapping, Sized
2626

27-
from prometheus_client import Gauge
28-
2927
from twisted.internet import defer
3028

31-
from synapse.metrics import SERVER_NAME_LABEL
29+
from synapse.metrics import SERVER_NAME_LABEL, SynapseGauge
3230
from synapse.types import JsonDict
3331
from synapse.util.constants import (
3432
MILLISECONDS_PER_SECOND,
@@ -57,22 +55,22 @@
5755
_stats_process: list[tuple[int, "resource.struct_rusage"]] = []
5856

5957
# Gauges to expose monthly active user control metrics
60-
current_mau_gauge = Gauge(
58+
current_mau_gauge = SynapseGauge(
6159
"synapse_admin_mau_current",
6260
"Current MAU",
6361
labelnames=[SERVER_NAME_LABEL],
6462
)
65-
current_mau_by_service_gauge = Gauge(
63+
current_mau_by_service_gauge = SynapseGauge(
6664
"synapse_admin_mau_current_mau_by_service",
6765
"Current MAU by service",
6866
labelnames=["app_service", SERVER_NAME_LABEL],
6967
)
70-
max_mau_gauge = Gauge(
68+
max_mau_gauge = SynapseGauge(
7169
"synapse_admin_mau_max",
7270
"MAU Limit",
7371
labelnames=[SERVER_NAME_LABEL],
7472
)
75-
registered_reserved_users_mau_gauge = Gauge(
73+
registered_reserved_users_mau_gauge = SynapseGauge(
7674
"synapse_admin_mau_registered_reserved_users",
7775
"Registered users with reserved threepids",
7876
labelnames=[SERVER_NAME_LABEL],

synapse/federation/federation_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
Union,
3333
)
3434

35-
from prometheus_client import Gauge, Histogram
35+
from prometheus_client import Histogram
3636

3737
from twisted.python import failure
3838

@@ -79,7 +79,7 @@
7979
tag_args,
8080
trace,
8181
)
82-
from synapse.metrics import SERVER_NAME_LABEL, SynapseCounter
82+
from synapse.metrics import SERVER_NAME_LABEL, SynapseCounter, SynapseGauge
8383
from synapse.metrics.background_process_metrics import wrap_as_background_process
8484
from synapse.replication.http.federation import (
8585
ReplicationFederationSendEduRestServlet,
@@ -122,7 +122,7 @@
122122
labelnames=[SERVER_NAME_LABEL],
123123
)
124124

125-
last_pdu_ts_metric = Gauge(
125+
last_pdu_ts_metric = SynapseGauge(
126126
"synapse_federation_last_received_pdu_time",
127127
"The timestamp of the last PDU which was successfully received from the given domain",
128128
labelnames=("origin_server_name", SERVER_NAME_LABEL),

synapse/federation/sender/transaction_manager.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import logging
2121
from typing import TYPE_CHECKING
2222

23-
from prometheus_client import Gauge
24-
2523
from synapse.api.constants import EduTypes
2624
from synapse.api.errors import HttpResponseException
2725
from synapse.events import EventBase
@@ -34,7 +32,7 @@
3432
tags,
3533
whitelisted_homeserver,
3634
)
37-
from synapse.metrics import SERVER_NAME_LABEL
35+
from synapse.metrics import SERVER_NAME_LABEL, SynapseGauge
3836
from synapse.types import JsonDict
3937
from synapse.util.json import json_decoder
4038
from synapse.util.metrics import measure_func
@@ -45,7 +43,7 @@
4543
logger = logging.getLogger(__name__)
4644
issue_8631_logger = logging.getLogger("synapse.8631_debug")
4745

48-
last_pdu_ts_metric = Gauge(
46+
last_pdu_ts_metric = SynapseGauge(
4947
"synapse_federation_last_sent_pdu_time",
5048
"The timestamp of the last PDU which was successfully sent to the given domain",
5149
labelnames=("destination_server_name", SERVER_NAME_LABEL),

0 commit comments

Comments
 (0)