Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix replication metrics when using redis #7325

Merged
merged 4 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions synapse/replication/tcp/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,16 @@
"synapse_replication_tcp_protocol_close_reason", "", ["reason_type"]
)

tcp_inbound_commands = Counter(
"synapse_replication_tcp_protocol_inbound_commands", "", ["command", "name"],
tcp_inbound_commands_counter = Counter(
"synapse_replication_tcp_protocol_inbound_commands",
"Number of commands received from replication",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Number of commands received from replication",
"Number of commands received over replication, by command and connection ID",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're not connection IDs, they're what they're connected to, will change

["command", "name"],
)

tcp_outbound_commands = Counter(
"synapse_replication_tcp_protocol_outbound_commands", "", ["command", "name"],
tcp_outbound_commands_counter = Counter(
"synapse_replication_tcp_protocol_outbound_commands",
"Number of commands sent to replication",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Number of commands sent to replication",
"Number of commands sent out over replication, by command and connection ID",

["command", "name"],
)

# A list of all connected protocols. This allows us to send metrics about the
Expand Down Expand Up @@ -226,7 +230,7 @@ def lineReceived(self, line: bytes):

self.last_received_command = self.clock.time_msec()

tcp_inbound_commands.labels(cmd.NAME, self.name).inc()
tcp_inbound_commands_counter.labels(cmd.NAME, self.name).inc()

# Now lets try and call on_<CMD_NAME> function
run_as_background_process(
Expand Down Expand Up @@ -292,7 +296,7 @@ def send_command(self, cmd, do_buffer=True):
self._queue_command(cmd)
return

tcp_outbound_commands.labels(cmd.NAME, self.name).inc()
tcp_outbound_commands_counter.labels(cmd.NAME, self.name).inc()

string = "%s %s" % (cmd.NAME, cmd.to_line())
if "\n" in string:
Expand Down
8 changes: 4 additions & 4 deletions synapse/replication/tcp/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
)
from synapse.replication.tcp.protocol import (
AbstractConnection,
tcp_inbound_commands,
tcp_outbound_commands,
tcp_inbound_commands_counter,
tcp_outbound_commands_counter,
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -85,7 +85,7 @@ def messageReceived(self, pattern: str, channel: str, message: str):

# We use "redis" as the name here as we don't have 1:1 connections to
# remote instances.
tcp_inbound_commands.labels(cmd.NAME, "redis").inc()
tcp_inbound_commands_counter.labels(cmd.NAME, "redis").inc()

# Now lets try and call on_<CMD_NAME> function
run_as_background_process(
Expand Down Expand Up @@ -136,7 +136,7 @@ def send_command(self, cmd: Command):

# We use "redis" as the name here as we don't have 1:1 connections to
# remote instances.
tcp_outbound_commands.labels(cmd.NAME, "redis").inc()
tcp_outbound_commands_counter.labels(cmd.NAME, "redis").inc()

async def _send():
with PreserveLoggingContext():
Expand Down